openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r907112 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-impl/src/main/java/org/apache/webbeans/component/third/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/jav...
Date Fri, 05 Feb 2010 22:05:54 GMT
Author: gerdogdu
Date: Fri Feb  5 22:05:54 2010
New Revision: 907112

URL: http://svn.apache.org/viewvc?rev=907112&view=rev
Log:
[OWB-6] Update passivation scope related work. Just define passivation capable if the contextual
is really a passivation capable according to section 6

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BaseBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OWBLogConst.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBeanVault.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomPassivatingContextImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebApplicationLifeCycle.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/resources/openwebbeans/Messages.properties
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java
    openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/component/EjbBean.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java
Fri Feb  5 22:05:54 2010
@@ -220,11 +220,9 @@
     {
         
     }
-
+    
     /**
-     * This is needed for serialization
-     * @return the id uniquely identifying the bean.
-     * @see javax.enterprise.inject.spi.PassivationCapable#getId() 
+     * {@inheritDoc}
      */
     public String getId()
     {
@@ -243,6 +241,11 @@
 
         return sb.toString();
     }
+    
+    public boolean isPassivationCapable()
+    {
+        return false;
+    }
 
     /**
      * Get bean type.

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
Fri Feb  5 22:05:54 2010
@@ -13,6 +13,7 @@
  */
 package org.apache.webbeans.component;
 
+import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.util.Set;
 
@@ -21,6 +22,7 @@
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.Producer;
 
+import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
 /**
@@ -200,5 +202,21 @@
 
         return super.getInjectionPoints();
     }
+    
+    protected boolean isPassivationCapable(Class<?> returnType, Integer modifiers)
+    {
+        if(ClassUtil.isFinal(modifiers) && !(Serializable.class.isAssignableFrom(returnType)))
+        {
+            return false;
+        }
+        
+        if(ClassUtil.isPrimitive(returnType) || Serializable.class.isAssignableFrom(returnType))
+        {
+            return true;
+        }
+        
+        return false;
+    }
+    
 
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BaseBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BaseBean.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BaseBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BaseBean.java
Fri Feb  5 22:05:54 2010
@@ -31,7 +31,7 @@
  * @version $Rev$ $Date$
  * <T> bean class
  */
-public abstract class BaseBean<T> implements Bean<T>, PassivationCapable
+public abstract class BaseBean<T> implements Bean<T>
 {
     /**Bean Manager*/
     private final BeanManager manager;
@@ -205,4 +205,16 @@
      */    
     public abstract boolean isEnabled();
     
+    /**
+     * Gets id of the bean.
+     * @return id of the bean
+     */
+    public abstract String getId();
+    
+    /**
+     * True if passivation capable false otherwise.
+     * @return true if this bean is passivation capable
+     */
+    public abstract boolean isPassivationCapable();
+    
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
Fri Feb  5 22:05:54 2010
@@ -13,14 +13,15 @@
  */
 package org.apache.webbeans.component;
 
-import java.io.IOException;
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
 
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Decorator;
 
 import org.apache.webbeans.inject.InjectableConstructor;
+import org.apache.webbeans.intercept.InterceptorData;
 
 /**
  * Managed bean implementation of the {@link Bean}.
@@ -85,5 +86,30 @@
     {
         this.constructor = constructor;
     }
+    
+    public boolean isPassivationCapable()
+    {
+        if(Serializable.class.isAssignableFrom(this.returnType))
+        {
+            for(Decorator<?> dec : this.decorators)
+            {
+                if(!Serializable.class.isAssignableFrom(dec.getBeanClass()))
+                {
+                    return false;
+                }
+            }
+            
+            for(InterceptorData interceptorData : this.interceptorStack)
+            {
+                if(!(interceptorData.getInterceptorInstance() instanceof Serializable))
+                {
+                    return false;
+                }
+            }
+        }
+        
+        return true;
+    }
+
 
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
Fri Feb  5 22:05:54 2010
@@ -175,6 +175,13 @@
         String errorMessage = "WebBeans producer method : " + producerField.getName() + "
return type in the component implementation class : " + this.ownerComponent.getReturnType().getName()
+ " with passivating scope @" + this.getScope().getName() + " must be Serializable";
         WebBeansUtil.checkSerializableScopeType(this.getScope(), this.isSerializable(), errorMessage);
     }
+    
+    @Override
+    public boolean isPassivationCapable()
+    {
+        return isPassivationCapable(this.producerField.getType(),this.producerField.getModifiers());
+    }
+    
 
     /**
      * {@inheritDoc}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
Fri Feb  5 22:05:54 2010
@@ -41,9 +41,6 @@
     /** Disposal method */
     protected Method disposalMethod;
 
-    /** @deprecated*/ /*, Realizations are removed from the specification*/
-    protected boolean fromRealizes;
-
     /**
      * Creates a new instance.
      * 
@@ -264,25 +261,13 @@
         WebBeansUtil.checkSerializableScopeType(this.getScope(), this.isSerializable(), errorMessage);
 
     }
-
-    /**
-     * Returns fromRealize.
-     * 
-     * @return the fromRealizes
-     */
-    public boolean isFromRealizes()
-    {
-        return fromRealizes;
-    }
-
-    /**
-     * Set fromRealize.
-     * 
-     * @param fromRealizes the fromRealizes to set
-     */
-    public void setFromRealizes(boolean fromRealizes)
+    
+    
+    
+    @Override
+    public boolean isPassivationCapable()
     {
-        this.fromRealizes = fromRealizes;
+        return isPassivationCapable(this.creatorMethod.getReturnType(),this.creatorMethod.getModifiers());
     }
 
     public String toString()

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java
Fri Feb  5 22:05:54 2010
@@ -23,6 +23,7 @@
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.PassivationCapable;
 
 import org.apache.webbeans.component.AbstractBean;
 import org.apache.webbeans.component.WebBeansType;
@@ -95,6 +96,28 @@
     }
 
 
