jlaskowski    2005/07/01 15:34:36

  Modified:    modules/core/src/java/org/openejb/proxy BaseEJB.java
                        EJBLocalObjectImpl.java EJBMetaDataImpl.java
                        EJBMethodInterceptor.java EJBObjectImpl.java
                        HandleImpl.java
  Added:       modules/core/src/java/org/openejb/proxy
                        SerializationHandler.java
  Removed:     modules/core/src/java/org/openejb/proxy
                        SerializationHanlder.java
  Log:

  Fixing a typo in the class name - org/openejb/proxy/SerializationHanlder
  
  Revision  Changes    Path
  1.6       +3 -3      
openejb/modules/core/src/java/org/openejb/proxy/BaseEJB.java
  
  Index: BaseEJB.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/proxy/BaseEJB.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BaseEJB.java      9 Feb 2005 02:07:55 -0000       1.5
  +++ BaseEJB.java      1 Jul 2005 19:34:36 -0000       1.6
  @@ -121,7 +121,7 @@
   
   
       protected Object writeReplace() throws ObjectStreamException {
  -        return SerializationHanlder.writeReplace(this, getProxyInfo());
  +        return SerializationHandler.writeReplace(this, getProxyInfo());
       }
   
   }
  
  
  
  1.4       +2 -2      
openejb/modules/core/src/java/org/openejb/proxy/EJBLocalObjectImpl.java
  
  Index: EJBLocalObjectImpl.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/proxy/EJBLocalObjectImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EJBLocalObjectImpl.java   21 Mar 2004 21:26:35 -0000      1.3
  +++ EJBLocalObjectImpl.java   1 Jul 2005 19:34:36 -0000       1.4
  @@ -63,6 +63,6 @@
       }

   

       public Object writeReplace() throws ObjectStreamException{

  -        return SerializationHanlder.writeReplace(this, getProxyInfo());

  +        return SerializationHandler.writeReplace(this, getProxyInfo());

       }

   }

  
  
  
  1.2       +2 -2      
openejb/modules/core/src/java/org/openejb/proxy/EJBMetaDataImpl.java
  
  Index: EJBMetaDataImpl.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/proxy/EJBMetaDataImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EJBMetaDataImpl.java      1 Mar 2004 07:14:43 -0000       1.1
  +++ EJBMetaDataImpl.java      1 Jul 2005 19:34:36 -0000       1.2
  @@ -104,6 +104,6 @@
       }
       
       protected Object writeReplace() throws ObjectStreamException{
  -        return SerializationHanlder.writeReplace(this, 
this.ejbHome.getProxyInfo());
  +        return SerializationHandler.writeReplace(this, 
this.ejbHome.getProxyInfo());
       }
   }
  
  
  
  1.13      +10 -10    
openejb/modules/core/src/java/org/openejb/proxy/EJBMethodInterceptor.java
  
  Index: EJBMethodInterceptor.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/proxy/EJBMethodInterceptor.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- EJBMethodInterceptor.java 15 Mar 2005 06:03:05 -0000      1.12
  +++ EJBMethodInterceptor.java 1 Jul 2005 19:34:36 -0000       1.13
  @@ -209,14 +209,14 @@
               try {
                   
Thread.currentThread().setContextClassLoader(targetClassLoader);
                   if (crossClassLoader) {
  -                    
SerializationHanlder.setStrategy(ReplacementStrategy.IN_VM_REPLACE);
  -                    SerializationHanlder.copyArgs(targetClassLoader, args);
  +                    
SerializationHandler.setStrategy(ReplacementStrategy.IN_VM_REPLACE);
  +                    SerializationHandler.copyArgs(targetClassLoader, args);
                   } else {
  -                    
SerializationHanlder.setStrategy(ReplacementStrategy.COPY);
  -                    SerializationHanlder.copyArgs(args);
  +                    
SerializationHandler.setStrategy(ReplacementStrategy.COPY);
  +                    SerializationHandler.copyArgs(args);
                   }
               } finally {
  -                SerializationHanlder.setStrategy(null);
  +                SerializationHandler.setStrategy(null);
                   Thread.currentThread().setContextClassLoader(oldCl);
               }
           }
  @@ -232,14 +232,14 @@
           try {
               Thread.currentThread().setContextClassLoader(sourceClassLoader);
               if (crossClassLoader) {
  -                
SerializationHanlder.setStrategy(ReplacementStrategy.IN_VM_REPLACE);
  -                return SerializationHanlder.copyObj(sourceClassLoader, 
returnObj);
  +                
SerializationHandler.setStrategy(ReplacementStrategy.IN_VM_REPLACE);
  +                return SerializationHandler.copyObj(sourceClassLoader, 
returnObj);
               } else {
  -                SerializationHanlder.setStrategy(ReplacementStrategy.COPY);
  -                return SerializationHanlder.copyObj(returnObj);
  +                SerializationHandler.setStrategy(ReplacementStrategy.COPY);
  +                return SerializationHandler.copyObj(returnObj);
               }
           } finally {
  -            SerializationHanlder.setStrategy(null);
  +            SerializationHandler.setStrategy(null);
               Thread.currentThread().setContextClassLoader(oldCl);
           }
       }
  
  
  
  1.5       +3 -3      
