Author: dblevins
Date: Sun Jun 19 10:02:59 2011
New Revision: 1137328

URL: http://svn.apache.org/viewvc?rev=1137328&view=rev
Log:
OWB-573: Invalid checking of Interceptor serialization capabilities for 
non-Passivation capable EJBs
OWB-587: Use business interface for producer and disposer methods of Session 
beans
Some toString, equals and hashcode methods

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/DefinitionUtil.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/BeanInstanceBag.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
    
openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
    
openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/plugins/OpenWebBeansEjbPlugin.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=1137328&r1=1137327&r2=1137328&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
 Sun Jun 19 10:02:59 2011
@@ -610,7 +610,12 @@ public abstract class AbstractOwbBean<T>
      */    
     public String toString()
     {
-        StringBuilder builder = new StringBuilder();        
+        StringBuilder builder = new StringBuilder();
+        if (returnType != null)
+        {
+            final String simpleName = returnType.getSimpleName();
+            builder.append(simpleName).append(", ");
+        }
         builder.append("Name:").append(getName()).append(", WebBeans 
Type:").append(getWebBeansType());
         builder.append(", API Types:[");
         
@@ -701,5 +706,176 @@ public abstract class AbstractOwbBean<T>
         }
     }
 
-    
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((apiTypes == null) ? 0 : 
apiTypes.hashCode());
+        result = prime * result + (enabled ? 1231 : 1237);
+        result = prime * result + (isAlternative() ? 1289 : 1273);
+        result = prime * result + ((implQualifiers == null) ? 0 : 
implQualifiers.hashCode());
+        result = prime * result + ((implScopeType == null) ? 0 : 
implScopeType.hashCode());
+        result = prime * result + ((injectionPoints == null) ? 0 : 
injectionPoints.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + (nullable ? 1231 : 1237);
+        result = prime * result + ((returnType == null) ? 0 : 
returnType.hashCode());
+        result = prime * result + ((scopeClass == null) ? 0 : 
scopeClass.hashCode());
+        result = prime * result + (serializable ? 1231 : 1237);
+        result = prime * result + (specializedBean ? 1231 : 1237);
+        result = prime * result + ((stereoTypeClasses == null) ? 0 : 
stereoTypeClasses.hashCode());
+        result = prime * result + ((stereoTypes == null) ? 0 : 
stereoTypes.hashCode());
+        result = prime * result + ((webBeansType == null) ? 0 : 
webBeansType.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj)
+    {
+        if (this == obj)
+        {
+            return true;
+        }
+        if (obj == null)
+        {
+            return false;
+        }
+        if (getClass() != obj.getClass())
+        {
+            return false;
+        }
+        AbstractOwbBean other = (AbstractOwbBean) obj;
+        if (apiTypes == null)
+        {
+            if (other.apiTypes != null)
+            {
+                return false;
+            }
+        }
+        else if (!apiTypes.equals(other.apiTypes))
+        {
+            return false;
+        }
+        if (enabled != other.enabled)
+        {
+            return false;
+        }
+        if (isAlternative() != other.isAlternative())
+        {
+            return false;
+        }
+        if (implQualifiers == null)
+        {
+            if (other.implQualifiers != null)
+            {
+                return false;
+            }
+        }
+        else if (!implQualifiers.equals(other.implQualifiers))
+        {
+            return false;
+        }
+        if (implScopeType == null)
+        {
+            if (other.implScopeType != null)
+            {
+                return false;
+            }
+        }
+        else if (!implScopeType.equals(other.implScopeType))
+        {
+            return false;
+        }
+        if (injectionPoints == null)
+        {
+            if (other.injectionPoints != null)
+            {
+                return false;
+            }
+        }
+        else if (!injectionPoints.equals(other.injectionPoints))
+        {
+            return false;
+        }
+        if (name == null)
+        {
+            if (other.name != null)
+            {
+                return false;
+            }
+        }
+        else if (!name.equals(other.name))
+        {
+            return false;
+        }
+        if (nullable != other.nullable)
+        {
+            return false;
+        }
+        if (returnType == null)
+        {
+            if (other.returnType != null)
+            {
+                return false;
+            }
+        }
+        else if (!returnType.equals(other.returnType))
+        {
+            return false;
+        }
+        if (scopeClass == null)
+        {
+            if (other.scopeClass != null)
+            {
+                return false;
+            }
+        }
+        else if (!scopeClass.equals(other.scopeClass))
+        {
+            return false;
+        }
+        if (serializable != other.serializable)
+        {
+            return false;
+        }
+        if (specializedBean != other.specializedBean)
+        {
+            return false;
+        }
+        if (stereoTypeClasses == null)
+        {
+            if (other.stereoTypeClasses != null)
+            {
+                return false;
+            }
+        }
+        else if (!stereoTypeClasses.equals(other.stereoTypeClasses))
+        {
+            return false;
+        }
+        if (stereoTypes == null)
+        {
+            if (other.stereoTypes != null)
+            {
+                return false;
+            }
+        }
+        else if (!stereoTypes.equals(other.stereoTypes))
+        {
+            return false;
+        }
+        if (webBeansType == null)
+        {
+            if (other.webBeansType != null)
+            {
+                return false;
+            }
+        }
+        else if (!webBeansType.equals(other.webBeansType))
+        {
+            return false;
+        }
+        return true;
+    }
+
 }

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=1137328&r1=1137327&r2=1137328&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
 Sun Jun 19 10:02:59 2011
