openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1433681 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/ webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ webbean...
Date Tue, 15 Jan 2013 21:49:09 GMT
Author: struberg
Date: Tue Jan 15 21:49:08 2013
New Revision: 1433681

URL: http://svn.apache.org/viewvc?rev=1433681&view=rev
Log:
OWB-344 make InjectionTarget#produce create a proxy

Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
    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
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DefaultInterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandlerPleaseRemove.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBeanPleaseRemove.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractDecoratorInjectionTarget.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ExtensionProducer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducerRemove.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProxyGenerationException.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorProxyChainTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionServiceTest.java
    openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsUtil.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java (original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java Tue Jan 15 21:49:08 2013
@@ -489,7 +489,7 @@ public class OpenWebBeansEjbInterceptor 
             delegateHandler = new DelegateHandler(this.contextual, ejbContext);
 
             final Object delegate =
-                webBeansContext.getProxyFactory().createDecoratorDelegate(injectionTarget, delegateHandler);
+                webBeansContext.getProxyFactoryRemove().createDecoratorDelegate(injectionTarget, delegateHandler);
             // Gets component decorator stack
             decorators = WebBeansDecoratorConfig.getDecoratorStack(injectionTarget, instance, delegate,
                                                                    (CreationalContextImpl<?>)this.cc);          

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java Tue Jan 15 21:49:08 2013
@@ -217,18 +217,18 @@ public abstract class BuildInOwbBean<T> 
             return actualInstance;
         }
 