+    /* (non-Javadoc)
+     * @see org.apache.webbeans.component.AbstractBean#getId()
+     */
+    @Override
+    public String getId()
+    {
+        if(this.bean instanceof PassivationCapable)
+        {
+            PassivationCapable pc = (PassivationCapable)this.bean;
+            return pc.getId();
+        }
+        
+        return null;
+    }
+    
+    
+
+    @Override
+    public boolean isPassivationCapable()
+    {
+        return this.bean instanceof PassivationCapable ? true : false;
+    }
 
     @Override
     protected T createInstance(CreationalContext<T> creationalContext)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OWBLogConst.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OWBLogConst.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OWBLogConst.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OWBLogConst.java
Fri Feb  5 22:05:54 2010
@@ -43,7 +43,6 @@
     public final static String TEXT_CONFIG_NOT_FOUND = "TEXT_CONFIG_NOT_FOUND"; // ] not
found. Using default settings.
     public final static String TEXT_CONFIG_FOUND     = "TEXT_CONFIG_FOUND";     // ] found
at location :
     public final static String TEXT_OVERRIDING       = "TEXT_OVERRIDING";       // . Overriding
default settings.
-    public final static String TEXT_MUSTSCOPE        = "TEXT_MUSTSCOPE";        // Stereotypes
must declare the same @Scope annotations for Managed Bean Implementation Class :
     public final static String TEXT_MB_IMPL          = "TEXT_MB_IMPL";          // Managed
Bean implementation class : 
     public final static String TEXT_SAME_SCOPE       = "TEXT_SAME_SCOPE";       //  stereotypes
must declare the same @Scope annotations.
     public final static String TEXT_JAVA_TYPENAME    = "TEXT_JAVA_TYPENAME";    // Java type
with name : 
@@ -80,13 +79,7 @@
     public final static String INFO_0030 = "INFO_0030"; // Checking Specialization constraints
is ended.
     public final static String INFO_0031 = "INFO_0031"; // Checking StereoTypes constraints
is started.
     public final static String INFO_0032 = "INFO_0032"; // Checking StereoTypes constraints