openejb/modules/core/src/java/org/openejb/proxy/EJBObjectImpl.java
  
  Index: EJBObjectImpl.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/proxy/EJBObjectImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EJBObjectImpl.java        13 Jan 2005 17:00:23 -0000      1.4
  +++ EJBObjectImpl.java        1 Jul 2005 19:34:36 -0000       1.5
  @@ -112,7 +112,7 @@
       }
   
       public Object writeReplace() throws ObjectStreamException {
  -        return SerializationHanlder.writeReplace(this, getProxyInfo());
  +        return SerializationHandler.writeReplace(this, getProxyInfo());
       }
   
   }
  
  
  
  1.2       +2 -2      
openejb/modules/core/src/java/org/openejb/proxy/HandleImpl.java
  
  Index: HandleImpl.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/proxy/HandleImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HandleImpl.java   1 Mar 2004 07:14:43 -0000       1.1
  +++ HandleImpl.java   1 Jul 2005 19:34:36 -0000       1.2
  @@ -78,7 +78,7 @@
           return ((BaseEJB) proxy).getProxyInfo().getPrimaryKey();
       }
       protected Object writeReplace() throws ObjectStreamException{
  -        return SerializationHanlder.writeReplace(this, 
((BaseEJB)proxy).getProxyInfo());
  +        return SerializationHandler.writeReplace(this, 
((BaseEJB)proxy).getProxyInfo());
       }
   
   }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/proxy/SerializationHandler.java
  
  Index: SerializationHandler.java
  ===================================================================
  /**

   * Redistribution and use of this software and associated documentation

   * ("Software"), with or without modification, are permitted provided

   * that the following conditions are met:

   *

   * 1. Redistributions of source code must retain copyright

   *    statements and notices.  Redistributions must also contain a

   *    copy of this document.

   *

   * 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 name "OpenEJB" must not be used to endorse or promote

   *    products derived from this Software without prior written

   *    permission of The OpenEJB Group.  For written permission,

   *    please contact [EMAIL PROTECTED]

   *

   * 4. Products derived from this Software may not be called "OpenEJB"

   *    nor may "OpenEJB" appear in their names without prior written

   *    permission of The OpenEJB Group. OpenEJB is a registered

   *    trademark of The OpenEJB Group.

   *

   * 5. Due credit should be given to the OpenEJB Project

   *    (http://openejb.org/).

   *

   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS

   * ``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 OPENEJB GROUP 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.

   *

   * Copyright 2001 (C) The OpenEJB Group. All Rights Reserved.

   *

   * $Id: SerializationHandler.java,v 1.1 2005/07/01 19:34:36 jlaskowski Exp $

   */

  package org.openejb.proxy;

  

  import java.io.IOException;

  import java.io.ObjectStreamException;

  import java.io.ByteArrayOutputStream;

  import java.io.ObjectOutputStream;

  import java.io.ByteArrayInputStream;

  import java.rmi.MarshalledObject;

  

  import javax.xml.rpc.Stub;

  

  import org.apache.geronimo.kernel.ObjectInputStreamExt;

  import org.omg.CORBA.ORB;

  

  

  public class SerializationHandler {

      private static InheritableThreadLocal serializationState = new 
InheritableThreadLocal();

  

      /**

       * This method is public so it can be called by other parts of the

       * container during their serialization operations, namely session

       * passivation

       */

      public static void setStrategy(ReplacementStrategy strategy) {

          serializationState.set(strategy);

      }

  

      private static ReplacementStrategy getStrategy() {

          ReplacementStrategy replacementStrategy = (ReplacementStrategy) 
serializationState.get();

          if (replacementStrategy == null) {

              return ReplacementStrategy.REPLACE;

          }

          return replacementStrategy;

      }

  

      public static void copyArgs(Object[] objects) throws IOException, 
ClassNotFoundException {

          for (int i = 0; i < objects.length; i++) {

              Object originalObject = objects[i];

              Object copy = copyObj(originalObject);

              // connect a coppied stub to the same orb as the original stub

              if (copy instanceof javax.rmi.CORBA.Stub) {

                  ORB orb = ((javax.rmi.CORBA.Stub)originalObject)._orb();

                  if (orb != null) {

                      ((javax.rmi.CORBA.Stub)copy).connect(orb);

                  }

              }

              objects[i] = copy;

          }

      }

  

      public static Object copyObj(Object object) throws IOException, 
ClassNotFoundException {

          MarshalledObject obj = new MarshalledObject(object);

          return obj.get();

      }

  

      public static Object writeReplace(Object object, ProxyInfo proxyInfo) 
throws ObjectStreamException {

          return getStrategy().writeReplace(object, proxyInfo);

      }

  

      public static void copyArgs(ClassLoader classLoader, Object[] objects) 
throws IOException, ClassNotFoundException {

          for (int i = 0; i < objects.length; i++) {

              objects[i] = copyObj(classLoader, objects[i]);

          }

      }

  

      public static Object copyObj(ClassLoader classLoader, Object object) 
throws IOException, ClassNotFoundException {

          ByteArrayOutputStream baos = new ByteArrayOutputStream();

          ObjectOutputStream oos = new ObjectOutputStream(baos);

          oos.writeObject(object);

          oos.flush();

          oos.close();

          ByteArrayInputStream bais = new 
ByteArrayInputStream(baos.toByteArray());

          ObjectInputStreamExt ois = new ObjectInputStreamExt(bais, 
classLoader);

          return ois.readObject();

      }

  }

  

  
  
  

Reply via email to