-        T proxy = (T) webBeansContext.getProxyFactory().createBuildInBeanProxyRemove(this);
+        T proxy = (T) webBeansContext.getProxyFactoryRemove().createBuildInBeanProxyRemove(this);
         if (handlerClassName.equals(PROXY_HANDLER_VALUE_DEFAULT)) 
         {
             final MethodHandler handler = new BuildInBeanMethodHandler(this, actualInstance);
-            webBeansContext.getProxyFactory().setHandler(proxy, handler);
+            webBeansContext.getProxyFactoryRemove().setHandler(proxy, handler);
             return proxy;
         } 
         else if (handlerContructor != null)
         {
             try 
             {
-                webBeansContext.getProxyFactory().setHandler(proxy,
+                webBeansContext.getProxyFactoryRemove().setHandler(proxy,
                                                  (MethodHandler) (handlerContructor.newInstance(this, actualInstance)));
                 return proxy;
             } 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java Tue Jan 15 21:49:08 2013
@@ -130,7 +130,7 @@ public abstract class InjectionTargetBea
         //For dependent instance checks
         if(getScope() == Dependent.class && !(this instanceof EnterpriseBeanMarker))
         {
-            final ProxyFactory proxyFactory = getWebBeansContext().getProxyFactory();
+            final ProxyFactory proxyFactory = getWebBeansContext().getProxyFactoryRemove();
             T result = (T) proxyFactory.createDependentScopedBeanProxyRemove(this, instance, creationalContext);
             //Means that Dependent Bean has interceptor/decorator
             if(proxyFactory.isProxyInstanceRemove(result))

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java Tue Jan 15 21:49:08 2013
@@ -63,8 +63,8 @@ public class ResourceBean<X, T extends A
                 return instance;
             }
 
-            X proxyInstance = (X) getWebBeansContext().getProxyFactory().getResourceBeanProxyClass(this).newInstance();
-            webBeansContext.getProxyFactory().setHandler(proxyInstance, new ResourceProxyHandler(this,instance));
+            X proxyInstance = (X) getWebBeansContext().getProxyFactoryRemove().getResourceBeanProxyClass(this).newInstance();
+            webBeansContext.getProxyFactoryRemove().setHandler(proxyInstance, new ResourceProxyHandler(this,instance));
             return proxyInstance;
         }
         catch (Exception e)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java Tue Jan 15 21:49:08 2013
@@ -65,6 +65,8 @@ import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
+import static org.apache.webbeans.intercept.InterceptorResolutionService.BeanInterceptorInfo;
+
 /**
  * Abstract implementation of {@link AbstractBeanBuilder}.
  * 
@@ -675,14 +677,17 @@ public abstract class AbstractInjectionT
         }
     }
 
-    protected InjectionTarget<T> buildInjectionTarget(AnnotatedType<T> annotatedType,
+    protected InjectionTarget<T> buildInjectionTarget(Set<Type> types,
+                                                      Set<Annotation> qualifiers,
+                                                      AnnotatedType<T> annotatedType,
                                                       Set<InjectionPoint> points,
                                                       WebBeansContext webBeansContext,
                                                       List<AnnotatedMethod<?>> postConstructMethods,
                                                       List<AnnotatedMethod<?>> preDestroyMethods)
     {
-        //X TODO set interceptor information
-        return new InjectionTargetImpl<T>(annotatedType, points, webBeansContext, postConstructMethods, preDestroyMethods);
+        InjectionTargetImpl<T> injectionTarget = new InjectionTargetImpl<T>(annotatedType, points, webBeansContext, postConstructMethods, preDestroyMethods);
+
+        return injectionTarget;
     }
 
     protected abstract I createBean(Set<Type> types,
@@ -709,7 +714,7 @@ public abstract class AbstractInjectionT
 
         //X TODO hack to set the InjectionTarget
         InjectionTarget<T> injectionTarget
-                = buildInjectionTarget(bean.getAnnotatedType(), bean.getInjectionPoints(), webBeansContext, getPostConstructMethods(), getPreDestroyMethods());
+                = buildInjectionTarget(types, qualifiers, bean.getAnnotatedType(), bean.getInjectionPoints(), webBeansContext, getPostConstructMethods(), getPreDestroyMethods());
         bean.setInjectionTarget(injectionTarget);
 
         return bean;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java Tue Jan 15 21:49:08 2013
@@ -19,9 +19,13 @@
 package org.apache.webbeans.component.creation;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import javax.annotation.PostConstruct;
@@ -30,6 +34,8 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.Interceptor;
 
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.WebBeansType;
@@ -39,7 +45,10 @@ import org.apache.webbeans.decorator.Dec
 import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
 import org.apache.webbeans.exception.inject.DeploymentException;
 import org.apache.webbeans.inject.impl.InjectionPointFactory;
+import org.apache.webbeans.intercept.InterceptorResolutionService;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.portable.InjectionTargetImpl;
+import org.apache.webbeans.proxy.InterceptorDecoratorProxyFactory;
 import org.apache.webbeans.portable.AbstractDecoratorInjectionTarget;
 import org.apache.webbeans.util.WebBeansUtil;
 
@@ -134,6 +143,65 @@ public class ManagedBeanBuilder<T, M ext
         return webBeansContext.getInterceptorUtil().getLifecycleMethods(getAnnotated(), PreDestroy.class, false);
     }
 
+    @Override
+    protected InjectionTarget<T> buildInjectionTarget(Set<Type> types, Set<Annotation> qualifiers, AnnotatedType<T> annotatedType, Set<InjectionPoint> points, WebBeansContext webBeansContext, List<AnnotatedMethod<?>> postConstructMethods, List<AnnotatedMethod<?>> preDestroyMethods)
+    {
+        InjectionTargetImpl<T> injectionTarget =  (InjectionTargetImpl<T>) super.buildInjectionTarget(types, qualifiers, annotatedType, points, webBeansContext, postConstructMethods, preDestroyMethods);    //To change body of overridden methods use File | Settings | File Templates.
+        InterceptorResolutionService.BeanInterceptorInfo interceptorInfo = webBeansContext.getInterceptorResolutionService().calculateInterceptorInfo(types, qualifiers, annotatedType);
+
+        Map<Method, List<Interceptor<?>>> methodInterceptors = new HashMap<Method, List<Interceptor<?>>>();
+        List<Method> nonBusinessMethods = new ArrayList<Method>();
+        for (Map.Entry<Method, InterceptorResolutionService.BusinessMethodInterceptorInfo> miEntry : interceptorInfo.getBusinessMethodsInfo().entrySet())
+        {
+            Method interceptedMethod = miEntry.getKey();
+            InterceptorResolutionService.BusinessMethodInterceptorInfo mii = miEntry.getValue();
+            List<Interceptor<?>> activeInterceptors = new ArrayList<Interceptor<?>>();
+
+            if (mii.getEjbInterceptors() != null)
+            {
+                for (Interceptor<?> i : mii.getEjbInterceptors())
+                {
+                    activeInterceptors.add(i);
+                }
+            }
+            if (mii.getCdiInterceptors() != null)
+            {
+                for (Interceptor<?> i : mii.getCdiInterceptors())
+                {
+                    activeInterceptors.add(i);
+                }
+            }
+            if (activeInterceptors.size() > 0)
+            {
+                methodInterceptors.put(interceptedMethod, activeInterceptors);
+            }
+
+            // empty InterceptionType -> AROUND_INVOKE
+            if (!mii.getInterceptionTypes().isEmpty())
+            {
+                nonBusinessMethods.add(interceptedMethod);
+            }
+        }
+
+        if (methodInterceptors.size() > 0)
+        {
+            // we only need to create a proxy class for intercepted or decorated Beans
+            InterceptorDecoratorProxyFactory pf = webBeansContext.getInterceptorDecoratorProxyFactory();
+
+            // we take a fresh URLClassLoader to not blur the test classpath with synthetic classes.
+            ClassLoader classLoader = this.getClass().getClassLoader();
+
+            Method[] businessMethods = methodInterceptors.keySet().toArray(new Method[methodInterceptors.size()]);
+            Method[] nonInterceptedMethods = interceptorInfo.getNonInterceptedMethods().toArray(new Method[interceptorInfo.getNonInterceptedMethods().size()]);
+
+            Class<? extends T> proxyClass = pf.createProxyClass(classLoader, getBeanType(), businessMethods, nonInterceptedMethods);
+
+            injectionTarget.setInterceptorInfo(interceptorInfo, proxyClass, methodInterceptors);
+        }
+
+        return injectionTarget;
+    }
+
     /**
      * @deprecated replaced via the various {@link InterceptorBeanBuilder}s
      */
@@ -233,6 +301,7 @@ public class ManagedBeanBuilder<T, M ext
         }
 
         //X TODO move proxy instance creation into JavassistProxyFactory!
+
         bean.setInjectionTarget(new AbstractDecoratorInjectionTarget<T>(bean));
         return bean;
     }

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=1433681&r1=1433680&r2=1433681&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 Tue Jan 15 21:49:08 2013
@@ -44,6 +44,7 @@ import org.apache.webbeans.intercept.ejb
 import org.apache.webbeans.plugins.PluginLoader;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
 import org.apache.webbeans.portable.events.ExtensionLoader;
+import org.apache.webbeans.proxy.InterceptorDecoratorProxyFactory;
 import org.apache.webbeans.proxy.ProxyFactory;
 import org.apache.webbeans.proxy.javassist.OpenWebBeansClassLoaderProvider;
 import org.apache.webbeans.service.DefaultLoaderService;