is ended.
-    public final static String INFO_0033 = "INFO_0033"; // Adding OpenWebBeansPlugin : 
-    public final static String INFO_0034 = "INFO_0034"; // Create new transitional conversation
for non-faces request with view id : [{1}]
-    public final static String INFO_0035 = "INFO_0035"; // Propogation of the conversation
for non-faces request with cid: [{1}] for view: [{2}]
-    public final static String INFO_0036 = "INFO_0036"; // Propogated conversation for non-faces
request can not be restored for view id : [{1}]. Creates new transitional conversation.
-    public final static String INFO_0038 = "INFO_0038"; // Conversation is restored for non-faces
request with cid: [{1}] for view id: [{2}]
-    public final static String INFO_0039 = "INFO_0039"; // Conversation is restored for JSF
postback with cid: [{1}] for view id: [{2}]
-    public final static String INFO_0040 = "INFO_0040"; // Create new transient conversation
for JSF postback view id : [{1}]
+    public final static String INFO_0033 = "INFO_0033"; // Adding OpenWebBeansPlugin :
     public final static String INFO_0041 = "INFO_0041"; // Destroying the conversation context
with cid: [{0}] for view: [{1}]
     public final static String INFO_0042 = "INFO_0042"; // Restoring conversation with cid:
[{0}] for view: [{1}]
     public final static String INFO_0043 = "INFO_0043"; // Creating a new transitional conversation
for view: [{0}]
@@ -111,6 +104,7 @@
     public final static String ERROR_0010 = "ERROR_0010"; // An error occured while closing
the JMS instance.
     public final static String ERROR_0011 = "ERROR_0011"; // Method security access violation
for method : [{1}] in decorator class : [{2}]
     public final static String ERROR_0012 = "ERROR_0012"; // Exception in calling method
: [{1}] in decorator class : [{2}]. Look in the log for target checked exception.
+    public final static String ERROR_0013 = "ERROR_0013"; // Got an Exception while starting
a fresh session!
     public final static String ERROR_0014 = "ERROR_0014"; // Method illegal access for method
: [{1}] in decorator class : [{2}]
     public final static String ERROR_0015 = "ERROR_0015"; // Illegal access exception for
field : [{1}] in decorator class : [{2}]
     public final static String ERROR_0016 = "ERROR_0016"; // IllegalArgumentException has
occured while calling the field: [{1}] on the class: [{2}]

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=907112&r1=907111&r2=907112&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
Fri Feb  5 22:05:54 2010
@@ -99,8 +99,8 @@
     /**Holds the context with key scope*/
     private static Map<Class<? extends Annotation>, List<Context>> contextMap
= new ConcurrentHashMap<Class<? extends Annotation>, List<Context>>();
 
-    /**Activity webbeans components*/
-    private Set<Bean<?>> components = new CopyOnWriteArraySet<Bean<?>>();
+    /**Deployment archive beans*/
+    private Set<Bean<?>> deploymentBeans = new CopyOnWriteArraySet<Bean<?>>();
 
     /**Activity interceptors*/
     private Set<Interceptor<?>> webBeansInterceptors = new CopyOnWriteArraySet<Interceptor<?>>();
@@ -140,7 +140,7 @@
      * This map stores all {@link PassivationCapable} beans along with their unique id.
      * This is used for serialization.
      */
-    private Map<String, Bean<?>> passivationCapableBeans = new ConcurrentHashMap<String,
Bean<?>>(); 
+    private ConcurrentHashMap<String, Bean<?>> passivationCapableBeans = new
ConcurrentHashMap<String, Bean<?>>(); 
 
     /**
      * The parent Manager this child is depending from.
@@ -276,23 +276,23 @@
     }
 
     /**
-     * Add new webbeans component to the activity.
+     * Add new bean.
      * 
-     * @param component new webbeans component
-     * @return the this activity
+     * @param newBean new bean instance
+     * @return the this manager
      */
     
