You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by db...@apache.org on 2011/01/20 05:47:02 UTC

svn commit: r1061122 [3/4] - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/ webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/ webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/p...

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java?rev=1061122&r1=1061121&r2=1061122&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java Thu Jan 20 04:46:59 2011
@@ -28,6 +28,7 @@ import javax.interceptor.AroundInvoke;
 import javax.interceptor.AroundTimeout;
 import javax.interceptor.Interceptors;
 
+import org.apache.webbeans.component.AbstractInjectionTargetBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.intercept.InterceptorData;
 import org.apache.webbeans.intercept.InterceptorUtil;
@@ -38,26 +39,37 @@ import org.apache.webbeans.util.Security
 
 /**
  * Configures the EJB related interceptors.
- * 
+ *
  * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
  * @since 1.0
  */
 public final class EJBInterceptorConfig
 {
-    /*
-     * Private constructor
-     */
-    private EJBInterceptorConfig()
+
+    private final WebBeansContext webBeansContext;
+
+    public EJBInterceptorConfig(WebBeansContext webBeansContext)
     {
+        this.webBeansContext = webBeansContext;
+    }
 
+    /**
+     * Configures the given class for applicable interceptors.
+     *
+     * @param component
+     * @param clazz configuration interceptors for this
+     */
+    public static void configure(Class<?> clazz, List<InterceptorData> stack, AbstractInjectionTargetBean<?> component)
+    {
+        new EJBInterceptorConfig(component.getWebBeansContext())._configure(clazz, stack);
     }
 
     /**
      * Configures the given class for applicable interceptors.
-     * 
+     *
      * @param clazz configuration interceptors for this
      */
-    public static void configure(Class<?> clazz, List<InterceptorData> stack)
+    public void _configure(Class<?> clazz, List<InterceptorData> stack)
     {
         Asserts.nullCheckForClass(clazz);
 
@@ -68,15 +80,15 @@ public final class EJBInterceptorConfig
 
             for (Class<?> intClass : intClasses)
             {
-                configureInterceptorAnnots(intClass, stack, false, null);
+                _configureInterceptorAnnots(intClass, stack, false, null);
             }
 
         }
-        configureBeanAnnots(clazz, stack);
+        _configureBeanAnnots(clazz, stack);
         InterceptorUtil.filterOverridenLifecycleInterceptor(clazz, stack);
-        
+
     }
-    
+
     /**
      * Configure {@link Interceptors} on bean class.
      * @param clazz bean class
@@ -84,34 +96,33 @@ public final class EJBInterceptorConfig
      * @param isMethod if interceptor definition is on the bean
      * @param m if isMethod true, then it is intercepted method
      */
-    private static void configureInterceptorAnnots(Class<?> clazz, List<InterceptorData> stack, boolean isMethod, Method m)
+    private void _configureInterceptorAnnots(Class<?> clazz, List<InterceptorData> stack, boolean isMethod, Method m)
     {
-        WebBeansContext webBeansContext = WebBeansContext.getInstance();
         // 1- Look interceptor class super class
         // 2- Look interceptor class
         Class<?> superClass = clazz.getSuperclass();
         if (superClass != null && !superClass.equals(Object.class))
         {
-            configureInterceptorAnnots(superClass, stack, false, null);
+            _configureInterceptorAnnots(superClass, stack, false, null);
         }
 
-        webBeansContext.getWebBeansUtil()._configureInterceptorMethods(null, clazz, AroundInvoke.class,
+        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, clazz, AroundInvoke.class,
                                                                                      true, isMethod, stack, m, false);
-        webBeansContext.getWebBeansUtil()._configureInterceptorMethods(null, clazz, AroundTimeout.class,
+        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, clazz, AroundTimeout.class,
                                                                                      true, isMethod, stack, m, false);
-        webBeansContext.getWebBeansUtil()._configureInterceptorMethods(null, clazz, PostConstruct.class,
+        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, clazz, PostConstruct.class,
                                                                                      true, isMethod, stack, m, false);
-        webBeansContext.getWebBeansUtil()._configureInterceptorMethods(null, clazz, PreDestroy.class,
+        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, clazz, PreDestroy.class,
                                                                                      true, isMethod, stack, m, false);
 
     }
-    
+
     /**
      * Configure bean class defined interceptors.
      * @param clazz bean class
      * @param stack interceptor stack
      */
-    private static void configureBeanAnnots(Class<?> clazz, List<InterceptorData> stack)
+    private void _configureBeanAnnots(Class<?> clazz, List<InterceptorData> stack)
     {
         // 1- Look method intercepor class annotations
         // 2- Look super class around invoke
@@ -129,7 +140,7 @@ public final class EJBInterceptorConfig
 
                 for (Class<?> intClass : intClasses)
                 {
-                    configureInterceptorAnnots(intClass, stack, true, method);
+                    _configureInterceptorAnnots(intClass, stack, true, method);
                 }
 
             }