@@ -64,7 +65,7 @@ import org.apache.webbeans.util.WebBeans
 public class WebBeansContext
 {
     //X TODO REMOVE, only used while implementing the new Interceptor handling
-    public static final boolean TODO_USING_NEW_INTERCEPTORS = false;
+    public static final boolean TODO_USING_NEW_INTERCEPTORS = true;
 
     private final Map<Class<?>, Object> managerMap = new HashMap<Class<?>, Object>();
 
@@ -82,7 +83,8 @@ public class WebBeansContext
     private final ExtensionLoader extensionLoader = new ExtensionLoader(this);
     private final InterceptorsManager interceptorsManager = new InterceptorsManager(this);
     private final WebBeansInterceptorConfig webBeansInterceptorConfig = new WebBeansInterceptorConfig(this);
-    private final ProxyFactory proxyFactory;
+    private final ProxyFactory proxyFactoryRemove;
+    private final InterceptorDecoratorProxyFactory interceptorDecoratorProxyFactory = new InterceptorDecoratorProxyFactory();
     private final OpenWebBeansConfiguration openWebBeansConfiguration;
     private final PluginLoader pluginLoader = new PluginLoader();
     private final SerializableBeanVault serializableBeanVault = new SerializableBeanVault();
@@ -138,9 +140,9 @@ public class WebBeansContext
         loaderService = getService(LoaderService.class);
         securityService = getService(SecurityService.class);
 
-        proxyFactory = serviceMap.containsKey(ProxyFactory.class)
+        proxyFactoryRemove = serviceMap.containsKey(ProxyFactory.class)
             ? (ProxyFactory) serviceMap.get(ProxyFactory.class)
-            : new ProxyFactory();
+            : new ProxyFactory(this);
         OpenWebBeansClassLoaderProvider.initProxyFactoryClassLoaderProvider();
 
         // Allow the WebBeansContext itself to be looked up
@@ -155,7 +157,8 @@ public class WebBeansContext
         managerMap.put(DecoratorsManager.class, decoratorsManager);
         managerMap.put(ExtensionLoader.class, extensionLoader);
         managerMap.put(InterceptorsManager.class, interceptorsManager);
-        managerMap.put(ProxyFactory.class, proxyFactory);
+        managerMap.put(ProxyFactory.class, proxyFactoryRemove);
+        managerMap.put(InterceptorDecoratorProxyFactory.class, interceptorDecoratorProxyFactory);
         managerMap.put(OpenWebBeansConfiguration.class, openWebBeansConfiguration);
         managerMap.put(PluginLoader.class, pluginLoader);
         managerMap.put(SerializableBeanVault.class, serializableBeanVault);
@@ -328,9 +331,14 @@ public class WebBeansContext
         return extensionLoader;
     }
 
-    public ProxyFactory getProxyFactory()
+    public ProxyFactory getProxyFactoryRemove()
     {
-        return proxyFactory;
+        return proxyFactoryRemove;
+    }
+
+    public InterceptorDecoratorProxyFactory getInterceptorDecoratorProxyFactory()
+    {
+        return interceptorDecoratorProxyFactory;
     }
 
 

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=1433681&r1=1433680&r2=1433681&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 Tue Jan 15 21:49:08 2013
@@ -706,7 +706,7 @@ public class BeanManagerImpl implements 
             if (instance == null)
             {
                 //Create Managed Bean Proxy
-                instance = webBeansContext.getProxyFactory().createNormalScopedBeanProxyRemove((AbstractOwbBean<?>) bean, creationalContext);
+                instance = webBeansContext.getProxyFactoryRemove().createNormalScopedBeanProxyRemove((AbstractOwbBean<?>) bean, creationalContext);
 
                 //Cached instance
                 cacheProxies.put(bean, instance);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java Tue Jan 15 21:49:08 2013
@@ -412,7 +412,7 @@ public class WebBeansDecorator<T> extend
         WebBeansContext webBeansContext = wrappedBean.getWebBeansContext();
         Context context = webBeansContext.getBeanManagerImpl().getContext(getScope());
         Object actualInstance = context.get((Bean<Object>) wrappedBean, (CreationalContext<Object>)creationalContext);
-        T proxy = (T) webBeansContext.getProxyFactory().createDependentScopedBeanProxyRemove(wrappedBean, actualInstance, creationalContext);
+        T proxy = (T) webBeansContext.getProxyFactoryRemove().createDependentScopedBeanProxyRemove(wrappedBean, actualInstance, creationalContext);
         
         return proxy;        
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DefaultInterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DefaultInterceptorHandler.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DefaultInterceptorHandler.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DefaultInterceptorHandler.java Tue Jan 15 21:49:08 2013
@@ -44,6 +44,16 @@ public class DefaultInterceptorHandler<T
         this.interceptors = interceptors;
     }
 
