openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1468333 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/container/ webbeans-impl/src/main/java/org/apache/webbeans/util/ webbeans-spi/src/main/java/org/apache/webbeans/spi/plugins/
Date Tue, 16 Apr 2013 09:28:55 GMT
Author: rmannibucau
Date: Tue Apr 16 09:28:55 2013
New Revision: 1468333

URL: http://svn.apache.org/r1468333
Log:
OWB-842 @New for ejbs

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.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/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=1468333&r1=1468332&r2=1468333&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
Tue Apr 16 09:28:55 2013
@@ -510,7 +510,7 @@ public class InjectionResolver
         }
 
         // Look for qualifiers
-        resolvedComponents = findByQualifier(resolvedComponents, qualifiers);
+        resolvedComponents = findByQualifier(resolvedComponents, injectionPointType, qualifiers);
 
         // Ambigious resolution, check for specialization
         if (resolvedComponents.size() > 1)
@@ -720,7 +720,7 @@ public class InjectionResolver
      * @param annotations  qualifiers on injection point
      * @return filtered bean set according to the qualifiers
      */
-    private Set<Bean<?>> findByQualifier(Set<Bean<?>> remainingSet,
Annotation... annotations)
+    private Set<Bean<?>> findByQualifier(Set<Bean<?>> remainingSet,
Type type, Annotation... annotations)
     {
         Iterator<Bean<?>> it = remainingSet.iterator();
         Set<Bean<?>> result = new HashSet<Bean<?>>();
@@ -754,6 +754,11 @@ public class InjectionResolver
             }
         }
 
+        if (result.isEmpty() && annotations.length == 1 && New.class.equals(annotations[0].annotationType())
&& Class.class.isInstance(type))
+        { // happen in TCKs, shouldn't be the case in real apps
+            result.add(webBeansContext.getWebBeansUtil().createNewComponent(Class.class.cast(type)));
+        }
+
         return result;
     }
 }

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=1468333&r1=1468332&r2=1468333&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 Apr 16 09:28:55 2013
@@ -432,10 +432,16 @@ public final class WebBeansUtil
         return false;
     }
 
-    public <T> NewManagedBean<T> createNewComponent(Class<T> type)
+    public <T> Bean<T> createNewComponent(Class<T> type)
     {
         Asserts.nullCheckForClass(type);
 
+        final OpenWebBeansEjbPlugin ejbPlugin = webBeansContext.getPluginLoader().getEjbPlugin();
+        if (ejbPlugin != null && ejbPlugin.isNewSessionBean(type))
+        {
+            return ejbPlugin.defineNewSessionBean(type);
+        }
+
         AnnotatedType<T> annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(type);
         BeanAttributesImpl<T> defaultBeanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(annotatedType).build();
         BeanAttributesImpl<T> newBeanAttributes = new BeanAttributesImpl<T>(defaultBeanAttributes.getTypes(),
Collections.<Annotation>singleton(new NewLiteral(type)));

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=1468333&r1=1468332&r2=1468333&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
Tue Apr 16 09:28:55 2013
@@ -39,6 +39,14 @@ public interface OpenWebBeansEjbPlugin e
     public boolean isSessionBean(Class<?> clazz);
 
     /**
+     * return true is clazz is an impl class or business interface of an EJB
+     *
+     * @param clazz class definition
+     * @return true is clazz denotes an EJB
+     */
+    public boolean isNewSessionBean(Class<?> clazz);
+
+    /**
      * Configures session bean and adds it into the container.
      * 
      * @param clazz session bean class
@@ -46,6 +54,8 @@ public interface OpenWebBeansEjbPlugin e
      */
     public <T> Bean<T> defineSessionBean(Class<T> clazz, ProcessAnnotatedType<T>
processAnnotateTypeEvent);
 
+    public <T> Bean<T> defineNewSessionBean(Class<T> clazz);
+
     /**
      * Returns true if given class is singleton session bean, false otherwise.
      * 



Mime
View raw message