-    public BeanManager addBean(Bean<?> component)
+    public BeanManager addBean(Bean<?> newBean)
     {
-        if(component instanceof AbstractBean)
+        if(newBean instanceof AbstractBean)
         {
-            this.components.add(component);
-            addPassivationCapableBean(component);
+            this.deploymentBeans.add(newBean);
+            addPassivationCapableBean(newBean);
         }
         else
         {
-            ThirdpartyBeanImpl<?> bean = new ThirdpartyBeanImpl(component);
-            this.components.add(bean);
+            ThirdpartyBeanImpl<?> bean = new ThirdpartyBeanImpl(newBean);
+            this.deploymentBeans.add(bean);
             addPassivationCapableBean(bean);
         }
         
@@ -308,20 +308,16 @@
      */
     protected void addPassivationCapableBean(Bean<?> bean) throws DefinitionException
     {
-        if (bean instanceof PassivationCapable)
+        String id = null;
+        if((id=WebBeansUtil.isPassivationCapable(bean)) != null)
         {
-            PassivationCapable pc = (PassivationCapable) bean;
-            String id = pc.getId();
-
-            if (id != null)
+            Bean<?> oldBean = passivationCapableBeans.putIfAbsent(id, bean);
+            if (oldBean != null)
             {
-                Bean<?> oldBean = passivationCapableBeans.put(id, bean);
-                if (oldBean != null)
-                {
-                    throw new DefinitionException("PassivationCapable bean id is not unique:
" + id);
-                }
+                throw new DefinitionException("PassivationCapable bean id is not unique:
" + id);
             }
-        }
+            
+        }        
     }
 
     
@@ -438,7 +434,7 @@
     
     public Set<Bean<?>> getComponents()
     {
-        return getManager().components;
+        return getManager().deploymentBeans;
     }
     
     
@@ -521,7 +517,7 @@
     
     public Set<Bean<?>> getBeans()
     {
-        return this.components;
+        return this.deploymentBeans;
     }
     
     public Set<Interceptor<?>> getInterceptors()
@@ -871,7 +867,8 @@
         {
             for (ExternalScope extScope : additionalScopes)
             {
-                if (extScope.equals(annotationType)) {
+                if (extScope.equals(annotationType))
+                {
                     return extScope.isPassivating();
                 }
             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBean.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBean.java
Fri Feb  5 22:05:54 2010
@@ -40,11 +40,16 @@
  *
  * @version $Rev$ $Date$
  */
-public final class SerializableBean<T> implements Bean<T>, PassivationCapable,
Serializable {
+public final class SerializableBean<T> implements Bean<T>, PassivationCapable,
Serializable 
+{
+
+    private static final long serialVersionUID = -8141263188006177021L;
 
     /** the delegated bean */
     private Bean<T> bean;
 
+    private String id;
+    
     /**
      * @return the deletaged internal Bean. 
      */
@@ -53,9 +58,10 @@
         return bean;
     }
 
-    public SerializableBean(Bean<T> bean)
+    public SerializableBean(Bean<T> bean, String id)
     {
         this.bean = bean;
+        this.id  = id;        
     }
 
     @Override
@@ -127,11 +133,7 @@
     @Override
     public String getId()
     {
-        if (bean instanceof PassivationCapable)
-        {
-            return ((PassivationCapable)bean).getId();
-        }
-        return null;
+        return this.id;
     }
 
     private synchronized void writeObject(ObjectOutputStream s)
@@ -147,6 +149,7 @@
     }
 
 
+    @SuppressWarnings("unchecked")
     private synchronized void readObject(ObjectInputStream s)
     throws IOException, ClassNotFoundException
     {
@@ -157,8 +160,9 @@
         }
         if (b instanceof SerializableBean)
         {
-            b = ((SerializableBean)b).getBean();
+            b = ((SerializableBean<T>)b).getBean();
         }
+        
         bean = b;
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBeanVault.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBeanVault.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBeanVault.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBeanVault.java
Fri Feb  5 22:05:54 2010
@@ -18,13 +18,12 @@
 * under the License.
 */
 
-import org.apache.webbeans.component.AbstractBean;
 import org.apache.webbeans.config.WebBeansFinder;
+import org.apache.webbeans.util.WebBeansUtil;
 
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.PassivationCapable;
-import java.io.Serializable;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -51,32 +50,23 @@
         return (SerializableBeanVault) WebBeansFinder.getSingletonInstance(SerializableBeanVault.class.getName());
     }
 
+    @SuppressWarnings("unchecked")
     public <T> Contextual<T> getSerializableBean(Contextual<T> bean)
     {
-        if (bean instanceof Serializable)
+        String id = null;
+        
+        if((id=WebBeansUtil.isPassivationCapable(bean)) != null) 
         {
-            // we don't need to wrap beans which are already Serializable
-            return bean;
-        }
-
-        if (bean instanceof AbstractBean)
-        {
-            AbstractBean<T> ab = (AbstractBean<T>)bean;
-            if (ab.isSerializable())
+            SerializableBean<T> sb = (SerializableBean<T>) serializableBeans.get(id);
+            if (sb == null)
             {
-                String id = ab.getId();
-                SerializableBean<T> sb = (SerializableBean<T>) serializableBeans.get(id);
-                if (sb == null)
-                {
-                    sb = new SerializableBean<T>((Bean<T>) bean);
-                    serializableBeans.put(id, sb);
-                }
-
-                return sb;
+                sb = new SerializableBean<T>((Bean<T>) bean,id);
+                serializableBeans.put(id, sb);
             }
-        }
 
-        // this should not happen, because all our beans are AbstractBeans!
+            return sb;            
+        }
+        
         return null;
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomPassivatingContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomPassivatingContextImpl.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomPassivatingContextImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomPassivatingContextImpl.java
Fri Feb  5 22:05:54 2010
@@ -33,16 +33,16 @@
         super(context);
     }
 
-    public <T> T get(Contextual<T> component, CreationalContext<T> crreationalContext)
+    public <T> T get(Contextual<T> contextual, CreationalContext<T> crreationalContext)
     {
         SerializableBeanVault sbv = SerializableBeanVault.getInstance();
-        return super.get(sbv.getSerializableBean(component), crreationalContext);
+        return super.get(sbv.getSerializableBean(contextual), crreationalContext);
     }
 
-    public <T> T get(Contextual<T> component)
+    public <T> T get(Contextual<T> contextual)
     {
         SerializableBeanVault sbv = SerializableBeanVault.getInstance();
-        return super.get(sbv.getSerializableBean(component));
+        return super.get(sbv.getSerializableBean(contextual));
     }
 
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
Fri Feb  5 22:05:54 2010
@@ -24,12 +24,13 @@
 import javax.enterprise.inject.spi.PassivationCapable;
 
 import org.apache.webbeans.container.BeanManagerImpl;
-import org.apache.webbeans.container.SerializableBeanVault;
 import org.apache.webbeans.util.Asserts;
 
 /** {@inheritDoc} */
 public class CreationalContextImpl<T> implements CreationalContext<T>, Serializable
 {
+    private static final long serialVersionUID = -3416834742959340960L;
+
     private transient Object incompleteInstance = null;
     
     private Object proxyInstance = null;
@@ -43,6 +44,8 @@
     
     private static class DependentCreationalContext<S> implements Serializable
     {
+        private static final long serialVersionUID = 7107949019995422165L;
+
         private CreationalContext<S> creationalContext;
         
         private Contextual<S> contextual;
@@ -228,6 +231,7 @@
     }
 
 
+    @SuppressWarnings("unchecked")
     private synchronized void readObject(ObjectInputStream s)
     throws IOException, ClassNotFoundException
     {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebApplicationLifeCycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebApplicationLifeCycle.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebApplicationLifeCycle.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebApplicationLifeCycle.java
Fri Feb  5 22:05:54 2010
@@ -128,7 +128,7 @@
             		httpRequest.getSession();
             	}
             	catch(Exception e) {
-            		logger.error("Got an Exception while starting a fresh session! ", e);
+            		logger.error(OWBLogConst.ERROR_0013, e);
             	}
             }
         }

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=907112&r1=907111&r2=907112&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
Fri Feb  5 22:05:54 2010
@@ -13,6 +13,7 @@
  */
 package org.apache.webbeans.util;
 
+import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Target;
@@ -45,6 +46,7 @@
 import javax.enterprise.context.NormalScope;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.event.Event;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Alternative;
@@ -69,6 +71,7 @@
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.Interceptor;
 import javax.enterprise.inject.spi.ObserverMethod;
+import javax.enterprise.inject.spi.PassivationCapable;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
 import javax.enterprise.inject.spi.ProcessBean;
 import javax.enterprise.inject.spi.ProcessInjectionTarget;
@@ -135,7 +138,6 @@
 import org.apache.webbeans.plugins.PluginLoader;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
 import org.apache.webbeans.portable.creation.InjectionTargetProducer;
-import org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl;
 import org.apache.webbeans.portable.events.discovery.ErrorStack;
 import org.apache.webbeans.portable.events.generics.GProcessAnnotatedType;
 import org.apache.webbeans.portable.events.generics.GProcessInjectionTarget;
@@ -728,6 +730,7 @@
      * Creates a new instance bean.
      * @return new instance bean
      */
+    @SuppressWarnings("serial")
     public static <T> InstanceBean<T> getInstanceBean()
     {
         InstanceBean<T> instanceBean = new InstanceBean<T>();
@@ -747,6 +750,7 @@
      * Creates a new event bean.
      * @return new event bean
      */
+    @SuppressWarnings("serial")
     public static <T> EventBean<T> getEventBean()
     {
         EventBean<T> eventBean = new EventBean<T>();
@@ -2322,7 +2326,38 @@
         }finally
         {
             stack.clear();
+        }        
+    }
+    
+    public static String isPassivationCapable(Contextual<?> contextual)
+    {
+        if(contextual instanceof Bean)
+        {
+            if(contextual instanceof AbstractBean)
+            {
+                if( ((AbstractBean<?>)contextual).isPassivationCapable())
+                {
+                    return ((AbstractBean<?>)contextual).getId();
+                }
+            }
+            
+            else if(contextual instanceof PassivationCapable)
+            {
+                PassivationCapable pc = (PassivationCapable)contextual;
+                
+                return pc.getId();
+            }
+        }
+        else
+        {
+            if((contextual instanceof PassivationCapable) && (contextual instanceof
Serializable))
+            {
+                PassivationCapable pc = (PassivationCapable)contextual;
+                
+                return pc.getId();
+            }
         }
         
+        return null;
     }
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/resources/openwebbeans/Messages.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/resources/openwebbeans/Messages.properties?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/resources/openwebbeans/Messages.properties (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/resources/openwebbeans/Messages.properties Fri
Feb  5 22:05:54 2010
@@ -46,10 +46,9 @@
 TEXT_CONFIG_NOT_FOUND = ] not found. Using default settings.
 TEXT_CONFIG_FOUND = ] found at location :
 TEXT_OVERRIDING = . Overriding default settings.
-TEXT_MUSTSCOPE = Stereotypes must declare the same @Scope annotations for Managed Bean Implementation
Class :
 TEXT_MB_IMPL = Managed Bean implementation class \: 
 TEXT_SAME_SCOPE =  stereotypes must declare the same @Scope annotations.
-
+TEXT_JAVA_TYPENAME = Java type with name :
 
 
 
@@ -59,41 +58,35 @@
 INFO_0002 = OpenWebBeans Container is starting.
 INFO_0003 = Scanning classpaths for beans artifacts.
 INFO_0004 = Deploying scanned beans.
-INFO_0005 = OpenWebBeans Container is started, it took {0} ms.
+INFO_0005 = OpenWebBeans Container has started, it took {0} ms.
 INFO_0006 = OpenWebBeans Container is stopping.
 INFO_0007 = OpenWebBeans Container has stopped.
-INFO_0008 = OpenWebBeans Container is stopped for context path, {0}
+INFO_0008 = OpenWebBeans Container was stopped for context path, {0}
 INFO_0009 = Session is passivated. Session id \: [{0}] 
 INFO_0010 = Session is activated. Session id : [{0}]
 INFO_0011 = Starting configuration of Web Beans {0}
 INFO_0012 = Finished configuration of Web Beans {0}
-INFO_0013 = Validation of injection points are started.
-INFO_0014 = Validation of the decorator's injection points are started.
-INFO_0015 = Validation of the interceptor's injection points are started.
-INFO_0016 = All injection points are validated succesfully.
-INFO_0017 = Deploying configurations from class files is started.
+INFO_0013 = Validation of injection points has started.
+INFO_0014 = Validation of the decorator's injection points has started.
+INFO_0015 = Validation of the interceptor's injection points has started.
+INFO_0016 = All injection points were validated successfully.
+INFO_0017 = Deploying configurations from class files has started.
 INFO_0018 = Found Managed Bean with class name : [{0}]
 INFO_0019 = Found Enterprise Bean with class name : [{0}]
-INFO_0020 = Deploying configurations from class files is ended.
-INFO_0021 = Deploying configurations from XML files is started.
-INFO_0022 = Deploying configurations from XML is ended succesfully.
-INFO_0023 = Configuring the Interceptors is started.
+INFO_0020 = Deploying configurations from class files has ended.
+INFO_0021 = Deploying configurations from XML files has started.
+INFO_0022 = Deploying configurations from XML has ended succesfully.
+INFO_0023 = Configuring the Interceptors has started.
 INFO_0024 = Found Managed Bean Interceptor with class name : [{0}]
-INFO_0025 = Configuring the Interceptors is ended.
-INFO_0026 = Configuring the Decorators is started.
+INFO_0025 = Configuring the Interceptors has ended.
+INFO_0026 = Configuring the Decorators has started.
 INFO_0027 = Found Managed Bean Decorator with class name : [{0}]
-INFO_0028 = Configuring the Decorators is ended.
-INFO_0029 = Checking Specialization constraints is started.
-INFO_0030 = Checking Specialization constraints is ended.
-INFO_0031 = Checking StereoTypes constraints is started.
-INFO_0032 = Checking StereoTypes constraints is ended.
+INFO_0028 = Configuring the Decorators has ended.
+INFO_0029 = Checking Specialization constraints has started.
+INFO_0030 = Checking Specialization constraints has ended.
+INFO_0031 = Checking StereoType constraints has started.
+INFO_0032 = Checking StereoType constraints has ended.
 INFO_0033 = Adding OpenWebBeansPlugin : {0}
-INFO_0034 = Create new transitional conversation for non-faces request with view id : [{0}]
-INFO_0035 = Propogation of the conversation for non-faces request with cid: [{0}] for view:
[{1}]
-INFO_0036 = Propogated conversation for non-faces request can not be restored for view id
: [{0}]. Creates new transitional conversation.
-INFO_0038 = Conversation is restored for non-faces request with cid: [{0}] for view: [{1}]
-INFO_0039 = Conversation is restored for JSF postback with cid: [{0}] for view: [{1}]
-INFO_0040 = Create new transient conversation for JSF postback view id : [{0}]
 INFO_0041 = Destroying the conversation context with cid: [{0}]
 INFO_0042 = Restoring conversation with cid: [{0}]
 INFO_0043 = Creating a new transitional conversation with cid: [{0}]
@@ -103,12 +96,12 @@
 #warning messages:
 WARN_0000 = Some random warning text for use in testing.
 WARN_0001 = No plugins to shutDown.
-WARN_0002 = Alternative XML content is wrong. Child of <alternatives> must be <class>,<stereotype>
but found \: 
+WARN_0002 = Alternative XML content is incorrect. Child of <alternatives> must be <class>,<stereotype>
but found \: 
 WARN_0003 = Discovery service not found. Continue by using MetaDataDiscoveryStandard as a
default.
 WARN_0004 = OpenWebBeans Container is already started.
 WARN_0005 = OpenWebBeans Container is already stopped.
-WARN_0006 = Conversation already started with cid : [{0}]
-WARN_0007 = Conversation already ended with cid : [{0}]
+WARN_0006 = Conversation with cid [{0}] already started
+WARN_0007 = Conversation with cid [{0}] already ended
 
 
 #error messages:
@@ -125,7 +118,8 @@
 ERROR_0010 = An error occured while closing the JMS instance.
 ERROR_0011 = Method security access violation for method : [{0}] in decorator class : [{1}]
 ERROR_0012 = Exception in calling method : [{0}] in decorator class : [{1}]. Look in the
log for target checked exception.
-ERROR_0014 = Method illegal access for method : [{0}] in decorator class : [{1}]
+ERROR_0013 = Caught an Exception while starting a fresh session!
+ERROR_0014 = Illegal access exception for method : [{0}] in decorator class : [{1}]
 ERROR_0015 = Illegal access exception for field : [{0}] in decorator class : [{1}]
 ERROR_0016 = IllegalArgumentException has occured while calling the field: [{0}] on the class:
[{1}]
 ERROR_0017 = IllegalAccessException has occured while calling the field: [{0}] on the class:
[{1}]
@@ -142,19 +136,19 @@
 CRITICAL_DEFAULT_CONFIG_FAILURE = Problem while loading OpenWebBeans default configuration.
 CRITICAL_SPECIAL_CONFIG_FAILURE = Problem while loading OpenWebBeans specialized configuration.
 EXCEPT_0001 = Wrong initialization object.
-EXCEPT_0002 = Wrong ended object.
+EXCEPT_0002 = Wrong termination object.
 EXCEPT_0003 = Specialized class [
-EXCEPT_0004 = ] must extendanothre class.
+EXCEPT_0004 = ] must extend another class.
 EXCEPT_XML = XML Specialization Error \: 
 EXCEPT_0005 = More than one class specialized the same super class :