+    public Map<Interceptor<?>, ?> getInstances()
+    {
+        return instances;
+    }
+
+    public Map<Method, List<Interceptor<?>>> getInterceptors()
+    {
+        return interceptors;
+    }
+
     public Object invoke(Method method, Object[] parameters)
     {
         try

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandlerPleaseRemove.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandlerPleaseRemove.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandlerPleaseRemove.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandlerPleaseRemove.java Tue Jan 15 21:49:08 2013
@@ -348,7 +348,7 @@ public abstract class InterceptorHandler
         if (decoratorDelegateHandler == null)
         {
             final DelegateHandler newDelegateHandler = new DelegateHandler(bean);
-            final ProxyFactory proxyFactory = webBeansContext.getProxyFactory();
+            final ProxyFactory proxyFactory = webBeansContext.getProxyFactoryRemove();
 
             final Object delegate = proxyFactory.createDecoratorDelegate(bean, newDelegateHandler);
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java Tue Jan 15 21:49:08 2013
@@ -23,7 +23,6 @@ import javax.annotation.PreDestroy;
 import javax.enterprise.inject.spi.Annotated;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Decorator;
 import javax.enterprise.inject.spi.InterceptionType;
@@ -86,9 +85,10 @@ public class InterceptorResolutionServic
     }
 
 
-    public <T> BeanInterceptorInfo  calculateInterceptorInfo(Bean<T> bean, AnnotatedType<T> annotatedType)
+    public <T> BeanInterceptorInfo  calculateInterceptorInfo(Set<Type> beanTypes, Set<Annotation> qualifiers, AnnotatedType<T> annotatedType)
     {
-        Asserts.assertNotNull(bean, "Bean must not be null!");
+        Asserts.assertNotNull(beanTypes, "beanTypes must not be null!");
+        Asserts.assertNotNull(qualifiers, "qualifiers must not be null!");
         Asserts.assertNotNull(annotatedType, "AnnotatedType must not be null!");
 
         List<AnnotatedMethod> interceptableAnnotatedMethods = getInterceptableBusinessMethods(annotatedType);
@@ -106,7 +106,7 @@ public class InterceptorResolutionServic
         collectEjbInterceptors(classLevelEjbInterceptors, annotatedType);
 
         // pick up the decorators
-        List<Decorator<?>> decorators = beanManager.resolveDecorators(bean.getTypes(), AnnotationUtil.asArray(bean.getQualifiers()));
+        List<Decorator<?>> decorators = beanManager.resolveDecorators(beanTypes, AnnotationUtil.asArray(qualifiers));
         if (decorators.size() == 0)
         {
             decorators = null; // less to store

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBeanPleaseRemove.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBeanPleaseRemove.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBeanPleaseRemove.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBeanPleaseRemove.java Tue Jan 15 21:49:08 2013
@@ -291,7 +291,7 @@ public class WebBeansInterceptorBeanPlea
     {
         Context context = webBeansContext.getBeanManagerImpl().getContext(getScope());
         Object actualInstance = context.get((Bean<Object>) delegateBean, (CreationalContext<Object>)creationalContext);
-        T proxy = (T) webBeansContext.getProxyFactory().createDependentScopedBeanProxyRemove(delegateBean, actualInstance, creationalContext);
+        T proxy = (T) webBeansContext.getProxyFactoryRemove().createDependentScopedBeanProxyRemove(delegateBean, actualInstance, creationalContext);
         
         return proxy;
     }

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=1433681&r1=1433680&r2=1433681&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 Tue Jan 15 21:49:08 2013
@@ -169,7 +169,7 @@ public abstract class AbstractLifeCycle 
             injectionResolver.clearCaches();
             
             //Delte proxies
-            webBeansContext.getProxyFactory().clear();
+            webBeansContext.getProxyFactoryRemove().clear();
             
             //Delete AnnotateTypeCache
             webBeansContext.getAnnotatedElementFactory().clear();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractDecoratorInjectionTarget.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractDecoratorInjectionTarget.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractDecoratorInjectionTarget.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractDecoratorInjectionTarget.java Tue Jan 15 21:49:08 2013
@@ -41,7 +41,7 @@ public class AbstractDecoratorInjectionT
     {
         super(bean.getAnnotatedType(), bean.getInjectionPoints(), bean.getWebBeansContext(),
               Collections.<AnnotatedMethod<?>>emptyList(), Collections.<AnnotatedMethod<?>>emptyList());
-        proxyFactory = bean.getWebBeansContext().getProxyFactory();
+        proxyFactory = bean.getWebBeansContext().getProxyFactoryRemove();
         Class<T> clazz = (Class<T>) proxyFactory.createAbstractDecoratorProxyClass(bean);
         constructor = bean.getWebBeansContext().getWebBeansUtil().defineConstructor(clazz);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ExtensionProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ExtensionProducer.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ExtensionProducer.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ExtensionProducer.java Tue Jan 15 21:49:08 2013
@@ -42,7 +42,7 @@ public class ExtensionProducer<T> extend
     @Override
     public T produce(CreationalContext<T> creationalContext)
     {
-        ExtensionLoader loader = context.getExtensionLoader();
+        ExtensionLoader loader = webBeansContext.getExtensionLoader();
         
         return loader.getBeanInstance((Bean<T>)((CreationalContextImpl<T>) creationalContext).getBean());
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java Tue Jan 15 21:49:08 2013
@@ -24,8 +24,11 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import javax.enterprise.context.spi.CreationalContext;
@@ -44,12 +47,17 @@ import javax.enterprise.inject.spi.Inter
 import javax.inject.Inject;
 import javax.interceptor.InvocationContext;
 
+import org.apache.webbeans.component.SelfInterceptorBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.inject.InjectableConstructor;
 import org.apache.webbeans.inject.InjectableField;
 import org.apache.webbeans.inject.InjectableMethod;
+import org.apache.webbeans.intercept.DefaultInterceptorHandler;
 import org.apache.webbeans.intercept.LifecycleInterceptorInvocationContext;
+import org.apache.webbeans.proxy.InterceptorDecoratorProxyFactory;
+import org.apache.webbeans.proxy.InterceptorHandler;
+import org.apache.webbeans.proxy.OwbInterceptorProxy;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ExceptionUtil;
 
@@ -61,7 +69,7 @@ public class InjectionTargetImpl<T> exte
 
     private AnnotatedType<T> type;
     private AnnotatedConstructor<T> constructor;
-    protected final WebBeansContext context;
+    protected final WebBeansContext webBeansContext;
 
     /**
      * If the InjectionTarget has a &#064;PostConstruct method, <code>null</code> if not.
@@ -84,6 +92,23 @@ public class InjectionTargetImpl<T> exte
      */
     private BeanInterceptorInfo interceptorInfo = null;
 
+    /**
+     * Defines the interceptor/decorator stack for the InjectionTargetBean.
+     * In case this is already defined, we get the ProxyClass for the Bean
+     * or <code>null</code> if this Bean doesn't need any proxy.
+     * This logic is handled inside the Bean and not in the BeanBuilder as
+     * this can also be created lazily
+     *
+     * the Proxy Class or <code>null</code> if this Bean is not intercepted nor decorated.
+     */
+    private Class<? extends T>  proxyClass;
+
+    /**
+     * List of all Interceptors per Method.
+     */
+    private Map<Method, List<Interceptor<?>>> methodInterceptors = null;
+
+
     public InjectionTargetImpl(AnnotatedType<T> annotatedType, Set<InjectionPoint> points, WebBeansContext webBeansContext,
                                List<AnnotatedMethod<?>> postConstructMethods, List<AnnotatedMethod<?>> preDestroyMethods)
     {
@@ -91,14 +116,16 @@ public class InjectionTargetImpl<T> exte
         Asserts.assertNotNull(annotatedType);
         Asserts.assertNotNull(webBeansContext);
         type = annotatedType;
-        context = webBeansContext;
+        this.webBeansContext = webBeansContext;
         this.postConstructMethods = postConstructMethods;
         this.preDestroyMethods = preDestroyMethods;
     }
 
-    public void setInterceptorInfo(BeanInterceptorInfo interceptorInfo)
+    public void setInterceptorInfo(BeanInterceptorInfo interceptorInfo, Class<? extends T> proxyClass, Map<Method, List<Interceptor<?>>> methodInterceptors)
     {
         this.interceptorInfo = interceptorInfo;
+        this.proxyClass = proxyClass;
+        this.methodInterceptors = methodInterceptors;
     }
 
     @Override
@@ -109,8 +136,27 @@ public class InjectionTargetImpl<T> exte
         if (interceptorInfo != null)
         {
             // apply interceptorInfo
-            Set<Interceptor<?>> interceptors = interceptorInfo.getInterceptors();
+            InterceptorDecoratorProxyFactory pf = webBeansContext.getInterceptorDecoratorProxyFactory();
 
+            Map<Interceptor<?>,Object> interceptorInstances  = new HashMap<Interceptor<?>, Object>();
+            for (Interceptor interceptorBean : interceptorInfo.getInterceptors())
+            {
+                Object interceptorInstance;
+                if (interceptorBean instanceof SelfInterceptorBean)
+                {
+                    interceptorInstance = instance;
+                }
+                else
+                {
+                    interceptorInstance = interceptorBean.create(creationalContext);
+                }
+                interceptorInstances.put(interceptorBean, interceptorInstance);
+            }
+
+            InterceptorHandler interceptorHandler = new DefaultInterceptorHandler<T>(instance, methodInterceptors, interceptorInstances);
+
+            T proxyInstance = pf.createProxyInstance(proxyClass, instance, interceptorHandler);
+            instance = proxyInstance;
         }
 
         return instance;
@@ -191,12 +237,31 @@ public class InjectionTargetImpl<T> exte
     @Override
     public void postConstruct(T instance)
     {
-        if (postConstructMethods == null /*X TODO && postConstructInterceptors == null */)
+        if (postConstructMethods == null)
         {
             return;
         }
 
-        InvocationContext ic = new LifecycleInterceptorInvocationContext<T>(instance, InterceptionType.POST_CONSTRUCT, null, null, postConstructMethods);
+
+        Map<Interceptor<?>, ?> interceptorInstances = null;
+        List<Interceptor<?>> postConstructInterceptors = null;
+
+        if (interceptorInfo != null && instance instanceof OwbInterceptorProxy)
+        {
+            InterceptorDecoratorProxyFactory pf = webBeansContext.getInterceptorDecoratorProxyFactory();
+            InterceptorHandler ih = pf.getInterceptorHandler((OwbInterceptorProxy) instance);
+            if (ih instanceof DefaultInterceptorHandler)
+            {
+                DefaultInterceptorHandler dih = (DefaultInterceptorHandler) ih;
+                interceptorInstances = dih.getInstances();
+            }
+
+            // we are cheating a bit right now. We could also calculate the real ones upfront
+            postConstructInterceptors = new ArrayList<Interceptor<?>>(interceptorInfo.getInterceptors());
+        }
+
+        InvocationContext ic = new LifecycleInterceptorInvocationContext<T>(instance, InterceptionType.POST_CONSTRUCT, postConstructInterceptors,
+                                                                            interceptorInstances, postConstructMethods);
         try
         {
             ic.proceed();
@@ -254,14 +319,14 @@ public class InjectionTargetImpl<T> exte
         }
         else
         {
-            this.constructor = new AnnotatedConstructorImpl<T>(context, getDefaultConstructor(), type);
+            this.constructor = new AnnotatedConstructorImpl<T>(webBeansContext, getDefaultConstructor(), type);
         }
         return this.constructor;
     }
 
     private Constructor<T> getDefaultConstructor()
     {
-        return context.getWebBeansUtil().getNoArgConstructor(type.getJavaClass());
+        return webBeansContext.getWebBeansUtil().getNoArgConstructor(type.getJavaClass());
     }
     
     private boolean isProducerMethod(InjectionPoint injectionPoint)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducerRemove.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducerRemove.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducerRemove.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducerRemove.java Tue Jan 15 21:49:08 2013
@@ -97,7 +97,7 @@ public class InjectionTargetProducerRemo
                 //injection will be occured on Proxy instances that are 
                 //not correct. Injection must be on actual dependent
                 //instance,so not necessary to inject on proxy
-                final ProxyFactory proxyFactory = this.bean.getWebBeansContext().getProxyFactory();
+                final ProxyFactory proxyFactory = this.bean.getWebBeansContext().getProxyFactoryRemove();
                 if(bean.getScope() == Dependent.class && proxyFactory.isProxyInstanceRemove(instance))
                 {
                     return;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java Tue Jan 15 21:49:08 2013
@@ -24,6 +24,7 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
+import org.apache.webbeans.util.ExceptionUtil;
 import org.objectweb.asm.ClassWriter;
 import org.objectweb.asm.Label;
 import org.objectweb.asm.MethodVisitor;
@@ -103,8 +104,27 @@ public class InterceptorDecoratorProxyFa
         }
         catch (Exception e)
         {
-            throw new RuntimeException(e);
+            ExceptionUtil.throwAsRuntimeException(e);
         }
+        return null;
+    }
+
+    /**
+     * @return the internal instance which gets proxied.
+     */
+    public InterceptorHandler getInterceptorHandler(OwbInterceptorProxy proxyInstance)
+    {
+        try
+        {
+            Field internalInstanceField = proxyInstance.getClass().getDeclaredField(FIELD_INTERCEPTOR_HANDLER);
+            internalInstanceField.setAccessible(true);
+            return (InterceptorHandler) internalInstanceField.get(proxyInstance);
+        }
+        catch (Exception e)
+        {
+            ExceptionUtil.throwAsRuntimeException(e);
+        }
+        return null;
     }
 
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProxyFactory.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProxyFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProxyFactory.java Tue Jan 15 21:49:08 2013
@@ -39,6 +39,7 @@ import org.apache.webbeans.component.Inj
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.component.ResourceBean;
 import org.apache.webbeans.config.OpenWebBeansConfiguration;
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.DelegateHandler;
 import org.apache.webbeans.decorator.WebBeansDecorator;
@@ -52,30 +53,32 @@ import org.apache.webbeans.proxy.javassi
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
+
+
 /**
  *  TODO remove old proxy handling. Only InterceptorDecoratorProxyFactory and NormalScopeProxyFactory shall remain.
  */
 public final class ProxyFactory
 {
-    private ConcurrentMap<OwbBean<?>, Class<?>> buildInBeanProxyClasses = new ConcurrentHashMap<OwbBean<?>, Class<?>>();
-    private ConcurrentMap<OwbBean<?>, Class<?>> normalScopedBeanProxyClasses = new ConcurrentHashMap<OwbBean<?>, Class<?>>();    
-    private ConcurrentMap<OwbBean<?>, Class<?>> dependentScopedBeanProxyClasses = new ConcurrentHashMap<OwbBean<?>, Class<?>>();    
-    private ConcurrentMap<OwbBean<?>, Class<?>> interceptorProxyClasses = new ConcurrentHashMap<OwbBean<?>, Class<?>>();
-    private ConcurrentMap<ResourceBean<?, ?>, Class<?>> resourceBeanProxyClasses = new ConcurrentHashMap<ResourceBean<?,?>, Class<?>>();
+    private final WebBeansContext webBeansContext;
+
+    private ConcurrentMap<OwbBean<?>, Class<?>> buildInBeanProxyClassesRemove = new ConcurrentHashMap<OwbBean<?>, Class<?>>();
+    private ConcurrentMap<OwbBean<?>, Class<?>> normalScopedBeanProxyClassesRemove = new ConcurrentHashMap<OwbBean<?>, Class<?>>();
+    private ConcurrentMap<OwbBean<?>, Class<?>> dependentScopedBeanProxyClassesRemove = new ConcurrentHashMap<OwbBean<?>, Class<?>>();
+    private ConcurrentMap<OwbBean<?>, Class<?>> interceptorProxyClassesRemove = new ConcurrentHashMap<OwbBean<?>, Class<?>>();
+    private ConcurrentMap<ResourceBean<?, ?>, Class<?>> resourceBeanProxyClassesRemove = new ConcurrentHashMap<ResourceBean<?,?>, Class<?>>();
 
     // second level map is indexed on local interface
     private ConcurrentMap<OwbBean<?>, ConcurrentMap<Class<?>, Class<?>>> ejbProxyClasses = new ConcurrentHashMap<OwbBean<?>, ConcurrentMap<Class<?>, Class<?>>>();
-    private Factory factory;
+    private Factory factoryRemove = new JavassistFactory();
 
+    private final InterceptorDecoratorProxyFactory interceptorDecoratorProxyFactory;
 
-    public ProxyFactory()
-    {
-        this(new JavassistFactory());
-    }
 
-    public ProxyFactory(Factory factory)
+    public ProxyFactory(WebBeansContext webBeansContext)
     {
-        this.factory = factory;
+        this.webBeansContext = webBeansContext;
+        this.interceptorDecoratorProxyFactory = new InterceptorDecoratorProxyFactory();
     }
 
     /**
@@ -87,20 +90,20 @@ public final class ProxyFactory
 
     public void setHandler(Object proxy, MethodHandler handler)
     {
-        factory.setHandler(proxy, handler);
+        factoryRemove.setHandler(proxy, handler);
     }
 
 
     private Map<OwbBean<?>, Class<?>> getInterceptorProxyClasses()
     {
-        return interceptorProxyClasses;
+        return interceptorProxyClassesRemove;
     }
 
     public void clear()
     {
-        normalScopedBeanProxyClasses.clear();
-        dependentScopedBeanProxyClasses.clear();
-        interceptorProxyClasses.clear();
+        normalScopedBeanProxyClassesRemove.clear();
+        dependentScopedBeanProxyClassesRemove.clear();
+        interceptorProxyClassesRemove.clear();
         ejbProxyClasses.clear();
     }
     /**
@@ -159,7 +162,7 @@ public final class ProxyFactory
             
             interfaces = new Class<?>[list.size()];
             interfaces = list.toArray(interfaces);
-            proxyClass = factory.getProxyClass(superClazz, interfaces);
+            proxyClass = factoryRemove.getProxyClass(superClazz, interfaces);
             
             typeToProxyClassMap.putIfAbsent(iface, proxyClass);
             // don't care if we were beaten in updating the iface->proxyclass map
@@ -192,12 +195,12 @@ public final class ProxyFactory
     {
         try
         {
-            Class<?> proxyClass = resourceBeanProxyClasses.get(resourceBean);
+            Class<?> proxyClass = resourceBeanProxyClassesRemove.get(resourceBean);
             if (proxyClass == null)
             {
                 proxyClass = createProxyClassRemove(resourceBean);
 
-                Class<?> oldClazz = resourceBeanProxyClasses.putIfAbsent(resourceBean, proxyClass);
+                Class<?> oldClazz = resourceBeanProxyClassesRemove.putIfAbsent(resourceBean, proxyClass);
                 if (oldClazz != null)
                 {
                     return oldClazz;
@@ -222,11 +225,11 @@ public final class ProxyFactory
         Object result = null;
         try
         {
-            Class<?> proxyClass = normalScopedBeanProxyClasses.get(bean);
+            Class<?> proxyClass = normalScopedBeanProxyClassesRemove.get(bean);
             if (proxyClass == null)
             {
                 proxyClass = createProxyClassRemove(bean);
-                normalScopedBeanProxyClasses.putIfAbsent(bean, proxyClass);
+                normalScopedBeanProxyClassesRemove.putIfAbsent(bean, proxyClass);
             }
 
 
@@ -254,7 +257,7 @@ public final class ProxyFactory
     private Object createProxyRemove(Class<?> proxyClass)
         throws InstantiationException, IllegalAccessException
     {
-        return factory.createProxy(proxyClass);
+        return factoryRemove.createProxy(proxyClass);
     }
 
     /**
@@ -346,11 +349,11 @@ public final class ProxyFactory
         Object result = null;
         try
         {
-            Class<?> proxyClass = buildInBeanProxyClasses.get(bean);
+            Class<?> proxyClass = buildInBeanProxyClassesRemove.get(bean);
             if (proxyClass == null)
             {
                 proxyClass = createProxyClassRemove(bean);
-                buildInBeanProxyClasses.putIfAbsent(bean, proxyClass);
+                buildInBeanProxyClassesRemove.putIfAbsent(bean, proxyClass);
             }
             result = createProxyRemove(proxyClass);
         }
@@ -427,11 +430,11 @@ public final class ProxyFactory
         
         try
         {
-            Class<?> proxyClass = dependentScopedBeanProxyClasses.get(bean);
+            Class<?> proxyClass = dependentScopedBeanProxyClassesRemove.get(bean);
             if (proxyClass == null)
             {
                 proxyClass = createProxyClassRemove(bean);
-                dependentScopedBeanProxyClasses.putIfAbsent(bean, proxyClass);
+                dependentScopedBeanProxyClassesRemove.putIfAbsent(bean, proxyClass);
             }
 
             Object result = createProxyRemove(proxyClass);
@@ -456,7 +459,7 @@ public final class ProxyFactory
     private Class<?> createProxyClassRemove(OwbBean<?> bean)
     {
         final ProxyInfoRemove info = getProxyInfo(bean);
-        return factory.getProxyClass(info.getSuperClass(), info.getInterfaces());
+        return factoryRemove.getProxyClass(info.getSuperClass(), info.getInterfaces());
     }
 
     public Class<?> createAbstractDecoratorProxyClass(OwbBean<?> bean)
@@ -469,13 +472,13 @@ public final class ProxyFactory
      */
     public boolean isProxyInstanceRemove(Object o)
     {
-        return factory.isProxyInstance(o);
+        return factoryRemove.isProxyInstance(o);
     }
 
     public Object createProxy(MethodHandler handler, Class<?>[] interfaces)
         throws IllegalAccessException, InstantiationException
     {
-        return factory.createProxy(handler, interfaces);
+        return factoryRemove.createProxy(handler, interfaces);
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProxyGenerationException.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProxyGenerationException.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProxyGenerationException.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProxyGenerationException.java Tue Jan 15 21:49:08 2013
@@ -19,7 +19,7 @@
 package org.apache.webbeans.proxy;
 
 public class ProxyGenerationException
-    extends Exception
+    extends RuntimeException
 {
 
     public ProxyGenerationException()

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=1433681&r1=1433680&r2=1433681&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 Jan 15 21:49:08 2013
@@ -2462,7 +2462,7 @@ public final class WebBeansUtil
         ManagedBean<T> bean = defineManagedBean(type);
 
         //X TODO move proxy instance creation into JavassistProxyFactory!
-        Class clazz = webBeansContext.getProxyFactory().createAbstractDecoratorProxyClass(bean);
+        Class clazz = webBeansContext.getProxyFactoryRemove().createAbstractDecoratorProxyClass(bean);
 
         bean.setConstructor(defineConstructor(clazz));
         bean.setIsAbstractDecorator(true);

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorProxyChainTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorProxyChainTest.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorProxyChainTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorProxyChainTest.java Tue Jan 15 21:49:08 2013
@@ -56,7 +56,7 @@ public class InterceptorProxyChainTest e
         AnnotatedType<ClassMultiInterceptedClass> annotatedType = getBeanManager().createAnnotatedType(ClassMultiInterceptedClass.class);
         Bean<ClassMultiInterceptedClass> bean = (Bean<ClassMultiInterceptedClass>) getBeanManager().resolve(getBeanManager().getBeans(ClassMultiInterceptedClass.class));
 
-        InterceptorResolutionService.BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean, annotatedType);
+        InterceptorResolutionService.BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean.getTypes(), bean.getQualifiers(), annotatedType);
         Assert.assertNotNull(interceptorInfo);
 
 
@@ -64,13 +64,8 @@ public class InterceptorProxyChainTest e
         ClassMultiInterceptedClass internalInstance = new ClassMultiInterceptedClass();
         CreationalContext<ClassMultiInterceptedClass> cc = getBeanManager().createCreationalContext(bean);
 
-        Map<Interceptor<?>,Object> interceptorInstances  = new HashMap<Interceptor<?>, Object>();
-        for (Interceptor interceptorBean : interceptorInfo.getInterceptors())
-        {
-            Object interceptorInstance = interceptorBean.create(cc);
-            interceptorInstances.put(interceptorBean, interceptorInstance);
-        }
-
+        // step 1.
+        // calculate the interceptor-method info
         Map<Method, List<Interceptor<?>>> methodInterceptors = new HashMap<Method, List<Interceptor<?>>>();
         List<Method> nonBusinessMethods = new ArrayList<Method>();
         for (Map.Entry<Method, InterceptorResolutionService.BusinessMethodInterceptorInfo> miEntry : interceptorInfo.getBusinessMethodsInfo().entrySet())
@@ -104,9 +99,8 @@ public class InterceptorProxyChainTest e
             }
         }
 
-        InterceptorHandler interceptorHandler
-                = new DefaultInterceptorHandler<ClassMultiInterceptedClass>(internalInstance, methodInterceptors, interceptorInstances);
-
+        // step 2.
+        // creating the Proxy Class itself
         InterceptorDecoratorProxyFactory pf = new InterceptorDecoratorProxyFactory();
 
         // we take a fresh URLClassLoader to not blur the test classpath with synthetic classes.
@@ -118,6 +112,18 @@ public class InterceptorProxyChainTest e
         Class<? extends ClassMultiInterceptedClass> proxyClass = pf.createProxyClass(classLoader, ClassMultiInterceptedClass.class, businessMethods, nonInterceptedMethods);
         Assert.assertNotNull(proxyClass);
 
+
+        // step 3.
+        // creating the InterceptorHandler for each intercepted instance later at runtime
+        Map<Interceptor<?>,Object> interceptorInstances  = new HashMap<Interceptor<?>, Object>();
+        for (Interceptor interceptorBean : interceptorInfo.getInterceptors())
+        {
+            Object interceptorInstance = interceptorBean.create(cc);
+            interceptorInstances.put(interceptorBean, interceptorInstance);
+        }
+        InterceptorHandler interceptorHandler
+                = new DefaultInterceptorHandler<ClassMultiInterceptedClass>(internalInstance, methodInterceptors, interceptorInstances);
+
         ClassMultiInterceptedClass proxyInstance = pf.createProxyInstance(proxyClass, internalInstance, interceptorHandler);
         Assert.assertNotNull(proxyInstance);
 

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionServiceTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionServiceTest.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionServiceTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionServiceTest.java Tue Jan 15 21:49:08 2013
@@ -76,7 +76,7 @@ public class InterceptorResolutionServic
         AnnotatedType<ClassInterceptedClass> annotatedType = getBeanManager().createAnnotatedType(ClassInterceptedClass.class);
         Bean<ClassInterceptedClass> bean = (Bean<ClassInterceptedClass>) getBeanManager().resolve(getBeanManager().getBeans(ClassInterceptedClass.class));
 
-        BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean, annotatedType);
+        BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean.getTypes(), bean.getQualifiers(), annotatedType);
         Assert.assertNotNull(interceptorInfo);
 
         Assert.assertNotNull(interceptorInfo.getInterceptors());
@@ -122,7 +122,7 @@ public class InterceptorResolutionServic
         AnnotatedType<ClassMultiInterceptedClass> annotatedType = getBeanManager().createAnnotatedType(ClassMultiInterceptedClass.class);
         Bean<ClassMultiInterceptedClass> bean = (Bean<ClassMultiInterceptedClass>) getBeanManager().resolve(getBeanManager().getBeans(ClassMultiInterceptedClass.class));
 
-        BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean, annotatedType);
+        BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean.getTypes(), bean.getQualifiers(), annotatedType);
         Assert.assertNotNull(interceptorInfo);
 
         Assert.assertNotNull(interceptorInfo.getInterceptors());
