geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject cvs commit: incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting MarshalingInterceptorsTest.java RemotingInterceptorsTest.java
Date Thu, 28 Aug 2003 05:12:11 GMT
chirino     2003/08/27 22:12:11

  Modified:    modules/core/src/java/org/apache/geronimo/common
                        Invocation.java InvocationType.java
                        SimpleInvocation.java
               modules/core/src/java/org/apache/geronimo/ejb
                        EJBInvocationUtil.java Entrancy.java
               modules/core/src/java/org/apache/geronimo/ejb/container
                        EJBContainerUtil.java
               modules/core/src/java/org/apache/geronimo/proxy
                        ProxyInvocation.java
               modules/core/src/java/org/apache/geronimo/remoting
                        IntraVMRoutingInterceptor.java
                        InvocationSupport.java MarshalingInterceptor.java
               modules/core/src/java/org/apache/geronimo/remoting/transport
                        TransportLoader.java TransportLoaderMBean.java
               modules/core/src/test/org/apache/geronimo/common
                        SimpleInvocationTest.java
               modules/core/src/test/org/apache/geronimo/remoting
                        MarshalingInterceptorsTest.java
                        RemotingInterceptorsTest.java
  Added:       modules/core/src/java/org/apache/geronimo/common
                        InvocationKey.java StringInvocationKey.java
  Log:
  While doing some profilng today we found out that doing new HashMap() is expensive relative