@@ -74,6 +74,7 @@ import org.apache.webbeans.event.Notific
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.intercept.InterceptorData;
 import org.apache.webbeans.spi.api.ResourceReference;
+import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
@@ -779,6 +780,14 @@ public final class DefinitionUtil
 
             ProducerMethodBean<?> newComponent = 
createProducerComponent(declaredMethod.getReturnType(), declaredMethod, 
component, isSpecializes);
 
+            if (component instanceof EnterpriseBeanMarker)
+            {
+                final OpenWebBeansEjbPlugin ejbPlugin = 
webBeansContext.getPluginLoader().getEjbPlugin();
+
+                Method method = ejbPlugin.resolveViewMethod(component, 
declaredMethod);
+                newComponent.setCreatorMethod(method);
+            }
+
             if (newComponent != null)
             {
                 producerComponents.add(newComponent);
@@ -939,17 +948,25 @@ public final class DefinitionUtil
                 }
             }
 
+            addMethodInjectionPointMetaData(component, declaredMethod);
+
+            if (component instanceof EnterpriseBeanMarker)
+            {
+                final OpenWebBeansEjbPlugin ejbPlugin = 
webBeansContext.getPluginLoader().getEjbPlugin();
+                declaredMethod = ejbPlugin.resolveViewMethod(component, 
declaredMethod);
+            }
+
+            pr.setDisposalMethod(declaredMethod);
+
             Method producerMethod = pr.getCreatorMethod();
+
             //Disposer methods and producer methods must be in the same class
             
if(!producerMethod.getDeclaringClass().getName().equals(declaredMethod.getDeclaringClass().getName()))
             {
                 throw new WebBeansConfigurationException("Producer method 
component of the disposal method : " + declaredMethod.getName() + " in class : "
                                                          + clazz.getName() + " 
must be in the same class!");
             }
-            
-            pr.setDisposalMethod(declaredMethod);
 
-            addMethodInjectionPointMetaData(component, declaredMethod);
 
         }
     }
@@ -1185,15 +1202,22 @@ public final class DefinitionUtil
             //Check for injected fields in EJB @Interceptors
             List<InterceptorData> stack = new ArrayList<InterceptorData>();
             
bean.getWebBeansContext().getEJBInterceptorConfig().configure(bean.getBeanClass(),
 stack);