-EXCEPT_0006 = Got Exceptions while sending shutdown to the following plugins \: 
+EXCEPT_0006 = Caught Exceptions while sending shutdown to the following plugins \: 
 EXCEPT_0007 = TransactionPhase not supported\: 
-EXCEPT_0008 = Exception is thrown while handling event object with type \: 
+EXCEPT_0008 = Caught Exception while handling event object with type \: 
 EXCEPT_0009 = Unable to unbind object with name \: 
 EXCEPT_0010 = Unable to lookup object with name \: 
 EXCEPT_0011 = Could not find Decorator delegate attribute for decorator class \: 
 EXCEPT_0012 = All elements in the beans.xml file have to declare name space.
 EXCEPT_0013 = Unable to read root element of the given input stream.
-EXCEPT_0014 = Multiple class with name \: 
+EXCEPT_0014 = Multiple classes with name \: 
 
 #========= END OF TRANSLATED MESSAGES =================================

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java
Fri Feb  5 22:05:54 2010
@@ -28,6 +28,8 @@
 import org.apache.webbeans.newtests.injection.circular.beans.CircularConstructorOrProducerMethodParameterBean;
 import org.apache.webbeans.newtests.injection.circular.beans.CircularDependenScopeBean;
 import org.apache.webbeans.newtests.injection.circular.beans.CircularNormalInConstructor;