@@ -166,7 +166,7 @@ public class InterceptorResolutionServic
         AnnotatedType<MethodInterceptedClass> annotatedType = getBeanManager().createAnnotatedType(MethodInterceptedClass.class);
         Bean<MethodInterceptedClass> bean = (Bean<MethodInterceptedClass>) getBeanManager().resolve(getBeanManager().getBeans(MethodInterceptedClass.class));
 
-        BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean, annotatedType);
+        BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean.getTypes(), bean.getQualifiers(), annotatedType);
         Assert.assertNotNull(interceptorInfo);
 
         Assert.assertNotNull(interceptorInfo.getInterceptors());
@@ -213,7 +213,7 @@ public class InterceptorResolutionServic
         Bean<DecoratedClass> bean = (Bean<DecoratedClass>) getBeanManager().resolve(
                 getBeanManager().getBeans(DecoratedClass.class, new AnnotationLiteral<Binding1>() {}));
 
-        BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean, annotatedType);
+        BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean.getTypes(), bean.getQualifiers(), annotatedType);
         Assert.assertNotNull(interceptorInfo);
 
         Assert.assertNotNull(interceptorInfo.getBusinessMethodsInfo());
@@ -241,7 +241,7 @@ public class InterceptorResolutionServic
         AnnotatedType<InterceptedComponent> annotatedType = getBeanManager().createAnnotatedType(InterceptedComponent.class);
         Bean<InterceptedComponent> bean = (Bean<InterceptedComponent>) getBeanManager().resolve(getBeanManager().getBeans(InterceptedComponent.class));
 
-        BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean, annotatedType);
+        BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean.getTypes(), bean.getQualifiers(), annotatedType);
         Assert.assertNotNull(interceptorInfo);
         Assert.assertNotNull(interceptorInfo.getBusinessMethodsInfo());
         Assert.assertEquals(2, interceptorInfo.getBusinessMethodsInfo().size());

Modified: openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsUtil.java?rev=1433681&r1=1433680&r2=1433681&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsUtil.java (original)
+++ openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsUtil.java Tue Jan 15 21:49:08 2013
@@ -171,7 +171,7 @@ public final class JmsUtil
 
             final Class<?>[] interfaces = {Closable.class, Serializable.class, intf};
 
-            return WebBeansContext.getInstance().getProxyFactory().createProxy(handler, interfaces);
+            return WebBeansContext.getInstance().getProxyFactoryRemove().createProxy(handler, interfaces);
 
         }
         catch (Exception e)
@@ -180,4 +180,4 @@ public final class JmsUtil
         }
     }
 
-}
\ No newline at end of file
+}



Mime
View raw message