openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1467909 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/creation/ProducerMethodBeansBuilder.java container/BeanManagerImpl.java portable/ProducerMethodProducer.java util/WebBeansUtil.java
Date Mon, 15 Apr 2013 09:08:01 GMT
Author: rmannibucau
Date: Mon Apr 15 09:08:01 2013
New Revision: 1467909

URL: http://svn.apache.org/r1467909
Log:
OWB-832 ejb view usage for ejb producers

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.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/component/creation/ProducerMethodBeansBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java?rev=1467909&r1=1467908&r2=1467909&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java
Mon Apr 15 09:08:01 2013
@@ -30,6 +30,7 @@ import javax.enterprise.inject.spi.Annot
 import javax.inject.Inject;
 
 import org.apache.webbeans.component.BeanAttributesImpl;
+import org.apache.webbeans.component.EnterpriseBeanMarker;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.config.WebBeansContext;
@@ -73,7 +74,10 @@ public class ProducerMethodBeansBuilder<
         
         for(AnnotatedMethod<? super T> annotatedMethod: annotatedMethods)
         {
-            if(annotatedMethod.isAnnotationPresent(Produces.class) && annotatedMethod.getDeclaringType().getJavaClass().equals(annotatedType.getJavaClass()))
+            boolean enterprise = EnterpriseBeanMarker.class.isInstance(bean);
+            if(annotatedMethod.isAnnotationPresent(Produces.class) &&
+                (annotatedMethod.getDeclaringType().getJavaClass().equals(annotatedType.getJavaClass())
+                || (enterprise && annotatedType.getJavaClass().isAssignableFrom(annotatedType.getJavaClass()))))
             {
                 checkProducerMethodForDeployment(annotatedMethod);
                 boolean specialize = false;

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=1467909&r1=1467908&r2=1467909&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
Mon Apr 15 09:08:01 2013
@@ -694,7 +694,7 @@ public class BeanManagerImpl implements 
         //Check type if bean type is given
         if(beanType != null)
         {
-            if(!isBeanTypeAssignableToGivenType(bean.getTypes(), beanType, bean instanceof
NewBean))
+            if(!isBeanTypeAssignableToGivenType(bean.getTypes(), beanType, bean instanceof
NewBean) && !ClassUtil.isAssignable(bean.getBeanClass(), beanType))
             {
                 throw new IllegalArgumentException("Given bean type : " + beanType + " is
not applicable for the bean instance : " + bean);
             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.java?rev=1467909&r1=1467908&r2=1467909&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.java
Mon Apr 15 09:08:01 2013
@@ -18,6 +18,8 @@
  */
 package org.apache.webbeans.portable;
 
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.util.Set;
 
 import javax.enterprise.context.spi.CreationalContext;
@@ -28,6 +30,7 @@ import javax.enterprise.inject.spi.Injec
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.inject.InjectableMethod;
+import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
 import org.apache.webbeans.util.Asserts;
 
 /**
@@ -38,8 +41,8 @@ public class ProducerMethodProducer<T, P
 
     private Bean<P> owner;
     private WebBeansContext webBeansContext;
-    private AnnotatedMethod<? super P> producerMethod;
-    private AnnotatedMethod<? super P> disposalMethod;
+    private Method producerMethod;
+    private Method disposalMethod;
 
     public ProducerMethodProducer(Bean<P> owner,
                                   AnnotatedMethod<? super P> producerMethod,
@@ -57,8 +60,24 @@ public class ProducerMethodProducer<T, P
         }
         this.owner = owner;
         this.webBeansContext = webBeansContext;
-        this.producerMethod = producerMethod;
-        this.disposalMethod = disposerMethod;
+
+        final OpenWebBeansEjbPlugin ejbPlugin = webBeansContext.getPluginLoader().getEjbPlugin();
+        if (ejbPlugin != null)
+        {
+            this.producerMethod = ejbPlugin.resolveViewMethod(owner, producerMethod.getJavaMember());
+            if (disposerMethod != null)
+            {
+                this.disposalMethod = ejbPlugin.resolveViewMethod(owner, disposerMethod.getJavaMember());
+            }
+        }
+        else
+        {
+            this.producerMethod = producerMethod.getJavaMember();
+            if (disposerMethod != null)
+            {
+                this.disposalMethod = disposerMethod.getJavaMember();
+            }
+        }
     }
 
     public void specializeBy(Bean<P> bean)
@@ -76,12 +95,12 @@ public class ProducerMethodProducer<T, P
         {
             parentCreationalContext = webBeansContext.getBeanManagerImpl().createCreationalContext(owner);
 
-            if (!producerMethod.isStatic())
+            if (!Modifier.isStatic(producerMethod.getModifiers()))
             {
                 parentInstance = (P)webBeansContext.getBeanManagerImpl().getReference(owner,
owner.getBeanClass(), parentCreationalContext);
             }
             
-            m = new InjectableMethod<T>(producerMethod.getJavaMember(), parentInstance,
this, (CreationalContextImpl<T>) creationalContext);
+            m = new InjectableMethod<T>(producerMethod, parentInstance, this, (CreationalContextImpl<T>)
creationalContext);
             
             return m.doInjection();
 
@@ -106,13 +125,13 @@ public class ProducerMethodProducer<T, P
             try
             {
                 parentCreationalContext = webBeansContext.getBeanManagerImpl().createCreationalContext(owner);
-                
-                if (!disposalMethod.isStatic())
+
+                if (!Modifier.isStatic(disposalMethod.getModifiers()))
                 {
                     parentInstance = (P)webBeansContext.getBeanManagerImpl().getReference(owner,
owner.getBeanClass(), parentCreationalContext);
                 }
 
-                m = new InjectableMethod<T>(disposalMethod.getJavaMember(), parentInstance,
this, (CreationalContextImpl<T>) parentCreationalContext);
+                m = new InjectableMethod<T>(disposalMethod, parentInstance, this, (CreationalContextImpl<T>)
parentCreationalContext);
                 m.setDisposable(true);
                 m.setProducerMethodInstance(instance);
 

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=1467909&r1=1467908&r2=1467909&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
Mon Apr 15 09:08:01 2013
@@ -696,7 +696,9 @@ public final class WebBeansUtil
 
                 if(!(candidate instanceof NewBean))
                 {
-                    if(candidate.getReturnType().equals(superClass))
+                    if(candidate.getReturnType().equals(superClass)
+                            || (EnterpriseBeanMarker.class.isInstance(candidate)
+                                && superClass.isAssignableFrom(candidate.getBeanClass())))
                     {
                         superBean = candidates;
                         break;
@@ -976,7 +978,7 @@ public final class WebBeansUtil
             }
 
             if (bean.getTypes().contains(clazz) ||
-                    (enterprise && bean.getBeanClass().equals(clazz)))
+                    (enterprise && clazz.isAssignableFrom(bean.getBeanClass())))
             {
                 if(annotate)
                 {



Mime
View raw message