openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1431276 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/WebBeansContext.java container/BeanManagerImpl.java container/ResolutionUtil.java
Date Thu, 10 Jan 2013 11:03:40 GMT
Author: struberg
Date: Thu Jan 10 11:03:39 2013
New Revision: 1431276

URL: http://svn.apache.org/viewvc?rev=1431276&view=rev
Log:
OWB-344 remove ResolutionUtil

Removed:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java?rev=1431276&r1=1431275&r2=1431276&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
Thu Jan 10 11:03:39 2013
@@ -27,7 +27,6 @@ import java.util.Properties;
 
 import org.apache.webbeans.annotation.AnnotationManager;
 import org.apache.webbeans.container.BeanManagerImpl;
-import org.apache.webbeans.container.ResolutionUtil;
 import org.apache.webbeans.container.SerializableBeanVault;
 import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.context.creational.CreationalContextFactory;
@@ -82,7 +81,6 @@ public class WebBeansContext
     private final SerializableBeanVault serializableBeanVault = new SerializableBeanVault();
     private final StereoTypeManager stereoTypeManager = new StereoTypeManager();
     private final AnnotationManager annotationManager = new AnnotationManager(this);
-    private final ResolutionUtil resolutionUtil = new ResolutionUtil(this);
     private final InjectionPointFactory injectionPointFactory = new InjectionPointFactory(this);
     private final InterceptorUtil interceptorUtil = new InterceptorUtil(this);
     private final SecurityService securityService;
@@ -230,11 +228,6 @@ public class WebBeansContext
         return injectionPointFactory;
     }
 
-    public ResolutionUtil getResolutionUtil()
-    {
-        return resolutionUtil;
-    }
-
     public WebBeansUtil getWebBeansUtil()
     {
         return webBeansUtil;

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=1431276&r1=1431275&r2=1431276&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
Thu Jan 10 11:03:39 2013
@@ -686,7 +686,7 @@ public class BeanManagerImpl implements 
         //Check type if bean type is given
         if(beanType != null)
         {
-            if(!webBeansContext.getResolutionUtil().checkBeanTypeAssignableToGivenType(bean.getTypes(),
beanType, bean instanceof NewBean))
+            if(!isBeanTypeAssignableToGivenType(bean.getTypes(), beanType, bean instanceof
NewBean))
             {
                 throw new IllegalArgumentException("Given bean type : " + beanType + " is
not applicable for the bean instance : " + bean);
             }
@@ -741,7 +741,37 @@ public class BeanManagerImpl implements 
         
         return instance;
     }
-    
+
+
+    private boolean isBeanTypeAssignableToGivenType(Set<Type> beanTypes, Type givenType,
boolean newBean)
+    {
+        Iterator<Type> itBeanApiTypes = beanTypes.iterator();
+        while (itBeanApiTypes.hasNext())
+        {
+            Type beanApiType = itBeanApiTypes.next();
+
+            if(ClassUtil.isAssignable(beanApiType, givenType))
+            {
+                return true;
+            }
+            else
+            {
+                //Check for @New
+                if(newBean && ClassUtil.isParametrizedType(givenType))
+                {
+                    Class<?> requiredType = ClassUtil.getClass(givenType);
+                    if(ClassUtil.isClassAssignable(requiredType, ClassUtil.getClass(beanApiType)))
+                    {
+                        return true;
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+
+
     private Object getEjbOrJmsProxyReference(Bean<?> bean,Type beanType, CreationalContext<?>
creationalContext)
     {
         //Create session bean proxy



Mime
View raw message