User: oberg   
  Date: 00/06/16 06:10:26

  Modified:    src/main/org/jboss/ejb/plugins/jrmp/interfaces
                        ContainerRemote.java EntityProxy.java
                        GenericProxy.java HomeProxy.java
                        SecureSocketFactory.java StatefulSessionProxy.java
                        StatelessSessionProxy.java
  Added:       src/main/org/jboss/ejb/plugins/jrmp/interfaces
                        RemoteMethodInvocation.java
  Log:
  Added configuration service
  Changed interceptors to be messagebased
  Added mini webserver
  Changed server bootstrap process
  
  Revision  Changes    Path
  1.4       +6 -6      
jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/ContainerRemote.java
  
  Index: ContainerRemote.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/ContainerRemote.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ContainerRemote.java      2000/05/12 11:19:05     1.3
  +++ ContainerRemote.java      2000/06/16 13:10:25     1.4
  @@ -11,14 +11,14 @@
   import java.rmi.Remote;
   import java.rmi.MarshalledObject;
   
  -import javax.naming.Name;
  +import javax.transaction.Transaction;
   
   /**
    *   <description> 
    *      
    *   @see <related>
    *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.3 $
  + *   @version $Revision: 1.4 $
    */
   public interface ContainerRemote
      extends Remote
  @@ -31,16 +31,16 @@
      // Public --------------------------------------------------------
   
      // ContainerRemote implementation --------------------------------
  -   public Object invokeHome(MarshalledObject mi, Object tx, Principal user)
  +   public Object invokeHome(MarshalledObject mi)
         throws Exception;
   
  -   public Object invoke(MarshalledObject mi, Object tx, Principal user)
  +   public Object invoke(MarshalledObject mi)
         throws Exception;
   
  -   public Object invokeHome(Method m, Object[] args, Object tx, Principal user)
  +   public Object invokeHome(Method m, Object[] args, Transaction tx, Principal 
identity)
         throws Exception;
   
  -   public Object invoke(Object id, Method m, Object[] args, Object tx, Principal 
user)
  +   public Object invoke(Object id, Method m, Object[] args, Transaction tx, 
Principal identity)
         throws Exception;
      // Package protected ---------------------------------------------
       
  
  
  
  1.9       +17 -15    
jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/EntityProxy.java
  
  Index: EntityProxy.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/EntityProxy.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- EntityProxy.java  2000/05/30 18:32:26     1.8
  +++ EntityProxy.java  2000/06/16 13:10:25     1.9
  @@ -19,9 +19,9 @@
    *      
    *      @see <related>
    *      @author Rickard �berg ([EMAIL PROTECTED])
  - *      @version $Revision: 1.8 $
  + *      @version $Revision: 1.9 $
    */
  -public abstract class EntityProxy
  +public class EntityProxy
      extends GenericProxy
   {
      // Constants -----------------------------------------------------
  @@ -64,7 +64,7 @@
      // Public --------------------------------------------------------
   
      // InvocationHandler implementation ------------------------------
  -   public Object invoke(Object proxy, Method m, Object[] args)
  +   public final Object invoke(Object proxy, Method m, Object[] args)
         throws Throwable
      {
         // Normalize args to always be an array
  @@ -99,18 +99,20 @@
         }
         else
         {
  -         // Delegate to container
  -         // Optimize if calling another bean in same EJB-application
  -         if (optimize && isLocal())
  -         {
  -            return container.invoke(id, m, args, null, null);
  -         }
  -                
  -         Object result = container.invoke(new MarshalledObject(new 
MethodInvocation(id, m, args)), null, null);
  -         if (result instanceof MarshalledObject)
  -            return ((MarshalledObject)result).get();
  -         else
  -            return result;
  +           // Delegate to container
  +           // Optimize if calling another bean in same EJB-application
  +           if (optimize && isLocal())
  +           {
  +              return container.invoke(id, m, args, 
  +                                                                                    
         tm != null ? tm.getTransaction() : null,
  +                                                                                    
         null);
  +           } else
  +           {
  +              RemoteMethodInvocation rmi = new RemoteMethodInvocation(id, m, args);
  +              if (tm != null)
  +                 rmi.setTransaction(tm.getTransaction());
  +              return container.invoke(new MarshalledObject(rmi));
  +           }
         }
      }
   
  
  
  
  1.3       +34 -3     
jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/GenericProxy.java
  
  Index: GenericProxy.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/GenericProxy.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GenericProxy.java 2000/05/17 06:31:06     1.2
  +++ GenericProxy.java 2000/06/16 13:10:25     1.3
  @@ -8,14 +8,20 @@
   
   import java.io.IOException;
   
  +import javax.transaction.TransactionManager;
  +
  +import org.jboss.ejb.MethodInvocation;
   import org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker;
  +import org.jboss.tm.TxManager;
  +
  +import java.util.HashMap;
   
   /**
    *      <description> 
    *      
    *      @see <related>
    *      @author Rickard �berg ([EMAIL PROTECTED])
  - *      @version $Revision: 1.2 $
  + *      @version $Revision: 1.3 $
    */
   public class GenericProxy
      implements java.io.Serializable
  @@ -30,6 +36,17 @@
      boolean optimize = false;
      
      // Static --------------------------------------------------------
  +   static TransactionManager tm;
  +     
  +   static HashMap invokers = new HashMap(); // Prevent DGC
  +   public static ContainerRemote getLocal(String jndiName) { return 
(ContainerRemote)invokers.get(jndiName); }
  +   public static void addLocal(String jndiName, ContainerRemote invoker) { 
invokers.put(jndiName, invoker); }
  +   public static void removeLocal(String jndiName) { invokers.remove(jndiName); }
  +     
  +     public static void setTransactionManager(TransactionManager txMan)
  +     {
  +             tm = txMan;
  +     }
   
      // Constructors --------------------------------------------------
      protected GenericProxy(String name, ContainerRemote container, boolean optimize)
  @@ -50,6 +67,21 @@
      }
       
      // Private -------------------------------------------------------
  +   private void writeObject(java.io.ObjectOutputStream out)
  +      throws IOException
  +   {
  +      if (!isLocal())
  +      {
  +                     ContainerRemote old = container;
  +         container = null;
  +           out.defaultWriteObject();
  +           container = old;
  +      } else
  +      {
  +           out.defaultWriteObject();
  +      }
  +   }
  +     
      private void readObject(java.io.ObjectInputStream in)
         throws IOException, ClassNotFoundException
      {
  @@ -58,9 +90,8 @@
         if (isLocal())
         {
            // VM-local optimization; still follows RMI-semantics though
  -         container = MethodInvocation.getLocal(name);
  +         container = getLocal(name);
         }
  -      
      }
      
      // Inner classes -------------------------------------------------
  
  
  
  1.7       +18 -17    
jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/HomeProxy.java
  
  Index: HomeProxy.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/HomeProxy.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HomeProxy.java    2000/06/04 23:19:01     1.6
  +++ HomeProxy.java    2000/06/16 13:10:25     1.7
  @@ -17,9 +17,9 @@
    *      
    *      @see <related>
    *      @author Rickard �berg ([EMAIL PROTECTED])
  - *      @version $Revision: 1.6 $
  + *      @version $Revision: 1.7 $
    */
  -public abstract class HomeProxy
  +public class HomeProxy
      extends GenericProxy
   {
      // Constants -----------------------------------------------------
  @@ -56,27 +56,28 @@
         // Isn't this a bug in the proxy call??
         if (args == null)
            args = new Object[0];
  -      System.out.println(); 
  -       System.out.println("In creating Home 
"+m.getDeclaringClass()+m.getName()+m.getParameterTypes().length);
  -        
  +                     
         if (m.equals(toStr))
         {
            return name+" home";
         }
         else
         {
  -         // Delegate to container
  -         // Optimize if calling another bean in same EJB-application
  -         if (optimize && isLocal())
  -         {
  -            return container.invokeHome(m, args, null, null);
  -         }
  -                
  -         Object result = container.invokeHome(new MarshalledObject(new 
MethodInvocation(m, args)), null, null);         
  -         if (result instanceof MarshalledObject)
  -            return ((MarshalledObject)result).get();
  -         else
  -            return result;
  +           
  +           // Delegate to container
  +           // Optimize if calling another bean in same EJB-application
  +           if (optimize && isLocal())
  +           {
  +              return container.invokeHome(m, args, 
  +                                                                                    
 tm != null ? tm.getTransaction() : null,
  +                                                                                    
 null);
  +           } else
  +           {
  +              RemoteMethodInvocation rmi = new RemoteMethodInvocation(null, m, 
args);
  +              if (tm != null)
  +                 rmi.setTransaction(tm.getTransaction());
  +              return container.invokeHome(new MarshalledObject(rmi));
  +           }
         }
      }
   
  
  
  
  1.4       +16 -1     
jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/SecureSocketFactory.java
  
  Index: SecureSocketFactory.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/SecureSocketFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SecureSocketFactory.java  2000/05/12 11:19:06     1.3
  +++ SecureSocketFactory.java  2000/06/16 13:10:25     1.4
  @@ -18,7 +18,7 @@
    *      
    *   @see <related>
    *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.3 $
  + *   @version $Revision: 1.4 $
    */
   public class SecureSocketFactory
      extends RMISocketFactory
  @@ -51,9 +51,15 @@
      
      public boolean equals(Object obj)
      {
  +             System.out.println(obj instanceof SecureSocketFactory);
         return obj instanceof SecureSocketFactory;
      }
       
  +   public int hashCode()
  +   {
  +      return getClass().getName().hashCode();
  +   }
  +     
      // Package protected ---------------------------------------------
       
      // Protected -----------------------------------------------------
  @@ -105,6 +111,15 @@
            throws IOException
         {
            super(host, port);
  +         System.out.println("Create socket to "+host+" "+port);
  +                     
  +                     try
  +                     {
  +                             throw new Exception();
  +                     } catch (Exception e)
  +                     {
  +                             e.printStackTrace();
  +                     }
            
            DataOutputStream out = new DataOutputStream(getOutputStream());
            out.writeUTF(System.getProperty("user.name"));
  
  
  
  1.7       +21 -20    
jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/StatefulSessionProxy.java
  
  Index: StatefulSessionProxy.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/StatefulSessionProxy.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StatefulSessionProxy.java 2000/06/04 23:19:01     1.6
  +++ StatefulSessionProxy.java 2000/06/16 13:10:25     1.7
  @@ -18,9 +18,9 @@
    *      
    *      @see <related>
    *      @author Rickard �berg ([EMAIL PROTECTED])
  - *      @version $Revision: 1.6 $
  + *      @version $Revision: 1.7 $
    */
  -public abstract class StatefulSessionProxy
  +public class StatefulSessionProxy
      extends GenericProxy
   {
      // Constants -----------------------------------------------------
  @@ -41,27 +41,28 @@
      // Public --------------------------------------------------------
   
      // InvocationHandler implementation ------------------------------
  -   public Object invoke(Object proxy, Method m, Object[] args)
  +   public final Object invoke(Object proxy, Method m, Object[] args)
         throws Throwable
      {
  -      // Normalize args to always be an array
  -      // Isn't this a bug in the proxy call??
  -      if (args == null)
  -         args = new Object[0];
  -
  -      // Optimize if calling another bean in same EJB-application
  -//      if (optimize &&
  -//          this.getClass().getClassLoader() == 
Thread.currentThread().getContextClassLoader())
  -//             return container.invoke(id, m, args, null, null);
  -                
  -                             
  -     System.out.println("In creating Home 
"+m.getDeclaringClass()+m.getName()+m.getParameterTypes().length);
  +        // Normalize args to always be an array
  +        // Isn't this a bug in the proxy call??
  +        if (args == null)
  +           args = new Object[0];
           
  -      Object result = container.invoke(new MarshalledObject(new 
MethodInvocation(id, m, args)), null, null);
  -      if (result instanceof MarshalledObject)
  -         return ((MarshalledObject)result).get();
  -      else
  -         return result;
  +        // Delegate to container
  +        // Optimize if calling another bean in same EJB-application
  +        if (optimize && isLocal())
  +        {
  +           return container.invoke(id, m, args, 
  +                                                                     tm != null ? 
tm.getTransaction() : null,
  +                                                                     null);
  +        } else
  +        {
  +           RemoteMethodInvocation rmi = new RemoteMethodInvocation(id, m, args);
  +           if (tm != null)
  +              rmi.setTransaction(tm.getTransaction());
  +           return ((MarshalledObject)container.invoke(new 
MarshalledObject(rmi))).get();
  +        }
      }
   
      // Package protected ---------------------------------------------
  
  
  
  1.6       +17 -14    
jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/StatelessSessionProxy.java
  
  Index: StatelessSessionProxy.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/StatelessSessionProxy.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StatelessSessionProxy.java        2000/05/12 11:43:25     1.5
  +++ StatelessSessionProxy.java        2000/06/16 13:10:25     1.6
  @@ -20,9 +20,9 @@
    *      
    *      @see <related>
    *      @author Rickard �berg ([EMAIL PROTECTED])
  - *      @version $Revision: 1.5 $
  + *      @version $Revision: 1.6 $
    */
  -public abstract class StatelessSessionProxy
  +public class StatelessSessionProxy
      extends GenericProxy
   {
      // Constants -----------------------------------------------------
  @@ -32,7 +32,7 @@
      // Static --------------------------------------------------------
      static Method getHandle;
      static Method toStr;
  -   
  +     
      static
      {
         try
  @@ -54,14 +54,14 @@
      // Public --------------------------------------------------------
   
      // InvocationHandler implementation ------------------------------
  -   public Object invoke(Object proxy, Method m, Object[] args)
  +   public final Object invoke(Object proxy, Method m, Object[] args)
         throws Throwable
      {
         // Normalize args to always be an array
         // Isn't this a bug in the proxy call??
         if (args == null)
            args = new Object[0];
  -      
  +                     
         if (m.equals(getHandle))
         {
            return new StatelessHandleImpl(name);
  @@ -75,14 +75,17 @@
            // Optimize if calling another bean in same EJB-application
            if (optimize && isLocal())
            {
  -            return container.invoke(null, m, args, null, null);
  +            return container.invoke(null, m, args, 
  +                                                                     tm != null ? 
tm.getTransaction() : null,
  +                                                                     null);
  +         } else
  +         {
  +              RemoteMethodInvocation rmi = new RemoteMethodInvocation(null, m, 
args);
  +              if (tm != null)
  +                 rmi.setTransaction(tm.getTransaction());
  +                                     
  +              return container.invoke(new MarshalledObject(rmi));
            }
  -                
  -         Object result = container.invoke(new MarshalledObject(new 
MethodInvocation(m, args)), null, null);
  -         if (result instanceof MarshalledObject)
  -            return ((MarshalledObject)result).get();
  -         else
  -            return result;
         }
      }
   
  @@ -91,6 +94,6 @@
      // Protected -----------------------------------------------------
       
      // Private -------------------------------------------------------
  -     
  -   // Inner classes -------------------------------------------------
  +       
  +     // Inner classes -------------------------------------------------
   }
  
  
  
  1.1                  
jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/RemoteMethodInvocation.java
  
  Index: RemoteMethodInvocation.java
  ===================================================================
  /*
   * jBoss, the OpenSource EJB server
   *
   * Distributable under GPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.ejb.plugins.jrmp.interfaces;
  
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.io.IOException;
  import java.lang.reflect.Method;
  import java.util.Map;
  
  import java.security.Principal;
  
  import javax.transaction.Transaction;
  
  /**
   *    MethodInvocation
   *
   *  This Serializable object carries the method to invoke and an identifier for the 
target ojbect
   *
   *    @see <related>
   *    @author Rickard �berg ([EMAIL PROTECTED])
   *  @author <a href="mailto:[EMAIL PROTECTED]">Richard 
Monson-Haefel</a>.
   *  @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>.
   *    @version $Revision: 1.1 $
   */
  public final class RemoteMethodInvocation
     implements java.io.Serializable
  {
     // Constants -----------------------------------------------------
  
     // Attributes ----------------------------------------------------
     Object id;
     String className;
     int hash;
        
     Object[] args;
        
        Transaction tx;
        Principal identity;
        
        Map methodMap;
  
     // Static --------------------------------------------------------
  
     /*
     * The use of hashCode is not enough to differenciate methods
     * we override the hashCode
     *
     * This is taken from the RMH code in EJBoss 0.9
     *
     */
     public static int calculateHash(Method method) {
  
        int hash =
                // We use the declaring class
                method.getDeclaringClass().getName().hashCode() ^ //name of class
              // We use the name of the method
                method.getName().hashCode(); //name of method
  
        Class[] clazz = method.getParameterTypes();
  
        for (int i = 0; i < clazz.length; i++) {
  
                 // XOR
                 // We use the constant because
                 // a^b^b = a (thank you norbert)
                 // so that methodA() hashes to methodA(String, String)
  
                 hash = (hash +20000) ^ clazz[i].getName().hashCode();
        }
  
        return hash;
     }
        
     // Constructors --------------------------------------------------
     public RemoteMethodInvocation(Method m, Object[] args)
     {
        this(null, m, args);
     }
  
     public RemoteMethodInvocation(Object id, Method m, Object[] args)
     {
        this.id = id;
        this.args = args;
                this.hash = calculateHash(m);
           this.className = m.getDeclaringClass().getName();
     }
        
     // Public --------------------------------------------------------
  
  
     public Object getId() { return id; }
  
     public Method getMethod()
     {
                return (Method)methodMap.get(new Integer(hash));
     }
  
     public Object[] getArguments()
     {
        return args;
     }
        
        public void setMethodMap(Map methods)
        {
                methodMap = methods;
        }
        
        public void setTransaction(Transaction tx)
        {
                this.tx = tx;
        }
        
        public Transaction getTransaction()
        {
                return tx;
        }
  
        public void setPrincipal(Principal identity)
        {
                this.identity = identity;
        }
  
        public Principal getPrincipal()
        {
                return identity;
        }
         
     // Package protected ---------------------------------------------
  
     // Protected -----------------------------------------------------
  
     // Private -------------------------------------------------------
        
        // Inner classes -------------------------------------------------
  }
  
  
  
  

Reply via email to