to doing a simple proxy invocation.  Stopped doing 3 new HashMap() in SimpleInvoation by unifying
all the maps into a single map and then we lazy create the map as needed.  All keys to the
Invocaiton map now have to implement the InvoationKey interface which lets the marshalling
layer know if the key and data should be marshalled or not.
  
  Revision  Changes    Path
  1.3       +5 -11     incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/Invocation.java
  
  Index: Invocation.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/Invocation.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Invocation.java	11 Aug 2003 17:59:10 -0000	1.2
  +++ Invocation.java	28 Aug 2003 05:12:10 -0000	1.3
  @@ -55,6 +55,7 @@
    */
   package org.apache.geronimo.common;
   
  +
   /**
    *
    *
  @@ -62,15 +63,8 @@
    * @version $Revision$ $Date$
    */
   public interface Invocation {
  -    Object getMarshal(Object key);
  -
  -    void putMarshal(Object key, Object value);
  -
  -    Object getAsIs(Object key);
  -
  -    void putAsIs(Object key, Object value);
  -
  -    Object getTransient(Object key);
   
  -    void putTransient(Object key, Object value);
  +    Object get(InvocationKey key);
  +    void put(InvocationKey key, Object value);
  +    
   }
  
  
  
  1.5       +14 -5     incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/InvocationType.java
  
  Index: InvocationType.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/InvocationType.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- InvocationType.java	24 Aug 2003 06:07:35 -0000	1.4
  +++ InvocationType.java	28 Aug 2003 05:12:10 -0000	1.5
  @@ -64,8 +64,8 @@
    *
    * @version $Revision$ $Date$
    */
  -public final class InvocationType implements Serializable {
  -    private static final String INVOCATION_TYPE_KEY = "INVOCATION_TYPE_KEY";
  +public final class InvocationType implements Serializable, InvocationKey {
  +    private static final StringInvocationKey INVOCATION_TYPE_KEY = new StringInvocationKey("INVOCATION_TYPE_KEY",
false);
   
       // Be careful here.  If you change the ordinals, this class must be changed on evey
client.
       private static int MAX_ORDINAL = 3;
  @@ -76,11 +76,11 @@
       public static final InvocationType LOCALHOME = new InvocationType("LOCALHOME", 3, false,
false);
   
       public static InvocationType getType(Invocation invocation) {
  -        return (InvocationType) invocation.getMarshal(INVOCATION_TYPE_KEY);
  +        return (InvocationType) invocation.get(INVOCATION_TYPE_KEY);
       }
   
       public static void putType(Invocation invocation, InvocationType type) {
  -        invocation.putMarshal(INVOCATION_TYPE_KEY, type);
  +        invocation.put(INVOCATION_TYPE_KEY, type);
       }
   
       private final transient String name;
  @@ -97,6 +97,14 @@
           this.ordinal = ordinal;
           values[ordinal] = this;
       }
  +    
  +    /**
  +     * @see org.apache.geronimo.common.InvocationKey#isTransient()
  +     */
  +    public boolean isTransient() {
  +        return false;
  +    }
  +    
   
       public boolean isRemoteInvocation() {
           return !local;
  @@ -121,4 +129,5 @@
       Object readResolve() throws ObjectStreamException {
           return values[ordinal];
       }
  +
   }
  
  
  
  1.5       +38 -30    incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/SimpleInvocation.java
  
  Index: SimpleInvocation.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/SimpleInvocation.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimpleInvocation.java	22 Aug 2003 02:08:41 -0000	1.4
  +++ SimpleInvocation.java	28 Aug 2003 05:12:10 -0000	1.5
  @@ -60,6 +60,7 @@
   import java.io.ObjectInput;
   import java.io.ObjectOutput;
   import java.util.HashMap;
  +import java.util.Iterator;
   import java.util.Map;
   
   /**
  @@ -70,48 +71,55 @@
    */
   public class SimpleInvocation implements Invocation, Externalizable {
       
  -    private Map marshalMap = new HashMap();
  -    private Map asIsMap = new HashMap();
  -    private Map transientMap = new HashMap();
  +    private Map data;
   
  -    public Object getMarshal(Object key) {
  -        return marshalMap.get(key);
  +    public Object get(InvocationKey key) {
  +        if(data==null)
  +            return null;
  +        return data.get(key);
       }
   
  -    public void putMarshal(Object key, Object value) {
  -        marshalMap.put(key, value);
  -    }
  -
  -    public Object getAsIs(Object key) {
  -        return asIsMap.get(key);
  -    }
  -
  -    public void putAsIs(Object key, Object value) {
  -        asIsMap.put(key, value);
  -    }
  -
  -    public Object getTransient(Object key) {
  -        return transientMap.get(key);
  -    }
  -
  -    public void putTransient(Object key, Object value) {
  -        transientMap.put(key, value);
  +    public void put(InvocationKey key, Object value) {
  +        if(data==null)
  +            data = new HashMap();
  +        data.put(key, value);
       }
   
       /* (non-Javadoc)
        * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
        */
       public void writeExternal(ObjectOutput out) throws IOException {
  -        out.writeObject(marshalMap);
  -        out.writeObject(asIsMap);        
  +        if( data !=null ) {
  +            Iterator iterator = data.keySet().iterator();
  +            while(iterator.hasNext()) {
  +                InvocationKey key = (InvocationKey) iterator.next();
  +                if( key.isTransient() )
  +                    continue; // don't serialize this item.
  +                Object value = data.get(key);
  +                out.writeObject(key);
  +                out.writeObject(value);
  +            }        
  +        }
  +        // write end of list terminator.
  +        out.writeObject(null);
       }
   
  -    /* (non-Javadoc)
  +    /**
        * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
        */
       public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
  -        marshalMap = (Map) in.readObject();
  -        asIsMap = (Map) in.readObject();
  -        transientMap = new HashMap();        
  +        
  +        if( data!=null )
  +            data.clear();
  +            
  +        InvocationKey key = (InvocationKey) in.readObject();
  +        while( key!=null ) {
  +            Object value = in.readObject();
  +            put(key,value);
  +            key = (InvocationKey) in.readObject();
  +        }
  +        
       }
  +
  +
   }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/InvocationKey.java
  
  Index: InvocationKey.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.common;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/08/28 05:12:10 $
   */
  public interface InvocationKey {
      
      /**
       * 
       * @return
       */
      boolean isTransient();
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/common/StringInvocationKey.java
  
  Index: StringInvocationKey.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.common;
  
  import java.io.Externalizable;
  import java.io.IOException;
  import java.io.ObjectInput;
  import java.io.ObjectOutput;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/08/28 05:12:10 $
   */
  public class StringInvocationKey implements InvocationKey, Externalizable {
      
      private String key;
      private boolean isTransient;
      private int hashCode;   
      
      public StringInvocationKey(String key, boolean isTransient) {
          this.key = key;
          this.hashCode = key.hashCode();
          this.isTransient = isTransient;
      }
       
      /**
       * @return
       */
      public boolean isTransient() {
          return isTransient;
      }
  
      /**
       * @see java.lang.Object#hashCode()
       */
      public int hashCode() {
          return hashCode;
      }
      
      /**
       * @see java.lang.Object#equals(java.lang.Object)
       */
      public boolean equals(Object obj) {
          if( obj == null )
              return false;
          if( !StringInvocationKey.class.equals(obj.getClass()) )
              return false;
          return key.equals( ((StringInvocationKey)obj).key );
      }
  
      /**
       * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
       */
      public void writeExternal(ObjectOutput out) throws IOException {
          out.writeUTF(key);
      }
  
      /**
       * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
       */
      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
          key = in.readUTF();
          hashCode = key.hashCode();
          isTransient = false;
      }
      
      /**
       * @see java.lang.Object#toString()
       */
      public String toString() {
          return key;
      }
  }
  
  
  
  1.6       +32 -21    incubator-geronimo/modules/core/src/java/org/apache/geronimo/ejb/EJBInvocationUtil.java
  
  Index: EJBInvocationUtil.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/ejb/EJBInvocationUtil.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EJBInvocationUtil.java	24 Aug 2003 06:07:36 -0000	1.5
  +++ EJBInvocationUtil.java	28 Aug 2003 05:12:10 -0000	1.6
  @@ -61,6 +61,7 @@
   import java.security.Principal;
   
   import org.apache.geronimo.common.Invocation;
  +import org.apache.geronimo.common.InvocationKey;
   
   /**
    *
  @@ -68,74 +69,77 @@
    *
    * @version $Revision$ $Date$
    */
  -public final class EJBInvocationUtil implements Serializable {
  +public final class EJBInvocationUtil implements Serializable, InvocationKey {
  +    
       // Be careful here.  If you change the ordinals, this class must be changed on evey
client.
       private static int MAX_ORDINAL = 5;
       private static final EJBInvocationUtil[] values = new EJBInvocationUtil[MAX_ORDINAL
+ 1];
  -    private static final EJBInvocationUtil METHOD = new EJBInvocationUtil("METHOD", 0);
  -    private static final EJBInvocationUtil ID = new EJBInvocationUtil("ID", 1);
  -    private static final EJBInvocationUtil ARGUMENTS = new EJBInvocationUtil("ARGUMENTS",
2);
  -    private static final EJBInvocationUtil EJB_CONTEXT_KEY = new EJBInvocationUtil("EJB_CONTEXT_KEY",
3);
  -    private static final EJBInvocationUtil PRINCIPAL = new EJBInvocationUtil("PRINCIPAL",
4);
  -    private static final EJBInvocationUtil CREDENTIALS = new EJBInvocationUtil("CREDENTIALS",
5);
  +    private static final EJBInvocationUtil METHOD = new EJBInvocationUtil("METHOD", 0,
false);
  +    private static final EJBInvocationUtil ID = new EJBInvocationUtil("ID", 1, false);
  +    private static final EJBInvocationUtil ARGUMENTS = new EJBInvocationUtil("ARGUMENTS",
2, false);
  +    private static final EJBInvocationUtil EJB_CONTEXT_KEY = new EJBInvocationUtil("EJB_CONTEXT_KEY",
3, true);
  +    private static final EJBInvocationUtil PRINCIPAL = new EJBInvocationUtil("PRINCIPAL",
4, false);
  +    private static final EJBInvocationUtil CREDENTIALS = new EJBInvocationUtil("CREDENTIALS",
5, false);
   
       public static Method getMethod(Invocation invocation) {
  -        return (Method) invocation.getAsIs(METHOD);
  +        return (Method) invocation.get(METHOD);
       }
   
       public static void putMethod(Invocation invocation, Method method) {
  -        invocation.putAsIs(METHOD, method);
  +        invocation.put(METHOD, method);
       }
   
       public static Object getId(Invocation invocation) {
  -        return invocation.getMarshal(ID);
  +        return invocation.get(ID);
       }
   
       public static void putId(Invocation invocation, Object id) {
  -        invocation.putMarshal(ID, id);
  +        invocation.put(ID, id);
       }
   
       public static Object[] getArguments(Invocation invocation) {
  -        return (Object[]) invocation.getMarshal(ARGUMENTS);
  +        return (Object[]) invocation.get(ARGUMENTS);
       }
   
       public static void putArguments(Invocation invocation, Object[] arguments) {
  -        invocation.putMarshal(ARGUMENTS, arguments);
  +        invocation.put(ARGUMENTS, arguments);
       }
   
       public static EnterpriseContext getEnterpriseContext(Invocation invocation) {
  -        return (EnterpriseContext) invocation.getTransient(EJB_CONTEXT_KEY);
  +        return (EnterpriseContext) invocation.get(EJB_CONTEXT_KEY);
       }
   
       public static void putEnterpriseContext(Invocation invocation, EnterpriseContext enterpriseContext)
{
  -        invocation.putTransient(EJB_CONTEXT_KEY, enterpriseContext);
  +        invocation.put(EJB_CONTEXT_KEY, enterpriseContext);
       }
   
       public static Principal getPrincipal(Invocation invocation) {
  -        return (Principal) invocation.getAsIs(PRINCIPAL);
  +        return (Principal) invocation.get(PRINCIPAL);
       }
   
       public static void putPrincipal(Invocation invocation, Principal principal) {
  -        invocation.putAsIs(PRINCIPAL, principal);
  +        invocation.put(PRINCIPAL, principal);
       }
   
       public static Object getCredentials(Invocation invocation) {
  -        return invocation.getMarshal(CREDENTIALS);
  +        return invocation.get(CREDENTIALS);
       }
   
       public static void putCredentials(Invocation invocation, Object credentials) {
  -        invocation.putMarshal(CREDENTIALS, credentials);
  +        invocation.put(CREDENTIALS, credentials);
       }
   
       private final transient String name;
       private final int ordinal;
  +    private final transient boolean isTransient;
   
  -    private EJBInvocationUtil(String name, int ordinal) {
  +    private EJBInvocationUtil(String name, int ordinal, boolean isTransient) {
           assert ordinal < MAX_ORDINAL;
           assert values[ordinal] == null;
           this.name = name;
           this.ordinal = ordinal;
           values[ordinal] = this;
  +        this.isTransient = isTransient;
       }
   
       public String toString() {
  @@ -144,5 +148,12 @@
   
       Object readResolve() throws ObjectStreamException {
           return values[ordinal];
  +    }
  +
  +    /**
  +     * @see org.apache.geronimo.common.InvocationKey#isTransient()
  +     */
  +    public boolean isTransient() {
  +        return isTransient;
       }
   }
  
  
  
  1.4       +5 -4      incubator-geronimo/modules/core/src/java/org/apache/geronimo/ejb/Entrancy.java
  
  Index: Entrancy.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/ejb/Entrancy.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Entrancy.java	11 Aug 2003 17:59:11 -0000	1.3
  +++ Entrancy.java	28 Aug 2003 05:12:10 -0000	1.4
  @@ -64,6 +64,7 @@
   
   import org.apache.geronimo.common.Invocation;
   import org.apache.geronimo.common.InvocationType;
  +import org.apache.geronimo.common.StringInvocationKey;
   
   /**
    *
  @@ -72,7 +73,7 @@
    * @version $Revision$ $Date$
    */
   public final class Entrancy implements Serializable {
  -    private static final String ENTRANCY_KEY = "ENTRANCY_KEY";
  +    private static final StringInvocationKey ENTRANCY_KEY = new StringInvocationKey("ENTRANCY_KEY",
false);
   
       public static final Entrancy ENTRANT = new Entrancy("ENTRANT", true);
       public static final Entrancy NON_ENTRANT = new Entrancy("NON_ENTRANT", false);
  @@ -111,11 +112,11 @@
       }
   
       public static Entrancy getEntrancy(Invocation invocation) {
  -        return (Entrancy) invocation.getTransient(ENTRANCY_KEY);
  +        return (Entrancy) invocation.get(ENTRANCY_KEY);
       }
   
       public static void putEntrancy(Invocation invocation, Entrancy type) {
  -        invocation.putTransient(ENTRANCY_KEY, type);
  +        invocation.put(ENTRANCY_KEY, type);
       }
   
       private final transient String name;
  
  
  
  1.5       +20 -12    incubator-geronimo/modules/core/src/java/org/apache/geronimo/ejb/container/EJBContainerUtil.java
  
  Index: EJBContainerUtil.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/ejb/container/EJBContainerUtil.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EJBContainerUtil.java	24 Aug 2003 06:07:36 -0000	1.4
  +++ EJBContainerUtil.java	28 Aug 2003 05:12:10 -0000	1.5
  @@ -61,6 +61,7 @@
   import java.security.Principal;
   
   import org.apache.geronimo.common.Invocation;
  +import org.apache.geronimo.common.InvocationKey;
   
   /**
    *
  @@ -68,7 +69,7 @@
    *
    * @version $Revision$ $Date$
    */
  -public final class EJBContainerUtil implements Serializable {
  +public final class EJBContainerUtil implements Serializable, InvocationKey {
       // Be careful here.  If you change the ordinals, this class must be changed on evey
client.
       private static int MAX_ORDINAL = 4;
       private static final EJBContainerUtil[] values = new EJBContainerUtil[MAX_ORDINAL +
1];
  @@ -79,43 +80,43 @@
       private static final EJBContainerUtil CREDENTIALS = new EJBContainerUtil("CREDENTIALS",
4);
   
       public static Method getMethod(Invocation invocation) {
  -        return (Method) invocation.getAsIs(METHOD);
  +        return (Method) invocation.get(METHOD);
       }
   
       public static void putMethod(Invocation invocation, Method method) {
  -        invocation.putAsIs(METHOD, method);
  +        invocation.put(METHOD, method);
       }
   
       public static Object getId(Invocation invocation) {
  -        return invocation.getMarshal(ID);
  +        return invocation.get(ID);
       }
   
       public static void putId(Invocation invocation, Object id) {
  -        invocation.putMarshal(ID, id);
  +        invocation.put(ID, id);
       }
   
       public static Object[] getArguments(Invocation invocation) {
  -        return (Object[]) invocation.getMarshal(ARGUMENTS);
  +        return (Object[]) invocation.get(ARGUMENTS);
       }
   
       public static void putArguments(Invocation invocation, Object[] arguments) {
  -        invocation.putMarshal(ARGUMENTS, arguments);
  +        invocation.put(ARGUMENTS, arguments);
       }
   
       public static Principal getPrincipal(Invocation invocation) {
  -        return (Principal) invocation.getAsIs(PRINCIPAL);
  +        return (Principal) invocation.get(PRINCIPAL);
       }
   
       public static void putPrincipal(Invocation invocation, Principal principal) {
  -        invocation.putAsIs(PRINCIPAL, principal);
  +        invocation.put(PRINCIPAL, principal);
       }
   
       public static Object getCredentials(Invocation invocation) {
  -        return invocation.getMarshal(CREDENTIALS);
  +        return invocation.get(CREDENTIALS);
       }
   
       public static void putCredentials(Invocation invocation, Object credentials) {
  -        invocation.putMarshal(CREDENTIALS, credentials);
  +        invocation.put(CREDENTIALS, credentials);
       }
   
       private final transient String name;
  @@ -135,5 +136,12 @@
   
       Object readResolve() throws ObjectStreamException {
           return values[ordinal];
  +    }
  +
  +    /**
  +     * @see org.apache.geronimo.common.InvocationKey#isTransient()
  +     */
  +    public boolean isTransient() {
  +        return false;
       }
   }
  
  
  
  1.2       +2 -2      incubator-geronimo/modules/core/src/java/org/apache/geronimo/proxy/ProxyInvocation.java
  
  Index: ProxyInvocation.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/proxy/ProxyInvocation.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProxyInvocation.java	22 Aug 2003 02:23:25 -0000	1.1
  +++ ProxyInvocation.java	28 Aug 2003 05:12:10 -0000	1.2
  @@ -67,7 +67,7 @@
   /**
    * @version $Revision$ $Date$
    */
  -public class ProxyInvocation extends SimpleInvocation {
  +final public class ProxyInvocation extends SimpleInvocation {
   
       Method method;
       Object args[];
  
  
  
  1.3       +2 -4      incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/IntraVMRoutingInterceptor.java
  
  Index: IntraVMRoutingInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/IntraVMRoutingInterceptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IntraVMRoutingInterceptor.java	26 Aug 2003 22:11:24 -0000	1.2
  +++ IntraVMRoutingInterceptor.java	28 Aug 2003 05:12:10 -0000	1.3
  @@ -77,8 +77,6 @@
        * @see org.apache.geronimo.common.AbstractInterceptor#invoke(org.apache.geronimo.common.Invocation)
        */
       public InvocationResult invoke(Invocation invocation) throws Throwable {
  -        if (next == null)
  -            resolveNext();
           return next.invoke(invocation);
       }
   
  @@ -124,7 +122,7 @@
        */
       public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
           deMarshalingInterceptorID = new Long(in.readLong());
  -
  +        resolveNext();
       }
   
       /**
  
  
  
  1.4       +17 -8     incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/InvocationSupport.java
  
  Index: InvocationSupport.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/InvocationSupport.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InvocationSupport.java	24 Aug 2003 06:07:36 -0000	1.3
  +++ InvocationSupport.java	28 Aug 2003 05:12:10 -0000	1.4
  @@ -58,10 +58,11 @@
   import java.io.Serializable;
   import java.net.URI;
   import org.apache.geronimo.common.Invocation;
  +import org.apache.geronimo.common.InvocationKey;
   /**
    * @version $Revision$ $Date$
    */
  -public final class InvocationSupport implements Serializable {
  +public final class InvocationSupport implements Serializable, InvocationKey {
   
       // Be careful here.  If you change the ordinals, this class must be changed on evey
client.
       private static int MAX_ORDINAL = 3;
  @@ -71,23 +72,24 @@
       private static final InvocationSupport INVOCATION_TYPE = new InvocationSupport("INVOCATION_TYPE",
2);
   
       public static MarshalledObject getMarshaledValue(Invocation invocation) {
  -        return (MarshalledObject) invocation.getTransient(MARSAHLLED_VALUE);
  +        return (MarshalledObject) invocation.get(MARSAHLLED_VALUE);
       }
       public static void putMarshaledValue(Invocation invocation, MarshalledObject mo) {
  -        invocation.putTransient(MARSAHLLED_VALUE, mo);
  +        invocation.put(MARSAHLLED_VALUE, mo);
       }
       public static URI getRemoteURI(Invocation invocation) {
  -        return (URI) invocation.getTransient(REMOTE_URI);
  +        return (URI) invocation.get(REMOTE_URI);
       }
       public static void putRemoteURI(Invocation invocation, URI remoteURI) {
  -        invocation.putTransient(REMOTE_URI, remoteURI);
  +        invocation.put(REMOTE_URI, remoteURI);
       }
       public static InvocationType getInvocationType(Invocation invocation) {
  -        return (InvocationType) invocation.getTransient(INVOCATION_TYPE);
  +        return (InvocationType) invocation.get(INVOCATION_TYPE);
       }
       public static void putInvocationType(Invocation invocation, InvocationType type) {
  -        invocation.putTransient(INVOCATION_TYPE, type);
  +        invocation.put(INVOCATION_TYPE, type);
       }
  +    
       private final transient String name;
       private final int ordinal;
   
  @@ -121,6 +123,13 @@
               child = child.getParent();
           }
           return false;
  +    }
  +    
  +    /**
  +     * @see org.apache.geronimo.common.InvocationKey#isTransient()
  +     */
  +    public boolean isTransient() {
  +        return true;
       }
   
   }
  
  
  
  1.4       +1 -2      incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/MarshalingInterceptor.java
  
  Index: MarshalingInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/MarshalingInterceptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MarshalingInterceptor.java	27 Aug 2003 04:50:39 -0000	1.3
  +++ MarshalingInterceptor.java	28 Aug 2003 05:12:10 -0000	1.4
  @@ -72,7 +72,6 @@
        * @see org.apache.geronimo.common.AbstractInterceptor#invoke(org.apache.geronimo.common.Invocation)
        */
       public InvocationResult invoke(Invocation invocation) throws Throwable {
  -
           // Marshall the invocation and store it.
           MarshalledObject mo = next.createMarshalledObject();
           mo.set(invocation);
  
  
  
  1.2       +4 -4      incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportLoader.java
  
  Index: TransportLoader.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TransportLoader.java	22 Aug 2003 02:23:26 -0000	1.1
  +++ TransportLoader.java	28 Aug 2003 05:12:10 -0000	1.2
  @@ -57,16 +57,16 @@
   
   import java.net.URI;
   
  -import org.apache.geronimo.common.AbstractComponent;
  +import org.apache.geronimo.management.AbstractManagedObject;
   
   /**
    * @version $Revision$ $Date$
    */
  -public class TransportLoader extends AbstractComponent implements TransportLoaderMBean
{
  +public class TransportLoader extends AbstractManagedObject implements TransportLoaderMBean
{
   
       URI bindURI;
       TransportServer server;
  -    Router dispatchingRouter;
  +    Router dispatchingRouter = new FragmentBasedInterceptorRouter();
   
       /**
        * @see org.apache.geronimo.common.AbstractComponent#doStart()
  
  
  
  1.2       +5 -2      incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportLoaderMBean.java
  
  Index: TransportLoaderMBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportLoaderMBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TransportLoaderMBean.java	22 Aug 2003 02:23:26 -0000	1.1
  +++ TransportLoaderMBean.java	28 Aug 2003 05:12:10 -0000	1.2
  @@ -57,10 +57,13 @@
   
   import java.net.URI;
   
  +import org.apache.geronimo.management.ManagedObject;
  +import org.apache.geronimo.management.StateManageable;
  +
   /**
    * @version $Revision$ $Date$
    */
  -public interface TransportLoaderMBean {
  +public interface TransportLoaderMBean extends ManagedObject, StateManageable {
       /**
        * @return
        */
  
  
  
  1.2       +6 -32     incubator-geronimo/modules/core/src/test/org/apache/geronimo/common/SimpleInvocationTest.java
  
  Index: SimpleInvocationTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/common/SimpleInvocationTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleInvocationTest.java	12 Aug 2003 09:14:43 -0000	1.1
  +++ SimpleInvocationTest.java	28 Aug 2003 05:12:10 -0000	1.2
  @@ -65,7 +65,7 @@
       extends TestCase
   {
       private Invocation invocation;
  -    private Object     key;
  +    private StringInvocationKey  key;
       private Object     value;
   
       public SimpleInvocationTest( String name ) 
  @@ -77,7 +77,7 @@
           throws Exception
       {
           invocation = new SimpleInvocation();
  -        key        = new Object();
  +        key        = new StringInvocationKey("Test", false);
           value      = new Object();
       }
   
  @@ -87,37 +87,11 @@
        *
        * @throws Exception
        */
  -    public void testGetPutMarshal()
  +    public void testGetPut()
           throws Exception
       {
  -        invocation.putMarshal( key, value );
  -        assertEquals( "Objects should match", value, invocation.getMarshal( key ) );
  -    }
  -
  -    /**
  -     * Test case for {@link SimpleInvocation#getAsIs()}
  -     * and {@link SimpleInvocation#putAsIs( Object, Object )}
  -     *
  -     * @throws Exception
  -     */
  -    public void testGetPutAsIs()
  -        throws Exception
  -    {
  -        invocation.putAsIs( key, value );
  -        assertEquals( "Objects should match", value, invocation.getAsIs( key ) );
  -    }
  -
  -    /**
  -     * Test case for {@link SimpleInvocation#getTransient()}
  -     * and {@link SimpleInvocation#putTransient( Object, Object )}
  -     *
  -     * @throws Exception
  -     */
  -    public void testGetPutTransient()
  -        throws Exception
  -    {
  -        invocation.putTransient( key, value );
  -        assertEquals( "Objects should match", value, invocation.getTransient( key ) );
  +        invocation.put( key, value );
  +        assertEquals( "Objects should match", value, invocation.get( key ) );
       }
   
       protected void tearDown()
  
  
  
  1.3       +20 -17    incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/MarshalingInterceptorsTest.java
  
  Index: MarshalingInterceptorsTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/MarshalingInterceptorsTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MarshalingInterceptorsTest.java	25 Aug 2003 03:14:46 -0000	1.2
  +++ MarshalingInterceptorsTest.java	28 Aug 2003 05:12:10 -0000	1.3
  @@ -67,7 +67,6 @@
   
   import junit.framework.TestCase;
   
  -import org.apache.geronimo.common.Interceptor;
   import org.apache.geronimo.proxy.ProxyContainer;
   import org.apache.geronimo.proxy.ReflexiveInterceptor;
   import org.apache.geronimo.remoting.transport.BytesMarshalledObject;
  @@ -326,24 +325,28 @@
         * @param object1
         * @return
         */
  -    private Object createProxy(Object object1) throws Exception {
  +    private Object createProxy(Object target) throws Exception {
           
  +        // Setup the server side contianer..        
           ProxyContainer serverContainer = new ProxyContainer();        
  -
  -        DeMarshalingInterceptor dmi = new DeMarshalingInterceptor();
  -        dmi.setClassloader(object1.getClass().getClassLoader());
  -        Long dmiid = InterceptorRegistry.instance.register(dmi);
  -        serverContainer.addInterceptor(dmi);      
  -        Interceptor reflexive = new ReflexiveInterceptor(object1);
  -        serverContainer.addInterceptor(reflexive);
  -        severContainers.add(serverContainer);
  +        DeMarshalingInterceptor demarshaller = new DeMarshalingInterceptor();
  +        serverContainer.addInterceptor(demarshaller);      
  +        serverContainer.addInterceptor(new ReflexiveInterceptor(target));
           
  -        ProxyContainer clientContainer = new ProxyContainer();        
  -        IntraVMRoutingInterceptor ivmri = new IntraVMRoutingInterceptor();
  -        ivmri.setDeMarshalingInterceptorID(dmiid);
  -        clientContainer.addInterceptor(ivmri);
  -
  -        return clientContainer.createProxy(object1.getClass());
  +        // Configure the server side interceptors.
  +        demarshaller.setClassloader(target.getClass().getClassLoader());
  +        Long dmiid = InterceptorRegistry.instance.register(demarshaller);
  +        
  +        // Setup the client side container..        
  +        ProxyContainer clientContainer = new ProxyContainer();
  +        IntraVMRoutingInterceptor localRouter = new IntraVMRoutingInterceptor();
  +        clientContainer.addInterceptor(localRouter);
  +
  +        // Configure the client side interceptors.
  +        localRouter.setDeMarshalingInterceptorID(dmiid);
  +        localRouter.setNext(demarshaller.getNext());
  +        
  +        return clientContainer.createProxy(target.getClass());
       }
   
   }
  
  
  
  1.4       +2 -1      incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/RemotingInterceptorsTest.java
  
  Index: RemotingInterceptorsTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/RemotingInterceptorsTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RemotingInterceptorsTest.java	27 Aug 2003 04:50:39 -0000	1.3
  +++ RemotingInterceptorsTest.java	28 Aug 2003 05:12:10 -0000	1.4
  @@ -377,6 +377,7 @@
   
           // Configure the client side interceptors.
           localRouter.setDeMarshalingInterceptorID(dmiid);
  +        localRouter.setNext(demarshaller.getNext());
           remoteRouter.setLocalInterceptor(localRouter);
           RemoteTransportInterceptor transport = new RemoteTransportInterceptor();
           transport.setRemoteURI(URISupport.setFragment(connectURI, ""+dmiid));
  
  
  

Mime
View raw message