@@ -137,46 +148,44 @@ public final class EJBInterceptorConfig
 
         // 2- Super clazz
         List<Class<?>> listSuperClazz = ClassUtil.getSuperClasses(clazz, new ArrayList<Class<?>>());
-        configureBeanSuperClassAnnots(listSuperClazz, stack);
+        _configureBeanSuperClassAnnots(listSuperClazz, stack);
 
         // 3- Bean itself
-        WebBeansContext webBeansContext = WebBeansContext.getInstance();
-        webBeansContext.getWebBeansUtil()._configureInterceptorMethods(null, clazz, AroundInvoke.class,
+        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, clazz, AroundInvoke.class,
                                                                                      false, false, stack, null, false);
-        webBeansContext.getWebBeansUtil()._configureInterceptorMethods(null, clazz, AroundTimeout.class,
+        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, clazz, AroundTimeout.class,
                                                                                      false, false, stack, null, false);
-        webBeansContext.getWebBeansUtil()._configureInterceptorMethods(null, clazz, PostConstruct.class,
+        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, clazz, PostConstruct.class,
                                                                                      false, false, stack, null, false);
-        webBeansContext.getWebBeansUtil()._configureInterceptorMethods(null, clazz, PreDestroy.class,
+        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, clazz, PreDestroy.class,
                                                                                      false, false, stack, null, false);
 
     }
-    
+
     /**
      * Configures super classes interceptors.
      * @param list super classes
      * @param stack interceptor stack
      */
