openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yingw...@apache.org
Subject svn commit: r993475 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: container/ decorator/ util/
Date Tue, 07 Sep 2010 18:58:01 GMT
Author: yingwang
Date: Tue Sep  7 18:58:01 2010
New Revision: 993475

URL: http://svn.apache.org/viewvc?rev=993475&view=rev
Log:
[owb-448] passivation support for decorator, interceptor and beanManager.

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/AbstractDecoratorMethodHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DelegateHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=993475&r1=993474&r2=993475&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
Tue Sep  7 18:58:01 2010
@@ -503,6 +503,10 @@ public class BeanManagerImpl implements 
     public BeanManager addDecorator(Decorator decorator)
     {
         getManager().webBeansDecorators.add(decorator);
+        if (decorator instanceof OwbBean)
+        {
+            this.addPassivationInfo((OwbBean)decorator);
+        }
         return this;
     }
 
@@ -510,6 +514,10 @@ public class BeanManagerImpl implements 
     public BeanManager addInterceptor(Interceptor interceptor)
     {
         getManager().webBeansInterceptors.add(interceptor);
+        if (interceptor instanceof OwbBean)
+        {
+            this.addPassivationInfo((OwbBean)interceptor);
+        }       
         return this;
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java?rev=993475&r1=993474&r2=993475&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java
Tue Sep  7 18:58:01 2010
@@ -19,6 +19,10 @@
 package org.apache.webbeans.container;
 
 import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.IOException;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.util.List;
@@ -49,7 +53,7 @@ import javax.enterprise.inject.spi.Obser
  * This class is Serializable and always resolves the current
  * instance of the central BeanManager automatically.
  */
-public class InjectableBeanManager implements BeanManager, Serializable 
+public class InjectableBeanManager implements BeanManager, Serializable, Externalizable 
 {
 
     private static final long serialVersionUID = 1L;
@@ -211,4 +215,16 @@ public class InjectableBeanManager imple
         return bm.wrapExpressionFactory(expressionFactory);
     }
 
+    @Override
+    public void writeExternal(ObjectOutput out) throws IOException 
+    {    
+    }
+
+    @Override
+    public void readExternal(ObjectInput in) throws IOException,
+            ClassNotFoundException 
+    {
+        this.bm = BeanManagerImpl.getManager();
+    }
+
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/AbstractDecoratorMethodHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/AbstractDecoratorMethodHandler.java?rev=993475&r1=993474&r2=993475&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/AbstractDecoratorMethodHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/AbstractDecoratorMethodHandler.java
Tue Sep  7 18:58:01 2010
@@ -18,13 +18,19 @@
  */
 package org.apache.webbeans.decorator;
 
+import java.io.Serializable;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.lang.reflect.Method;
 
 import javassist.util.proxy.MethodHandler;
 
-public class AbstractDecoratorMethodHandler implements MethodHandler
+public class AbstractDecoratorMethodHandler implements MethodHandler, Serializable
 {
   
+    private static final long serialVersionUID = 1L;
+    
     @Override
     public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws
Throwable
     {
@@ -37,5 +43,23 @@ public class AbstractDecoratorMethodHand
         //Throw the exception so the DelegateHandler will continue the loop
         throw new NoSuchMethodException();
     }
+    
+    private  void writeObject(ObjectOutputStream s) throws IOException
+    {
+        //TODO: abstract decorator could not be serialized yet.
+        s.writeLong(serialVersionUID);
+    }    
+    
+    private  void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
+    {
+        //TODO: abstract decorator could not be serialized yet.
+        if(s.readLong() == serialVersionUID) 
+        {
+        } 
+        else 
+        {
+        }
+    }    
+    
 
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DelegateHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DelegateHandler.java?rev=993475&r1=993474&r2=993475&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DelegateHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DelegateHandler.java
Tue Sep  7 18:58:01 2010
@@ -18,6 +18,11 @@
  */
 package org.apache.webbeans.decorator;
 
+import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.List;
@@ -27,13 +32,15 @@ import javax.interceptor.InvocationConte
 import org.apache.webbeans.component.EnterpriseBeanMarker;
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.config.OWBLogConst;
+import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.util.SecurityUtil;
+import org.apache.webbeans.util.WebBeansUtil;
 
 import javassist.util.proxy.MethodHandler;
 
-public class DelegateHandler implements MethodHandler
+public class DelegateHandler implements MethodHandler, Serializable, Externalizable
 {
     private transient WebBeansLogger logger = WebBeansLogger.getLogger(DelegateHandler.class);
 
@@ -46,6 +53,12 @@ public class DelegateHandler implements 
     
     private transient InvocationContext ejbContext;
 
+    //Do not remove this constructor, used by passivation.
+    public DelegateHandler()
+    {
+        logger = WebBeansLogger.getLogger(DelegateHandler.class);
+    }
+
     public DelegateHandler(OwbBean<?> bean)
     {
         this.bean = bean;
@@ -190,4 +203,35 @@ public class DelegateHandler implements 
         this.decorators = dec;
     }
 
+    @Override
+    public void writeExternal(ObjectOutput out) throws IOException 
+    {
+        String id = WebBeansUtil.isPassivationCapable(bean);
+        if (id != null) 
+        {
+            out.writeObject(id);
+            out.writeObject(actualBean);
+            out.writeObject(decorators);
+        }
+        else 
+        {
+            out.writeObject("");
+        }
+        //TODO: ejbContext is not serializable, need to re-grab it
+        //from the env.
+    }
+
+    @Override
+    public void readExternal(ObjectInput in) throws IOException,
+            ClassNotFoundException 
+    {
+        String id = (String)in.readObject();
+        if (id.equals("")) 
+        {
+            return;
+        }
+        bean = (OwbBean<?>) BeanManagerImpl.getManager().getPassivationCapableBean(id);
+        actualBean = in.readObject();
+        decorators = (List<Object>) in.readObject();
+    }    
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=993475&r1=993474&r2=993475&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Tue Sep  7 18:58:01 2010
@@ -97,6 +97,8 @@ import javax.interceptor.AroundInvoke;
 import javax.interceptor.AroundTimeout;
 import javax.interceptor.InvocationContext;
 
+import javassist.util.proxy.ProxyFactory;
+
 import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.annotation.ApplicationScopeLiteral;
 import org.apache.webbeans.annotation.DefaultLiteral;
@@ -3232,4 +3234,17 @@ public final class WebBeansUtil
 
         throw new RuntimeException(e);
     }
+    
+    public static void initProxyFactoryClassLoaderProvider()
+    {
+        ProxyFactory.classLoaderProvider = new ProxyFactory.ClassLoaderProvider()
+        {
+            @Override
+            public ClassLoader get(ProxyFactory pf)
+            {
+                return WebBeansUtil.getCurrentClassLoader();
+            }
+
+        };
+    } 
 }



Mime
View raw message