openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1435108 - 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 Fri, 18 Jan 2013 12:27:02 GMT
Author: struberg
Date: Fri Jan 18 12:27:01 2013
New Revision: 1435108

URL: http://svn.apache.org/viewvc?rev=1435108&view=rev
Log:
OWB-344 remove old WebBeansDecorator 

Removed:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorRemove.java
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/InjectionTargetBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.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/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandlerPleaseRemove.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.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=1435108&r1=1435107&r2=1435108&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
Fri Jan 18 12:27:01 2013
@@ -42,7 +42,6 @@ import javax.enterprise.context.RequestS
 import javax.enterprise.context.spi.Context;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.Decorator;
 import javax.interceptor.AroundInvoke;
 import javax.interceptor.AroundTimeout;
 import javax.interceptor.InvocationContext;
@@ -52,7 +51,6 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.DelegateHandler;
-import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
 import org.apache.webbeans.decorator.WebBeansDecoratorInterceptor;
 import org.apache.webbeans.ejb.common.component.BaseEjbBean;
 import org.apache.webbeans.inject.OWBInjector;
@@ -469,47 +467,19 @@ public class OpenWebBeansEjbInterceptor 
         InterceptorDataImpl decoratorInterceptorDataImpl = null;
         List<Object> decorators = null;
         DelegateHandler delegateHandler = null;
-        List<Decorator<?>> decoratorStack = injectionTarget.getDecoratorStack();
         List<InterceptorData> interceptorStack = injectionTarget.getInterceptorStack();
 
 
         if (logger.isLoggable(Level.FINE))
         {
-            logger.log(Level.FINE, "Decorator stack for target {0}", decoratorStack);
             logger.log(Level.FINE, "Interceptor stack {0}", interceptorStack);
         }
                     