+import org.apache.webbeans.util.WebBeansUtil;
+
 import junit.framework.Assert;
 import org.junit.Test;
 
@@ -92,15 +94,17 @@
 
         for (Bean<?> bean : beans)
         {
-            if (! (bean instanceof SerializableBean))
+            String id = null;
+            if((id = WebBeansUtil.isPassivationCapable(bean)) != null)
             {
-                bean = new SerializableBean(bean);
-            }
-            
-            byte[] serial = serializeBean(bean);
-            Bean b2 = deSerializeBean(serial);
-
-            Assert.assertEquals(((SerializableBean)bean).getBean(), ((SerializableBean)b2).getBean());
+                bean = new SerializableBean(bean,id);
+                
+                byte[] serial = serializeBean(bean);
+                Bean b2 = deSerializeBean(serial);
+
+                Assert.assertEquals(((SerializableBean)bean).getBean(), ((SerializableBean)b2).getBean());
+                
+            }            
         }
 
     }

Modified: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/component/EjbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/component/EjbBean.java?rev=907112&r1=907111&r2=907112&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/component/EjbBean.java
(original)
+++ openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/component/EjbBean.java
Fri Feb  5 22:05:54 2010
@@ -107,6 +107,22 @@
         //No-operations
     }
     
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.webbeans.component.AbstractBean#isPassivationCapable()
+     */
+    @Override
+    public boolean isPassivationCapable()
+    {
+        if(this.ejbType.equals(SessionBeanType.STATELESS))
+        {
+            return true;
+        }
+        
+        return false;
+    }
+
     /**
      * Inject session bean injected fields. It is called from
      * interceptor.



Mime
View raw message