-            for(InterceptorData data : stack)
+
+            final OpenWebBeansEjbPlugin ejbPlugin = 
bean.getWebBeansContext().getPluginLoader().getEjbPlugin();
+            final boolean isStateful = 
ejbPlugin.isStatefulBean(bean.getBeanClass());
+
+            if (isStateful)
             {
-                if(data.isDefinedInInterceptorClass())
+                for (InterceptorData data : stack)
                 {
-                    AnnotationManager annotationManager = 
WebBeansContext.getInstance().getAnnotationManager();
-                    
if(!annotationManager.checkInjectionPointForInterceptorPassivation(data.getInterceptorClass()))
+                    if (data.isDefinedInInterceptorClass())
                     {
-                        throw new WebBeansConfigurationException("Enterprise 
bean : " + bean.toString() +
-                                                                 " 
interceptors must have serializable injection points");
+                        AnnotationManager annotationManager = 
bean.getWebBeansContext().getAnnotationManager();
+                        if 
(!annotationManager.checkInjectionPointForInterceptorPassivation(data.getInterceptorClass()))
+                        {
+                            throw new 
WebBeansConfigurationException("Enterprise bean : " + bean.toString() +
+                                                                         " 
interceptors must have serializable injection points");
+                        }
                     }
                 }
             }

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/BeanInstanceBag.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/BeanInstanceBag.java?rev=1137328&r1=1137327&r2=1137328&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/BeanInstanceBag.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/BeanInstanceBag.java
 Sun Jun 19 10:02:59 2011
@@ -88,4 +88,10 @@ public class BeanInstanceBag<T> implemen
         
         return beanInstance; 
     }
+
+    @Override
+    public String toString()
+    {
+        return "Bag:" + beanCreationalContext + ", Instance: " + beanInstance;
+    }
 }

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=1137328&r1=1137327&r2=1137328&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
 Sun Jun 19 10:02:59 2011
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentMa
 
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.Decorator;
 import javax.enterprise.inject.spi.Interceptor;
 
@@ -387,4 +388,26 @@ public class CreationalContextImpl<T> im
         ejbInterceptors = (ConcurrentMap<Object, List<EjbInterceptorContext>>) 
s.readObject();
     }
 
+//    private static volatile int ids = 0;
+//    private final int id = ids++;
+
+    @Override
+    public String toString()
+    {
+
+        final String name;
+
+        if (contextual instanceof Bean)
+        {
+            Bean bean = (Bean) contextual;
+            name = bean.getBeanClass().getSimpleName();
+        }
+        else
+        {
+            name = "unknown";
+        }
+
+        return String.format("CreationalContext{name=%s}", name);
+//        return String.format("CreationalContext{id=%s, name=%s}", id, name);
+    }
 }

Modified: 
openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java?rev=1137328&r1=1137327&r2=1137328&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
 (original)
+++ 
openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
 Sun Jun 19 10:02:59 2011
@@ -641,4 +641,9 @@ public class EjbPlugin extends AbstractO
         return atNewEjb;
     }
 
+    public Method resolveViewMethod(javax.enterprise.inject.spi.Bean<?> bean, 
java.lang.reflect.Method method)
+    {
+        return method;
+    }
+
 }

Modified: 
openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/plugins/OpenWebBeansEjbPlugin.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/plugins/OpenWebBeansEjbPlugin.java?rev=1137328&r1=1137327&r2=1137328&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/plugins/OpenWebBeansEjbPlugin.java
 (original)
+++ 
openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/plugins/OpenWebBeansEjbPlugin.java
 Sun Jun 19 10:02:59 2011
@@ -21,6 +21,7 @@ package org.apache.webbeans.spi.plugins;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import java.lang.reflect.Method;
 
 /**
  * Session bean related plugin contract.
@@ -77,4 +78,6 @@ public interface OpenWebBeansEjbPlugin e
      * @return session bean proxy
      */
     public Object getSessionBeanProxy(Bean<?> bean, Class<?> iface, 
CreationalContext<?> creationalContext);
+
+    Method resolveViewMethod(Bean<?> component, Method declaredMethod);
 }
\ No newline at end of file


Reply via email to