-        if (decoratorStack.size() > 0 )
-        {    
-            if (logger.isLoggable(Level.FINE))
-            {
-                logger.fine("Obtaining a delegate");
-            }
-
-            delegateHandler = new DelegateHandler(this.contextual, ejbContext);
 
-            final Object delegate =
-                webBeansContext.getProxyFactoryRemove().createDecoratorDelegate(injectionTarget,
delegateHandler);
-            // Gets component decorator stack
-            decorators = WebBeansDecoratorConfig.getDecoratorStack(injectionTarget, instance,
delegate,
-                                                                   (CreationalContextImpl<?>)this.cc);
         
-            
-            //Sets decorator stack of delegate
-            delegateHandler.setDecorators(decorators);
-        }
-        
         if (interceptorStack.size() == 0)
         {   
-            if (decoratorStack.size() == 0)
-            {
-                rv = ejbContext.proceed();
-            }
-            else 
-            {
-                // We only have decorators, so run the decorator stack directly without interceptors.

-                // The delegate handler knows about the ejbContext.proceed()
-                rv = delegateHandler.invoke(instance, method, null, arguments);    
-            }
+            // The delegate handler knows about the ejbContext.proceed()
+            rv = delegateHandler.invoke(instance, method, null, arguments);
         }
         else 
         {

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=1435108&r1=1435107&r2=1435108&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
Fri Jan 18 12:27:01 2013
@@ -28,11 +28,9 @@ import java.util.Set;
 
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Decorator;
 
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.decorator.WebBeansDecoratorRemove;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.intercept.InterceptorData;
 
@@ -61,12 +59,7 @@ public abstract class InjectionTargetBea
      */
     protected List<InterceptorData> interceptorStack = new ArrayList<InterceptorData>();
 
-    /**
-     * Decorators
-     * @deprecated will be replaced by InterceptorResolution logic and moved to InjectionTargetImpl
-     */
-    protected List<Decorator<?>> decorators = new ArrayList<Decorator<?>>();
-    
+
     protected InjectionTargetBean(WebBeansContext webBeansContext,
                                   WebBeansType webBeansType,
                                   AnnotatedType<T> annotatedType,
@@ -119,11 +112,6 @@ public abstract class InjectionTargetBea
     {
         return interceptorStack;
     }
-    
-    public List<Decorator<?>> getDecoratorStack()
-    {
-        return decorators;
-    }
 
     /**
      * {@inheritDoc}
@@ -140,22 +128,7 @@ public abstract class InjectionTargetBea
     public void validatePassivationDependencies()
     {        
         super.validatePassivationDependencies();
-        
-        //Check for interceptors and decorators
-        for(int i = 0, size = decorators.size(); i < size; i++)
-        {
-            Decorator<?> dec = decorators.get(i);
-            WebBeansDecoratorRemove<?> decorator = (WebBeansDecoratorRemove<?>)dec;
-            if(!decorator.isPassivationCapable())
-            {
-                throw new WebBeansConfigurationException(MessageFormat.format(
-                        WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0015), toString()));
-            }
-            else
-            {
-                decorator.validatePassivationDependencies();
-            }
-        }
+
         
         for(int i = 0, size = interceptorStack.size(); i < size; i++)
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java?rev=1435108&r1=1435107&r2=1435108&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
Fri Jan 18 12:27:01 2013
@@ -25,7 +25,6 @@ import java.lang.reflect.Type;
 import java.util.Set;
 
 import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Decorator;
 
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.intercept.InterceptorData;
@@ -97,14 +96,6 @@ public class ManagedBean<T> extends Inje
         }
         if(Serializable.class.isAssignableFrom(getReturnType()))
         {
-            for(Decorator<?> dec : decorators)
-            {
-                if(dec.getBeanClass() != null && !Serializable.class.isAssignableFrom(dec.getBeanClass()))
-                {
-                    isPassivationCapable = Boolean.FALSE;
-                    return false;
-                }
-            }
 
             for(InterceptorData interceptorData : interceptorStack)
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java?rev=1435108&r1=1435107&r2=1435108&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
Fri Jan 18 12:27:01 2013
@@ -36,13 +36,17 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.apache.webbeans.component.DecoratorBean;
 import org.apache.webbeans.component.WebBeansType;
+import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.OwbParametrizedTypeImpl;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.inject.impl.InjectionPointFactory;
+import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.util.ClassUtil;
 
 
@@ -51,6 +55,7 @@ import org.apache.webbeans.util.ClassUti
  */
 public class DecoratorBeanBuilder<T> extends AbstractInjectionTargetBeanBuilder<T,
DecoratorBean<T>>
 {
+    private static Logger logger = WebBeansLoggerFacade.getLogger(DecoratorBeanBuilder.class);
 
     private AnnotatedConstructor<T> constructor;
 
@@ -84,12 +89,6 @@ public class DecoratorBeanBuilder<T> ext
         return result;
     }
 
-    @Override
-    public Class<? extends Annotation> getScope()
-    {
-        // Interceptors are always Dependent scoped
-        return Dependent.class;
-    }
 
     public void defineConstructor()
     {
@@ -128,6 +127,38 @@ public class DecoratorBeanBuilder<T> ext
 
     protected void checkDecoratorConditions()
     {
+        if(getScope() != Dependent.class)
+        {
+            if(logger.isLoggable(Level.WARNING))
+            {
+                logger.log(Level.WARNING, OWBLogConst.WARN_0005_1, getBeanType().getName());
+            }
+        }
+
+        if(getName() != null)
+        {
+            if(logger.isLoggable(Level.WARNING))
+            {
+                logger.log(Level.WARNING, OWBLogConst.WARN_0005_2, getBeanType().getName());
+            }
+        }
+
+/*X TODO enable again
+        if(isAlternative())
+        {
+            if(logger.isLoggable(Level.WARNING))
+            {
+                logger.log(Level.WARNING, OWBLogConst.WARN_0005_3, getBeanType().getName());
+            }
+        }
+*/
+
+
+        if (logger.isLoggable(Level.FINE))
+        {
+            logger.log(Level.FINE, "Configuring decorator class : [{0}]", getBeanType());
+        }
+
         Set<AnnotatedMethod<? super T>> methods = getAnnotated().getMethods();
         for(AnnotatedMethod method : methods)
         {
@@ -146,6 +177,9 @@ public class DecoratorBeanBuilder<T> ext
 
     public void defineDecoratorRules()
     {
+        defineScopeType(WebBeansLoggerFacade.getTokenString(OWBLogConst.TEXT_MB_IMPL) + getBeanType()
+
+                WebBeansLoggerFacade.getTokenString(OWBLogConst.TEXT_SAME_SCOPE));
+
         checkDecoratorConditions();
 
         defineApiType();

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=1435108&r1=1435107&r2=1435108&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
Fri Jan 18 12:27:01 2013
@@ -19,7 +19,6 @@
 package org.apache.webbeans.component.creation;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 import java.util.List;
 import java.util.Set;
@@ -35,12 +34,8 @@ import org.apache.webbeans.component.Man
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.decorator.DecoratorUtil;
-import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
-import org.apache.webbeans.exception.inject.DeploymentException;
 import org.apache.webbeans.inject.impl.InjectionPointFactory;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
-import org.apache.webbeans.portable.AbstractDecoratorInjectionTarget;
 import org.apache.webbeans.util.WebBeansUtil;
 
 /**
@@ -147,60 +142,6 @@ public class ManagedBeanBuilder<T, M ext
         bean.setConstructor(constructor.getJavaMember());
     }
 
-    /**
-     * Define decorator bean.
-     * @param annotatedType
-     */
-    public ManagedBean<T> defineDecorator(AnnotatedType<T> annotatedType)
-    {
-        Class<T> clazz = annotatedType.getJavaClass();
-        if (webBeansContext.getDecoratorsManager().isDecoratorEnabled(clazz))
-        {
-            ManagedBean<T> delegate = null;
-
-            DecoratorUtil.checkDecoratorConditions(clazz);
-
-            if(Modifier.isAbstract(clazz.getModifiers()))
-            {
-                delegate = defineAbstractDecorator(annotatedType);
-            }
-            else
-            {
-                delegate = defineManagedBean(annotatedType);
-            }
-
-            if (delegate != null)
-            {
-                WebBeansDecoratorConfig.configureDecoratorClass(delegate);
-            }
-            else
-            {
-                // TODO could probably be a bit more descriptive
-                throw new DeploymentException("Cannot create Decorator for class" + annotatedType);
-            }
-            return delegate;
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-    private ManagedBean<T> defineAbstractDecorator(AnnotatedType<T> annotatedType)
-    {
-
-        ManagedBean<T> bean = defineManagedBean(annotatedType);
-        if (bean == null)
-        {
-            // TODO could probably be a bit more descriptive
-            throw new DeploymentException("Cannot create ManagedBean for class" + annotatedType);
-        }
-
-        //X TODO move proxy instance creation into JavassistProxyFactory!
-
-        bean.setProducer(new AbstractDecoratorInjectionTarget<T>(bean));
-        return bean;
-    }
 
     @Override
     protected M createBean(Set<Type> types,

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1435108&r1=1435107&r2=1435108&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
Fri Jan 18 12:27:01 2013
@@ -56,7 +56,6 @@ import org.apache.webbeans.component.Cdi
 import org.apache.webbeans.component.EnterpriseBeanMarker;
 import org.apache.webbeans.component.InterceptedMarker;
 import org.apache.webbeans.component.ManagedBean;
-import org.apache.webbeans.component.NewBean;
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.component.ProducerFieldBean;
 import org.apache.webbeans.component.ProducerMethodBean;
@@ -67,7 +66,6 @@ import org.apache.webbeans.container.Bea
 import org.apache.webbeans.container.InjectableBeanManager;
 import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.corespi.se.DefaultJndiService;
-import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
 import org.apache.webbeans.deployment.StereoTypeModel;
 import org.apache.webbeans.event.ObserverMethodImpl;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
@@ -403,22 +401,10 @@ public class BeansDeployer
                 }
                 
                 
-                if(bean instanceof InjectionTargetBean)
+                if(bean instanceof InjectionTargetBean && bean instanceof InterceptedMarker)
                 {
-                    //Decorators not applied to interceptors/decorators/@NewBean
-                    if(!(bean instanceof Decorator) && 
-                       !(bean instanceof javax.enterprise.inject.spi.Interceptor) &&
-                       !(bean instanceof NewBean))
-                    {
-                        WebBeansDecoratorConfig.configureDecorators((InjectionTargetBean<Object>)bean);
-                    }
-                    
-                    //If intercepted marker
-                    if(bean instanceof InterceptedMarker)
-                    {
-                        webBeansContext.getWebBeansInterceptorConfig().defineBeanInterceptorStack((InjectionTargetBean<Object>)
bean);
-                    }                                                            
-                }                
+                    webBeansContext.getWebBeansInterceptorConfig().defineBeanInterceptorStack((InjectionTargetBean<Object>)
bean);
+                }
                 
                 //Check passivation scope
                 checkPassivationScope(bean);

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=1435108&r1=1435107&r2=1435108&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
Fri Jan 18 12:27:01 2013
@@ -42,10 +42,8 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.DelegateHandler;
-import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
 import org.apache.webbeans.decorator.WebBeansDecoratorInterceptor;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
-import org.apache.webbeans.proxy.ProxyFactory;
 import org.apache.webbeans.util.ClassUtil;
 
 /**
@@ -135,7 +133,6 @@ import org.apache.webbeans.util.ClassUti
  * @version $Rev$ $Date$
  * 
  * @see WebBeansInterceptorConfig
- * @see WebBeansDecoratorConfig
  *
  * @deprecated the whole interceptor stack will be changed to the new ASM based proxying.
  */
@@ -235,10 +232,6 @@ public abstract class InterceptorHandler
                 //Check method is business method
                 if (webBeansContext.getInterceptorUtil().isWebBeansBusinessMethod(method))
                 {
-                    if (!injectionTarget.getDecoratorStack().isEmpty())
-                    {
-                        resolveDecoratorDelegateHandler(instance, ownerCreationalContext,
injectionTarget);
-                    }
 
                     // Run around invoke chain
                     List<InterceptorData> interceptorStack = injectionTarget.getInterceptorStack();
@@ -337,24 +330,6 @@ public abstract class InterceptorHandler
         return result;
     }
 
-    private synchronized void resolveDecoratorDelegateHandler(Object instance, CreationalContextImpl<?>
ownerCreationalContext,
-                                                              InjectionTargetBean<?>
injectionTarget)
-            throws Exception
-    {
-        if (decoratorDelegateHandler == null)
-        {
-            final DelegateHandler newDelegateHandler = new DelegateHandler(bean);
-            final ProxyFactory proxyFactory = webBeansContext.getProxyFactoryRemove();
-
-            final Object delegate = proxyFactory.createDecoratorDelegate(bean, newDelegateHandler);
-
-            // Gets component decorator stack
-            List<Object> decorators = WebBeansDecoratorConfig.getDecoratorStack(injectionTarget,
instance, delegate, ownerCreationalContext);
-            //Sets decorator stack of delegate
-            newDelegateHandler.setDecorators(decorators);
-            decoratorDelegateHandler = newDelegateHandler;
-        }
-    }
 
     /**
      * Call around invoke method of the given bean on

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=1435108&r1=1435107&r2=1435108&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
Fri Jan 18 12:27:01 2013
@@ -33,7 +33,6 @@ import org.apache.webbeans.component.Man
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
-import org.apache.webbeans.decorator.WebBeansDecoratorRemove;
 import org.apache.webbeans.intercept.InterceptorsManager;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.portable.events.generics.GProcessBean;
@@ -142,7 +141,7 @@ public class AfterBeanDiscoveryImpl impl
             }
 
 
-            webBeansContext.getDecoratorsManager().addDecorator(new WebBeansDecoratorRemove(managedBean,
(Decorator) bean));
+            webBeansContext.getDecoratorsManager().addDecorator((Decorator) bean);
             webBeansContext.getDecoratorsManager().addCustomDecoratorClass(bean.getBeanClass());
         }
         else

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=1435108&r1=1435107&r2=1435108&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
Fri Jan 18 12:27:01 2013
@@ -21,8 +21,6 @@ package org.apache.webbeans.proxy;
 import java.io.Serializable;
 import java.lang.reflect.Type;
 import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
@@ -30,21 +28,11 @@ import java.util.concurrent.ConcurrentMa
 
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.Decorator;
-
-import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.OwbBean;
-import org.apache.webbeans.component.ResourceBean;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.DelegateHandler;
-import org.apache.webbeans.decorator.WebBeansDecoratorRemove;
-import org.apache.webbeans.intercept.DependentScopedBeanInterceptorHandlerRemove;
-import org.apache.webbeans.intercept.InterceptorData;
-import org.apache.webbeans.intercept.webbeans.WebBeansInterceptorBeanPleaseRemove;
 import org.apache.webbeans.proxy.javassist.JavassistFactory;
 import org.apache.webbeans.util.ClassUtil;
-import org.apache.webbeans.util.WebBeansUtil;
 
 
 
@@ -54,11 +42,9 @@ import org.apache.webbeans.util.WebBeans
 public final class ProxyFactory
 {
 
-    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<?>>>();
@@ -108,30 +94,6 @@ public final class ProxyFactory
         return delegate;
     }
 
-    public Class<?> getResourceBeanProxyClass(ResourceBean<?, ?> resourceBean)
-    {
-        try
-        {
-            Class<?> proxyClass = resourceBeanProxyClassesRemove.get(resourceBean);
-            if (proxyClass == null)
-            {
-                proxyClass = createProxyClassRemove(resourceBean);
-
-                Class<?> oldClazz = resourceBeanProxyClassesRemove.putIfAbsent(resourceBean,
proxyClass);
-                if (oldClazz != null)
-                {
-                    return oldClazz;
-                }                
-            }
-            return proxyClass;
-        }
-        catch (Exception e)
-        {
-            WebBeansUtil.throwRuntimeExceptions(e);
-        }
-
-        return null;
-    }
 
     /**
      * @deprecated uses old proxy
@@ -143,115 +105,13 @@ public final class ProxyFactory
     }
 
     /**
-     * @deprecated uses old proxy
-     */
-    public Object createBuildInBeanProxyRemove(OwbBean<?> bean)
-    {
-        Object result = null;
-        try
-        {
-            Class<?> proxyClass = buildInBeanProxyClassesRemove.get(bean);
-            if (proxyClass == null)
-            {
-                proxyClass = createProxyClassRemove(bean);
-                buildInBeanProxyClassesRemove.putIfAbsent(bean, proxyClass);
-            }
-            result = createProxyRemove(proxyClass);
-        }
-        catch (Exception e)
-        {
-            WebBeansUtil.throwRuntimeExceptions(e);
-        }
-        return result;
-    }
-
-
-    /**
      * @deprecated uses old proxy. And will be obsolete anyway...
      */
     public  Object createDependentScopedBeanProxyRemove(OwbBean<?> bean, Object actualInstance,
CreationalContext<?> creastionalContext)
     {
 
-        List<InterceptorData> interceptors =  null;
-        List<Decorator<?>> decorators = null;
-        InjectionTargetBean<?> injectionTargetBean = null;
-        if(bean instanceof InjectionTargetBean<?>)
-        {
-            injectionTargetBean = (InjectionTargetBean<?>)bean;
-            interceptors = injectionTargetBean.getInterceptorStack();
-            decorators = injectionTargetBean.getDecoratorStack();
-        }
-        
-        if(interceptors == null && decorators == null)
-        {
-            return actualInstance;
-        }
-        
-        boolean notInInterceptorClassAndLifecycle = false;
-        if(interceptors != null && interceptors.size() > 0)
-        {
-            Iterator<InterceptorData> its = interceptors.iterator();
-            while(its.hasNext())
-            {
-                InterceptorData id = its.next();
-                if(!id.isDefinedInInterceptorClass() && id.isLifecycleInterceptor())
-                {
-                    continue;
-                }
-                notInInterceptorClassAndLifecycle = true;
-                break;
-            }
-        }
-        
-        //No need to return proxy
-        if(!notInInterceptorClassAndLifecycle && decorators.isEmpty())
-        {
-            //Adding this dependent instance into creational context
-            //This occurs when no owner of this dependent instance
-            if(creastionalContext instanceof CreationalContextImpl)
-            {
-                //If this creational context is owned by itself, add it
-                //For example, getting it directly BeanManager#getReference(bean,creational
context)
-                CreationalContextImpl<?> ccImpl = (CreationalContextImpl<?>)creastionalContext;
-                
-                //Non contextual instance --> Bean --> Null
-                //See OWBInjector
-                if(ccImpl.getBean() != null)
-                {
-                    if(ccImpl.getBean().equals(bean))
-                    {
-                        //Owner of the dependent is itself
-                        ccImpl.addDependent(actualInstance, bean, actualInstance);
-                    }                                
-                }
-            }
-            
-            return actualInstance;
-        }
-        
-        try
-        {
-            Class<?> proxyClass = dependentScopedBeanProxyClassesRemove.get(bean);
-            if (proxyClass == null)
-            {
-                proxyClass = createProxyClassRemove(bean);
-                dependentScopedBeanProxyClassesRemove.putIfAbsent(bean, proxyClass);
-            }
-
-            Object result = createProxyRemove(proxyClass);
-            if (!(bean instanceof WebBeansDecoratorRemove<?>) && !(bean instanceof
WebBeansInterceptorBeanPleaseRemove<?>))
-            {
-                setHandler(result, new DependentScopedBeanInterceptorHandlerRemove(bean,
actualInstance, creastionalContext));
-            }
+        throw new RuntimeException("Bloody Mary! this must not get used anymore!");
 
-            return result;
-        }
-        catch (Exception e)
-        {
-            WebBeansUtil.throwRuntimeExceptions(e);
-        }
-
-        return null;
     }
 
     /**
@@ -268,19 +128,6 @@ public final class ProxyFactory
         return createProxyClassRemove(bean);
     }
 
-    /**
-     * @deprecated uses old proxy
-     */
-    public boolean isProxyInstanceRemove(Object o)
-    {
-        return factoryRemove.isProxyInstance(o);
-    }
-
-    public Object createProxy(MethodHandler handler, Class<?>[] interfaces)
-        throws IllegalAccessException, InstantiationException
-    {
-        return factoryRemove.createProxy(handler, interfaces);
-    }
 
     /**
      * @deprecated uses old proxy

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=1435108&r1=1435107&r2=1435108&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
Fri Jan 18 12:27:01 2013
@@ -50,7 +50,6 @@ import javax.enterprise.inject.Alternati
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.IllegalProductException;
 import javax.enterprise.inject.Instance;
-import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.spi.AfterBeanDiscovery;
 import javax.enterprise.inject.spi.AfterDeploymentValidation;
@@ -116,7 +115,6 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.ExternalScope;
 import org.apache.webbeans.container.InjectionResolver;
-import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.inject.DefinitionException;
 import org.apache.webbeans.exception.inject.InconsistentSpecializationException;
@@ -127,7 +125,6 @@ import org.apache.webbeans.logger.WebBea
 import org.apache.webbeans.plugins.OpenWebBeansEjbLCAPlugin;
 import org.apache.webbeans.plugins.PluginLoader;
 import org.apache.webbeans.portable.ProducerFieldProducer;
-import org.apache.webbeans.portable.ProducerMethodProducer;
 import org.apache.webbeans.portable.events.discovery.ErrorStack;
 import org.apache.webbeans.portable.events.generics.GProcessAnnotatedType;
 import org.apache.webbeans.portable.events.generics.GProcessBean;
@@ -645,8 +642,6 @@ public final class WebBeansUtil
     {
         ConversationBean conversationComp = new ConversationBean(webBeansContext);
 
-        WebBeansDecoratorConfig.configureDecorators(conversationComp);
-
         return conversationComp;
     }
 
@@ -2285,7 +2280,6 @@ public final class WebBeansUtil
         managedBeanCreator.defineProducerFields(managedBean);
         managedBeanCreator.defineObserverMethods(managedBean);
 
-        WebBeansDecoratorConfig.configureDecorators(managedBean);
         webBeansContext.getWebBeansInterceptorConfig().defineBeanInterceptorStack(managedBean);
 
         managedBeanCreator.validateDisposalMethods(managedBean);//Define disposal method
after adding producers
@@ -2429,7 +2423,6 @@ public final class WebBeansUtil
         managedBeanCreator.defineProducerMethods(managedBean);
         managedBeanCreator.defineProducerFields(managedBean);
         managedBeanCreator.defineObserverMethods(managedBean);
-        WebBeansDecoratorConfig.configureDecorators(managedBean);
         webBeansContext.getWebBeansInterceptorConfig().defineBeanInterceptorStack(managedBean);
 
         managedBeanCreator.validateDisposalMethods(managedBean); //Define disposal method
after adding producers
@@ -2437,70 +2430,6 @@ public final class WebBeansUtil
         return managedBean;
     }
 
-    @SuppressWarnings("unchecked")
-    public <T> ManagedBean<T> defineAbstractDecorator(AnnotatedType<T>
type)
-    {
-
-        ManagedBean<T> bean = defineManagedBean(type);
-
-        //X TODO move proxy instance creation into JavassistProxyFactory!
-        Class clazz = webBeansContext.getProxyFactoryRemove().createAbstractDecoratorProxyClass(bean);
-
-        bean.setConstructor(defineConstructor(clazz));
-        return bean;
-    }
-
-    /**
-     * Define decorator bean.
-     * @param <T> type info
-     * @param annotatedType decorator class
-     */
-    public <T> ManagedBean<T> defineDecorator(AnnotatedType<T> annotatedType)
-    {
-        if (webBeansContext.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);
-            }
-            return delegate;
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-
     /**
      * Checks the implementation class for checking conditions.
      *

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java?rev=1435108&r1=1435107&r2=1435108&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
Fri Jan 18 12:27:01 2013
@@ -46,19 +46,17 @@ import org.apache.webbeans.component.Man
 import org.apache.webbeans.component.ProducerFieldBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.component.WebBeansType;
+import org.apache.webbeans.component.creation.DecoratorBeanBuilder;
 import org.apache.webbeans.component.creation.ManagedBeanBuilder;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.context.DependentContext;
 import org.apache.webbeans.decorator.DecoratorUtil;
-import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
 import org.apache.webbeans.deployment.StereoTypeModel;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.portable.InjectionTargetImpl;
-import org.apache.webbeans.portable.ProducerFieldProducer;
-import org.apache.webbeans.portable.ProducerMethodProducer;
 import org.apache.webbeans.portable.events.generics.GProcessAnnotatedType;
 import org.apache.webbeans.test.component.decorator.broken.DelegateAttributeIsnotInterface;
 import org.apache.webbeans.test.component.decorator.broken.DelegateAttributeMustImplementAllDecoratedTypes;
@@ -284,7 +282,6 @@ public abstract class TestContext implem
         if (bean != null)
         {
             DecoratorUtil.checkManagedBeanDecoratorConditions(bean,null);
-            WebBeansDecoratorConfig.configureDecorators(bean);
             webBeansContext.getWebBeansInterceptorConfig().defineBeanInterceptorStack(bean);
 
             getComponents().add((AbstractOwbBean<?>) bean);
@@ -332,21 +329,18 @@ public abstract class TestContext implem
     @SuppressWarnings("unchecked")
     protected <T> AbstractOwbBean<T> defineDecorator(Class<T> clazz)
     {
-        ManagedBean<T> component = null;
 
         WebBeansContext webBeansContext = WebBeansContext.getInstance();
         if (webBeansContext.getDecoratorsManager().isDecoratorEnabled(clazz))
         {
-            DecoratorUtil.checkDecoratorConditions(clazz);
-            component = define(clazz, WebBeansType.DECORATOR, webBeansContext.getAnnotatedElementFactory().newAnnotatedType(clazz));
+            AnnotatedType<T> annotatedType = webBeansContext.getBeanManagerImpl().createAnnotatedType(clazz);
+            DecoratorBeanBuilder<T> dbb = new DecoratorBeanBuilder<T>(webBeansContext,
annotatedType);
+            dbb.defineDecoratorRules();
 
-            if (component != null)
-            {
-                WebBeansDecoratorConfig.configureDecoratorClass((ManagedBean<Object>)
component);
-            }
+            return dbb.getBean();
         }
 
-        return component;
+        return null;
     }
 
     /**



Mime
View raw message