openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r910561 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/container/ main/java/org/apache/webbeans/decorator/ test/java/org/apache/webbea...
Date Tue, 16 Feb 2010 15:23:34 GMT
Author: struberg
Date: Tue Feb 16 15:23:34 2010
New Revision: 910561

URL: http://svn.apache.org/viewvc?rev=910561&view=rev
Log:
OWB-6 cache passivationId and use it consistently

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.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/decorator/WebBeansDecoratorConfig.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java?rev=910561&r1=910560&r2=910561&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
Tue Feb 16 15:23:34 2010
@@ -84,7 +84,14 @@
     
     /**Beans injection points*/
     protected Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
-        
+    
+    /**
+     * This string will be used for passivating the Bean.
+     * It will be created on the first use.
+     * @see #getId()
+     */
+    private String passivatingId = null;
+    
     /**Bean Manager*/
     private final BeanManager manager;
 
@@ -212,15 +219,19 @@
             // annotating it @Typed() as Object, then it is not serializable
             return null;
         }
-        
-        StringBuilder sb = new StringBuilder(webBeansType.toString()).append('#');
-        sb.append(returnType).append('#');
-        for (Annotation qualifier : implQualifiers)
+        if (passivatingId == null)
         {
-            sb.append(qualifier.toString()).append(',');
+            StringBuilder sb = new StringBuilder(webBeansType.toString()).append('#');
+            sb.append(returnType).append('#');
+            for (Annotation qualifier : implQualifiers)
+            {
+                sb.append(qualifier.toString()).append(',');
+            }
+            
+            passivatingId = sb.toString();
         }
 
-        return sb.toString();
+        return passivatingId;
     }
     
     public boolean isPassivationCapable()

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=910561&r1=910560&r2=910561&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
Tue Feb 16 15:23:34 2010
@@ -168,10 +168,8 @@
             {
                 throw  (WebBeansDeploymentException)e;
             }
-            else
-            {
-                throw new WebBeansDeploymentException(e);
-            }
+            
+            throw new WebBeansDeploymentException(e);
         }
     }
     

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=910561&r1=910560&r2=910561&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
Tue Feb 16 15:23:34 2010
@@ -18,6 +18,7 @@
 * under the License.
 */
 
+import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.exception.inject.DeploymentException;
 
 import javax.enterprise.context.spi.CreationalContext;
@@ -48,7 +49,6 @@
     /** the delegated bean */
     private Bean<T> bean;
 
-    private String id;
 
     /**
      * @return the delegated internal Bean. 
@@ -62,12 +62,10 @@
      * This constructor shall not be invoked directly, but only get called
      * from {@link org.apache.webbeans.container.SerializableBeanVault}
      * @param bean the PassivationCapable bean which should be made Serializable
-     * @param id the {@link javax.enterprise.inject.spi.PassivationCapable#getId()}
      */
-    SerializableBean(Bean<T> bean, String id)
+    SerializableBean(Bean<T> bean)
     {
         this.bean = bean;
-        this.id  = id;
     }
 
     @Override
@@ -139,7 +137,7 @@
     @Override
     public String getId()
     {
-        return this.id;
+        return ((OwbBean<?>) bean).getId();
     }
 
     private synchronized void writeObject(ObjectOutputStream s)
@@ -172,5 +170,29 @@
         bean = b;
     }
 
+    /**
+     * If the other object is a SerializableBean too, we compare the 2 underlying wrapped
beans.
+     * 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals(Object other) {
+        if (other instanceof SerializableBean<?>)
+        {
+            return bean.equals(((SerializableBean<?>)other).getBean());
+        }
+        
+        return super.equals(other);
+    }
+
+    /**
+     * We need to return the hashCode of the wrapped underlying bean, otherwise the context
+     * won't work.
+     * @return hashCode of the underlying bean instance.
+     */
+    @Override
+    public int hashCode() {
+        return bean.hashCode();
+    }
 
 }

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=910561&r1=910560&r2=910561&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
Tue Feb 16 15:23:34 2010
@@ -66,7 +66,7 @@
             SerializableBean<T> sb = (SerializableBean<T>) serializableBeans.get(id);
             if (sb == null)
             {
-                sb = new SerializableBean<T>((Bean<T>) bean,id);
+                sb = new SerializableBean<T>((Bean<T>) bean);
                 serializableBeans.put(id, sb);
             }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java?rev=910561&r1=910560&r2=910561&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
Tue Feb 16 15:23:34 2010
@@ -29,7 +29,6 @@
 import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.component.AbstractInjectionTargetBean;
 import org.apache.webbeans.component.InjectionTargetBean;
-import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.decorator.xml.WebBeansXMLDecorator;
 import org.apache.webbeans.inject.xml.XMLInjectionPointModel;

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=910561&r1=910560&r2=910561&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
Tue Feb 16 15:23:34 2010
@@ -133,8 +133,8 @@
     }
 
     private CreationalContext<?> deSerializeCreationalContext(byte[] serial) throws
IOException, ClassNotFoundException {
-        ByteArrayInputStream baos = new ByteArrayInputStream(serial);
-        ObjectInputStream ois = new ObjectInputStream(baos);
+        ByteArrayInputStream bais = new ByteArrayInputStream(serial);
+        ObjectInputStream ois = new ObjectInputStream(bais);
         return (CreationalContext<?>) ois.readObject();
     }
 



Mime
View raw message