-    private static void configureBeanSuperClassAnnots(List<Class<?>> list, List<InterceptorData> stack)
+    private void _configureBeanSuperClassAnnots(List<Class<?>> list, List<InterceptorData> stack)
     {
         int i = list.size();
-        WebBeansContext webBeansContext = WebBeansContext.getInstance();
 
         for (int j = i - 1; j >= 0; j--)
         {
             Class<?> clazz = list.get(j);
             if (!clazz.equals(Object.class))
             {
-                webBeansContext.getWebBeansUtil()._configureInterceptorMethods(null, clazz,
+                webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, clazz,
                                                                                              AroundInvoke.class, false,
                                                                                              false, stack, null, false);
-                webBeansContext.getWebBeansUtil()._configureInterceptorMethods(null, clazz,
+                webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, clazz,
                                                                                              AroundTimeout.class, false,
                                                                                              false, stack, null, false);
-                webBeansContext.getWebBeansUtil()._configureInterceptorMethods(null, clazz,
+                webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, clazz,
                                                                                              PostConstruct.class, false,
                                                                                              false, stack, null, false);
-                webBeansContext.getWebBeansUtil()._configureInterceptorMethods(null, clazz,
+                webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, clazz,
                                                                                              PreDestroy.class, false,
                                                                                              false, stack, null, false);
             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=1061122&r1=1061121&r2=1061122&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java Thu Jan 20 04:46:59 2011
@@ -83,12 +83,12 @@ public class WebBeansInterceptor<T> exte
 
     public WebBeansInterceptor(AbstractInjectionTargetBean<T> delegateBean)
     {
-        super(WebBeansType.INTERCEPTOR,delegateBean.getReturnType());
+        super(WebBeansType.INTERCEPTOR,delegateBean.getReturnType(), delegateBean.getWebBeansContext());
         
         this.delegateBean = delegateBean;
         this.clazz = getDelegate().getReturnType();
 
-        webBeansContext = WebBeansContext.getInstance();
+        webBeansContext = delegateBean.getWebBeansContext();
     }
 
     public AbstractOwbBean<T> getDelegate()
@@ -217,7 +217,7 @@ public class WebBeansInterceptor<T> exte
             if (anns != null && anns.length > 0)
             {
                 // For example : @Transactional @Action Interceptor
-                Set<Interceptor<?>> metas = WebBeansInterceptorConfig.findDeployedWebBeansInterceptor(anns);
+                Set<Interceptor<?>> metas = WebBeansInterceptorConfig.findDeployedWebBeansInterceptor(anns, webBeansContext);
                 set.addAll(metas);
 
                 // For each @Transactional and @Action Interceptor
@@ -225,7 +225,7 @@ public class WebBeansInterceptor<T> exte
                 {
                     Annotation[] simple = new Annotation[1];
                     simple[0] = ann;
-                    metas = WebBeansInterceptorConfig.findDeployedWebBeansInterceptor(simple);
+                    metas = WebBeansInterceptorConfig.findDeployedWebBeansInterceptor(simple, webBeansContext);
                     set.addAll(metas);
                 }
 
@@ -278,7 +278,7 @@ public class WebBeansInterceptor<T> exte
         else
         {
             Class<? extends Annotation> interceptorTypeAnnotationClazz = InterceptorUtil.getInterceptorAnnotationClazz(type);
-            method = getWebBeansContext().getWebBeansUtil()._checkCommonAnnotationCriterias(getClazz(),
+            method = getWebBeansContext().getWebBeansUtil().checkCommonAnnotationCriterias(getClazz(),
                                                                                                      interceptorTypeAnnotationClazz,
                                                                                                      true);
         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java?rev=1061122&r1=1061121&r2=1061122&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java Thu Jan 20 04:46:59 2011
@@ -159,7 +159,9 @@ public abstract class AbstractLifeCycle 
             webBeansContext.getExtensionLoader().clear();
             
             //Delete Resolutions Cache
-            InjectionResolver.getInstance().clearCaches();
+            InjectionResolver injectionResolver = webBeansContext.getBeanManagerImpl().getInjectionResolver();
+
+            injectionResolver.clearCaches();
             
             //Delte proxies
             webBeansContext.getJavassistProxyFactory().clear();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/AbstractProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/AbstractProducer.java?rev=1061122&r1=1061121&r2=1061122&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/AbstractProducer.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/AbstractProducer.java Thu Jan 20 04:46:59 2011
@@ -25,7 +25,6 @@ import javax.enterprise.inject.spi.Injec
 import javax.enterprise.inject.spi.Producer;
 
 import org.apache.webbeans.component.OwbBean;
-import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 
 /**
@@ -72,7 +71,7 @@ public abstract class AbstractProducer<T
         T instance = null;
         if(!(creationalContext instanceof CreationalContextImpl))
         {
-            creationalContext = WebBeansContext.getInstance().getCreationalContextFactory().wrappedCreationalContext(creationalContext, this.bean);
+            creationalContext = bean.getWebBeansContext().getCreationalContextFactory().wrappedCreationalContext(creationalContext, this.bean);
         }
         
         //Save it

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/DefaultInjectionTargetImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/DefaultInjectionTargetImpl.java?rev=1061122&r1=1061121&r2=1061122&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/DefaultInjectionTargetImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/DefaultInjectionTargetImpl.java Thu Jan 20 04:46:59 2011
@@ -25,7 +25,7 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.InjectionTarget;
 
-import org.apache.webbeans.util.WebBeansAnnotatedTypeUtil;
+import org.apache.webbeans.config.WebBeansContext;
 
 public class DefaultInjectionTargetImpl<T> implements InjectionTarget<T>
 {
@@ -33,7 +33,7 @@ public class DefaultInjectionTargetImpl<
     
     public DefaultInjectionTargetImpl(AnnotatedType<T> annotatedType)
     {
-        target = new InjectionTargetProducer<T>(WebBeansAnnotatedTypeUtil.defineManagedBean(annotatedType));
+        target = new InjectionTargetProducer<T>(WebBeansContext.getInstance().getWebBeansUtil().defineManagedBean(annotatedType));
     }
 
     @Override

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducer.java?rev=1061122&r1=1061121&r2=1061122&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducer.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducer.java Thu Jan 20 04:46:59 2011
@@ -25,7 +25,6 @@ import javax.enterprise.inject.spi.Injec
 
 import org.apache.webbeans.component.EnterpriseBeanMarker;
 import org.apache.webbeans.component.InjectionTargetBean;
-import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.inject.AbstractInjectable;
 import org.apache.webbeans.proxy.JavassistProxyFactory;
@@ -57,7 +56,7 @@ public class InjectionTargetProducer<T> 
     {
         if(!(ctx instanceof CreationalContextImpl))
         {
-            ctx = WebBeansContext.getInstance().getCreationalContextFactory().wrappedCreationalContext(ctx, this.bean);
+            ctx = bean.getWebBeansContext().getCreationalContextFactory().wrappedCreationalContext(ctx, this.bean);
         }
         
         Object oldInstanceUnderInjection = AbstractInjectable.instanceUnderInjection.get();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java?rev=1061122&r1=1061121&r2=1061122&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java Thu Jan 20 04:46:59 2011
@@ -48,6 +48,8 @@ public class ExtensionLoader
     private final Set<Class<? extends Extension>> extensionClasses = new HashSet<Class<? extends Extension>>();
     private final BeanManagerImpl manager;
 
+    private final WebBeansContext webBeansContext;
+
     /**
      * Creates a new loader instance.
      * @param webBeansContext
@@ -55,7 +57,8 @@ public class ExtensionLoader
     public ExtensionLoader(WebBeansContext webBeansContext)
     {
 
-        manager = webBeansContext.getBeanManagerImpl();
+        this.webBeansContext = webBeansContext;
+        manager = this.webBeansContext.getBeanManagerImpl();
     }
 
     /**
@@ -120,7 +123,7 @@ public class ExtensionLoader
      */
     public void addExtension(Extension ext)
     {
-        Bean<?> bean = WebBeansUtil.createExtensionComponent(ext.getClass());
+        Bean<?> bean = webBeansContext.getWebBeansUtil().createExtensionComponent(ext.getClass());
         this.extensions.put(bean, ext);
 
         manager.addBean(bean);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java?rev=1061122&r1=1061121&r2=1061122&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java Thu Jan 20 04:46:59 2011
@@ -53,10 +53,10 @@ public class AfterBeanDiscoveryImpl impl
     private static final WebBeansLogger logger = WebBeansLogger.getLogger(AfterBeanDiscoveryImpl.class);
     private final WebBeansContext webBeansContext;
 
-    public AfterBeanDiscoveryImpl()
+    public AfterBeanDiscoveryImpl(WebBeansContext webBeansContext)
     {
-        webBeansContext = WebBeansContext.getInstance();
-        this.beanManager = webBeansContext.getBeanManagerImpl();
+        this.webBeansContext = webBeansContext;
+        this.beanManager = this.webBeansContext.getBeanManagerImpl();
     }
     
     /**
@@ -76,7 +76,7 @@ public class AfterBeanDiscoveryImpl impl
         {
             //Required for custom interceptors
             ManagedBean managedBean =
-                webBeansContext.getWebBeansUtil()._defineManagedBeanWithoutFireEvents(
+                webBeansContext.getWebBeansUtil().defineManagedBeanWithoutFireEvents(
                     (AnnotatedType<?>) annotatedType);
             
             CustomInterceptor<?> interceptor = new CustomInterceptor(managedBean, (Interceptor<?>)bean);
@@ -112,7 +112,7 @@ public class AfterBeanDiscoveryImpl impl
         {
             //Required for custom decorators
             ManagedBean managedBean =
-                webBeansContext.getWebBeansUtil()._defineManagedBeanWithoutFireEvents(
+                webBeansContext.getWebBeansUtil().defineManagedBeanWithoutFireEvents(
                     (AnnotatedType<?>) annotatedType);
             if(managedBean.getScope() != Dependent.class)
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java?rev=1061122&r1=1061121&r2=1061122&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java Thu Jan 20 04:46:59 2011
@@ -20,7 +20,7 @@ package org.apache.webbeans.portable.eve
 
 import javax.enterprise.inject.spi.AfterDeploymentValidation;
 
-import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.BeanManagerImpl;
 
 /**
  * Event that is fired by the container after it validates
@@ -31,13 +31,20 @@ import org.apache.webbeans.config.WebBea
  */
 public class AfterDeploymentValidationImpl implements AfterDeploymentValidation
 {
+    private final BeanManagerImpl beanManagerImpl;
+
+    public AfterDeploymentValidationImpl(BeanManagerImpl beanManagerImpl)
+    {
+        this.beanManagerImpl = beanManagerImpl;
+    }
+
     /**
      * {@inheritDoc}
      */
     @Override
     public void addDeploymentProblem(Throwable t)
     {
-        WebBeansContext.getInstance().getBeanManagerImpl().getErrorStack().pushError(t);
+        beanManagerImpl.getErrorStack().pushError(t);
     }
 
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java?rev=1061122&r1=1061121&r2=1061122&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java Thu Jan 20 04:46:59 2011
@@ -40,10 +40,10 @@ public class BeforeBeanDiscoveryImpl imp
     private BeanManagerImpl beanManager = null;
     private final WebBeansContext webBeansContext;
 
-    public BeforeBeanDiscoveryImpl()
+    public BeforeBeanDiscoveryImpl(WebBeansContext webBeansContext)
     {
-        webBeansContext = WebBeansContext.getInstance();
-        beanManager = webBeansContext.getBeanManagerImpl();
+        this.webBeansContext = webBeansContext;
+        beanManager = this.webBeansContext.getBeanManagerImpl();
     }
     
     /**
@@ -93,7 +93,7 @@ public class BeforeBeanDiscoveryImpl imp
         if (!webBeansContext.getxMLAnnotationTypeManager().hasStereoType(stereotype))
         {
             webBeansContext.getAnnotationManager().checkStereoTypeClass(stereotype, stereotypeDef);
-            StereoTypeModel model = new StereoTypeModel(stereotype, stereotypeDef);
+            StereoTypeModel model = new StereoTypeModel(webBeansContext, stereotype, stereotypeDef);
             webBeansContext.getStereoTypeManager().addStereoTypeModel(model);
         }
         

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java?rev=1061122&r1=1061121&r2=1061122&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java Thu Jan 20 04:46:59 2011
@@ -31,18 +31,13 @@ import org.apache.webbeans.component.Res
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.component.creation.AnnotatedTypeBeanCreatorImpl;
 import org.apache.webbeans.config.DefinitionUtil;
-import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.InjectionResolver;
-import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.inject.impl.InjectionPointFactory;
-import org.apache.webbeans.intercept.InterceptorUtil;
-import org.apache.webbeans.intercept.WebBeansInterceptorConfig;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.spi.api.ResourceReference;
 
-import javax.decorator.Decorator;
 import javax.decorator.Delegate;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.event.Observes;
@@ -60,7 +55,6 @@ import javax.enterprise.inject.spi.Injec
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.inject.Inject;
 import javax.inject.Named;
-import javax.interceptor.Interceptor;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -150,7 +144,8 @@ public final class WebBeansAnnotatedType
     
     public static <T> void addConstructorInjectionPointMetaData(AbstractOwbBean<T> owner, AnnotatedConstructor<T> constructor)
     {
-        List<InjectionPoint> injectionPoints = InjectionPointFactory.getConstructorInjectionPointData(owner, constructor);
+        InjectionPointFactory injectionPointFactory = owner.getWebBeansContext().getInjectionPointFactory();
+        List<InjectionPoint> injectionPoints = injectionPointFactory.getConstructorInjectionPointData(owner, constructor);
         for (InjectionPoint injectionPoint : injectionPoints)
         {
             DefinitionUtil.addImplicitComponentForInjectionPoint(injectionPoint);
@@ -160,7 +155,7 @@ public final class WebBeansAnnotatedType
     
     public static <T,X> void addMethodInjectionPointMetaData(OwbBean<T> owner, AnnotatedMethod<X> method)
     {
-        List<InjectionPoint> injectionPoints = InjectionPointFactory.getMethodInjectionPointData(owner, method);
+        List<InjectionPoint> injectionPoints = owner.getWebBeansContext().getInjectionPointFactory().getMethodInjectionPointData(owner, method);
         for (InjectionPoint injectionPoint : injectionPoints)
         {
             DefinitionUtil.addImplicitComponentForInjectionPoint(injectionPoint);
@@ -170,7 +165,7 @@ public final class WebBeansAnnotatedType
     
     public static <T,X> void addFieldInjectionPointMetaData(AbstractOwbBean<T> owner, AnnotatedField<X> annotField)
     {
-        owner.addInjectionPoint(InjectionPointFactory.getFieldInjectionPointData(owner, annotField));        
+        owner.addInjectionPoint(owner.getWebBeansContext().getInjectionPointFactory().getFieldInjectionPointData(owner, annotField));
     }
     
     @SuppressWarnings("unchecked")
@@ -254,7 +249,9 @@ public final class WebBeansAnnotatedType
                 Type type = AnnotationUtil.getAnnotatedMethodFirstParameterWithAnnotation(annotatedMethod, Disposes.class);
                 Annotation[] annot = annotationManager.getAnnotatedMethodFirstParameterQualifierWithGivenAnnotation(annotatedMethod, Disposes.class);
 
-                Set<Bean<?>> set = InjectionResolver.getInstance().implResolveByType(type, annot);
+                InjectionResolver injectionResolver = bean.getWebBeansContext().getBeanManagerImpl().getInjectionResolver();
+
+                Set<Bean<?>> set = injectionResolver.implResolveByType(type, annot);
                 if (set.isEmpty())
                 {
                     throwUnsatisfiedResolutionException(type, declaredMethod, annot);
@@ -451,13 +448,13 @@ public final class WebBeansAnnotatedType
                     
                     DefinitionUtil.defineSerializable(producerFieldBean);
                     DefinitionUtil.defineStereoTypes(producerFieldBean, anns);
-                    webBeansContext.getWebBeansUtil()._setBeanEnableFlagForProducerBean(bean,
+                    webBeansContext.getWebBeansUtil().setBeanEnableFlagForProducerBean(bean,
                                                                                                       producerFieldBean,
                                                                                                       anns);
                     Set<Type> types = annotatedField.getTypeClosure();
                     producerFieldBean.getTypes().addAll(types);
                     DefinitionUtil.defineScopeType(producerFieldBean, anns, "Annotated producer field: " + annotatedField +  "must declare default @Scope annotation");
-                    webBeansContext.getWebBeansUtil()._checkUnproxiableApiType(producerFieldBean,
+                    webBeansContext.getWebBeansUtil().checkUnproxiableApiType(producerFieldBean,
                                                                                              producerFieldBean.getScope());
                     WebBeansUtil.checkProducerGenericType(producerFieldBean,annotatedField.getJavaMember());
                     DefinitionUtil.defineQualifiers(producerFieldBean, anns);
@@ -511,7 +508,7 @@ public final class WebBeansAnnotatedType
                 
                 DefinitionUtil.defineSerializable(producerMethodBean);
                 DefinitionUtil.defineStereoTypes(producerMethodBean, AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()));
-                webBeansContext.getWebBeansUtil()._setBeanEnableFlagForProducerBean(bean,
+                webBeansContext.getWebBeansUtil().setBeanEnableFlagForProducerBean(bean,
                                                                                                   producerMethodBean,
                                                                                                   AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()));
 
@@ -520,7 +517,7 @@ public final class WebBeansAnnotatedType
                 DefinitionUtil.defineScopeType(producerMethodBean,
                                                AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()),
                                                                                     "Annotated producer method : " + annotatedMethod +  "must declare default @Scope annotation");
-                webBeansContext.getWebBeansUtil()._checkUnproxiableApiType(producerMethodBean,
+                webBeansContext.getWebBeansUtil().checkUnproxiableApiType(producerMethodBean,
                                                                                          producerMethodBean.getScope());
                 WebBeansUtil.checkProducerGenericType(producerMethodBean,annotatedMethod.getJavaMember());
                 DefinitionUtil.defineQualifiers(producerMethodBean, AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()));
@@ -694,108 +691,15 @@ public final class WebBeansAnnotatedType
                                                      + clazz.getName() + " can not annotated with annotation @Disposes");
         }                
     }
-     
-    /**
-     * Checks the implementation class for checking conditions.
-     * 
-     * @param type implementation class
-     * @throws WebBeansConfigurationException if any configuration exception occurs
-     */
-    public static <X> void checkManagedBeanCondition(AnnotatedType<X> type) throws WebBeansConfigurationException
-    {        
-        int modifier = type.getJavaClass().getModifiers();
-
-        if (type.isAnnotationPresent(Decorator.class) && type.isAnnotationPresent(Interceptor.class))
-        {
-            throw new WebBeansConfigurationException("Annotated type "+ type +  " may not annotated with both @Interceptor and @Decorator annotation");
-        }
-
-        if (!type.isAnnotationPresent(Decorator.class) && !type.isAnnotationPresent(Interceptor.class))
-        {
-            checkManagedWebBeansInterceptorConditions(type);
-        }
-
-        if (ClassUtil.isInterface(modifier))
-        {
-            throw new WebBeansConfigurationException("ManagedBean implementation class : " + type.getJavaClass().getName() + " may not defined as interface");
-        }
-    }
-    
-    public static <X> void checkManagedWebBeansInterceptorConditions(AnnotatedType<X> type)
-    {
-        Annotation[] anns = AnnotationUtil.getAnnotationsFromSet(type.getAnnotations());
 
-        Class<?> clazz = type.getJavaClass();
-        boolean hasClassInterceptors = false;
-        AnnotationManager annotationManager = WebBeansContext.getInstance().getAnnotationManager();
-        if (annotationManager.getInterceptorBindingMetaAnnotations(anns).length > 0)
-        {
-            hasClassInterceptors = true;
-        }
-        else
-        {
-            Annotation[] stereoTypes = annotationManager.getStereotypeMetaAnnotations(anns);
-            for (Annotation stero : stereoTypes)
-            {
-                if (annotationManager.hasInterceptorBindingMetaAnnotation(stero.annotationType().getDeclaredAnnotations()))
-                {
-                    hasClassInterceptors = true;
-                    break;
-                }
-            }
-        }
-         
-        if(ClassUtil.isFinal(clazz.getModifiers()) && hasClassInterceptors)
-        {
-            throw new WebBeansConfigurationException("Final managed bean class with name : " + clazz.getName() + " can not define any InterceptorBindings");
-        }
-        
-        Set<AnnotatedMethod<? super X>> methods = type.getMethods();
-        for(AnnotatedMethod<? super X> methodA : methods)
-        {
-            Method method = methodA.getJavaMember(); 
-            int modifiers = method.getModifiers();
-            if (!ClassUtil.isStatic(modifiers) && !ClassUtil.isPrivate(modifiers) && ClassUtil.isFinal(modifiers))
-            {
-                if (hasClassInterceptors)
-                {
-                    throw new WebBeansConfigurationException("Maanged bean class : " + clazz.getName()
-                                                    + " can not define non-static, non-private final methods. Because it is annotated with at least one @InterceptorBinding");
-                }
-
-                if (annotationManager.hasInterceptorBindingMetaAnnotation(
-                    AnnotationUtil.getAnnotationsFromSet(methodA.getAnnotations())))
-                {
-                    throw new WebBeansConfigurationException("Method : " + method.getName() + "in managed bean class : " + clazz.getName()
-                                                    + " can not be defined as non-static, non-private and final . Because it is annotated with at least one @InterceptorBinding");
-                }
-            }
-            
-        }
-    }
-    
-    @SuppressWarnings("unchecked")
-    public static <T> ManagedBean<T> defineAbstractDecorator(AnnotatedType<T> type)
-    {
-        
-        ManagedBean<T> bean = defineManagedBean(type);
-
-        //X TODO move proxy instance creation into JavassistProxyFactory!
-        Class clazz = WebBeansContext.getInstance().getJavassistProxyFactory().createAbstractDecoratorProxyClass(bean);
-
-        bean.setConstructor(WebBeansUtil.defineConstructor(clazz));
-        bean.setIsAbstractDecorator(true);
-        return bean;
-    }
-    
     /**
      * Gets injection points for the given javaee component annotated type.
-     * @param <T> component class type
-     * @param type annotated type for the class
-     * @return injection points of the java ee component class
+     * @param webBeansContext
+     *@param type annotated type for the class  @return injection points of the java ee component class
      * @throws IllegalArgumentException if any exception occurs
      */
-    public static <T> Set<InjectionPoint> getJavaEeComponentInstanceInjectionPoints(AnnotatedType<T> type) throws IllegalArgumentException
+    public static <T> Set<InjectionPoint> getJavaEeComponentInstanceInjectionPoints(WebBeansContext webBeansContext,
+                                                                                    AnnotatedType<T> type) throws IllegalArgumentException
     {
         try
         {
@@ -809,7 +713,7 @@ public final class WebBeansAnnotatedType
                 Class<T> clazz = type.getJavaClass();
                 
                 //Just creating temporary for getting injected fields
-                ManagedBean<T> managedBean = new ManagedBean<T>(clazz,WebBeansType.MANAGED);    
+                ManagedBean<T> managedBean = new ManagedBean<T>(clazz,WebBeansType.MANAGED, webBeansContext);
                 managedBean.setAnnotatedType(type);
                             
                 AnnotatedTypeBeanCreatorImpl<T> managedBeanCreator = new AnnotatedTypeBeanCreatorImpl<T>(managedBean);            
@@ -830,181 +734,7 @@ public final class WebBeansAnnotatedType
             throw new IllegalArgumentException(message, e);
         }
     }
-    
-    public static <T> ManagedBean<T>  defineManagedBean(AnnotatedType<T> type)
-    {
-        Class<T> clazz = type.getJavaClass();
-        
-        ManagedBean<T> managedBean = new ManagedBean<T>(clazz,WebBeansType.MANAGED);    
-        managedBean.setAnnotatedType(type);
-        AnnotatedTypeBeanCreatorImpl<T> managedBeanCreator = new AnnotatedTypeBeanCreatorImpl<T>(managedBean);            
-        managedBeanCreator.setAnnotatedType(type);
-        
-        managedBeanCreator.defineSerializable();
-
-        //Define meta-data
-        managedBeanCreator.defineStereoTypes();
-
-        //Scope type
-        managedBeanCreator.defineScopeType(logger.getTokenString(OWBLogConst.TEXT_MB_IMPL) + clazz.getName()
-                                           + logger.getTokenString(OWBLogConst.TEXT_SAME_SCOPE));                                        
-        //Check for Enabled via Alternative
-        WebBeansContext.getInstance().getWebBeansUtil()._setInjectionTargetBeanEnableFlag(managedBean);
-        managedBeanCreator.defineApiType();
-        managedBeanCreator.checkCreateConditions();
-        managedBeanCreator.defineQualifier();
-        managedBeanCreator.defineName(WebBeansUtil.getManagedBeanDefaultName(clazz.getSimpleName()));
-        managedBeanCreator.defineConstructor();            
-        managedBeanCreator.defineProducerMethods();       
-        managedBeanCreator.defineProducerFields();           
-        managedBeanCreator.defineInjectedFields();
-        managedBeanCreator.defineInjectedMethods();
-        managedBeanCreator.defineObserverMethods();
-        DefinitionUtil.defineDecoratorStack(managedBean);
-        DefinitionUtil.defineBeanInterceptorStack(managedBean);
-                                        
-        managedBeanCreator.defineDisposalMethods();//Define disposal method after adding producers
-        
-        return managedBean;
-    }
-    
-    /**
-     * Return true if this annotated type represents a decorator.
-     * @param annotatedType annotated type
-     * @return true if decorator
-     */
-    public static boolean isAnnotatedTypeDecorator(AnnotatedType<?> annotatedType)
-    {
-        if(annotatedType.isAnnotationPresent(Decorator.class))
-        {
-            return true;
-        }
-        
-        return false;
-    }
-    
-    /**
-     * Return true if this annotated type represents a decorator.
-     * @param annotatedType annotated type
-     * @return true if decorator
-     */
-    public static boolean isAnnotatedTypeDecoratorOrInterceptor(AnnotatedType<?> annotatedType)
-    {
-        if(isAnnotatedTypeDecorator(annotatedType) ||
-                isAnnotatedTypeInterceptor(annotatedType))            
-        {
-            return true;
-        }
-        else if(WebBeansContext.getInstance().getInterceptorsManager().isInterceptorEnabled(annotatedType.getJavaClass()))
-        {
-            return true;
-        }
-        else if(WebBeansContext.getInstance().getDecoratorsManager().isDecoratorEnabled(annotatedType.getJavaClass()))
-        {
-            return true;
-        }
-
-        
-        return false;
-    }
-    
-    
-    /**
-     * Return true if this annotated type represents a decorator.
-     * @param annotatedType annotated type
-     * @return true if decorator
-     */
-    public static boolean isAnnotatedTypeInterceptor(AnnotatedType<?> annotatedType)
-    {
-        if(annotatedType.isAnnotationPresent(Interceptor.class))
-        {
-            return true;
-        }
-        
-        return false;
-    }
-    
-    
-    /**
-     * Define decorator bean.
-     * @param <T> type info
-     * @param annotatedType decorator class
-     */
-    public static <T> void defineDecorator(AnnotatedType<T> annotatedType)
-    {
-        if (WebBeansContext.getInstance().getDecoratorsManager().isDecoratorEnabled(annotatedType.getJavaClass()))
-        {
-            ManagedBean<T> delegate = null;
-            
-            Set<AnnotatedMethod<? super T>> methods = annotatedType.getMethods();
-            for(AnnotatedMethod<? super T> methodA : methods)
-            {
-                Method method = methodA.getJavaMember();
-                if(AnnotationUtil.hasMethodAnnotation(method, Produces.class))
-                {
-                    throw new WebBeansConfigurationException("Decorator class : " + annotatedType.getJavaClass() + " can not have producer methods but it has one with name : "
-                                                             + method.getName());
-                }
-                
-                if(AnnotationUtil.hasMethodParameterAnnotation(method, Observes.class))
-                {
-                    throw new WebBeansConfigurationException("Decorator class : " + annotatedType.getJavaClass() + " can not have observer methods but it has one with name : "
-                                                             + method.getName());
-                }
-                
-            }
-            
-            if(Modifier.isAbstract(annotatedType.getJavaClass().getModifiers()))
-            {
-                delegate = defineAbstractDecorator(annotatedType);
-            } 
-            else 
-            {
-                delegate = defineManagedBean(annotatedType);
-            }
 
-            if (delegate != null)
-            {
-                WebBeansDecoratorConfig.configureDecoratorClass(delegate);
-            }
-            else
-            {
-                if (logger.wblWillLogTrace())
-                {
-                    logger.trace("Unable to configure decorator with class : [{0}]", annotatedType.getJavaClass());
-                }
-            }
-        }
-    }
-    
-    public static <T> void defineInterceptor(AnnotatedType<T> annotatedType)
-    {
-        Class<?> clazz = annotatedType.getJavaClass();
-        WebBeansContext webBeansContext = WebBeansContext.getInstance();
-        if (webBeansContext.getInterceptorsManager().isInterceptorEnabled(clazz))
-        {
-            ManagedBean<T> delegate = null;
-
-            InterceptorUtil.checkAnnotatedTypeInterceptorConditions(annotatedType);
-            delegate = defineManagedBean(annotatedType);
-
-            if (delegate != null)
-            {
-                Annotation[] anns = annotatedType.getAnnotations().toArray(new Annotation[0]);
-                AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
-                WebBeansInterceptorConfig.configureInterceptorClass(delegate,
-                                                                    annotationManager.getInterceptorBindingMetaAnnotations(anns));
-            }
-            else
-            {
-                if (logger.wblWillLogTrace())
-                {
-                    logger.trace("Unable to configure interceptor with class : [{0}]", annotatedType.getJavaClass());
-                }
-            }
-        }
-
-    }
 
     @SuppressWarnings("unchecked")
     @Deprecated