openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r911634 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/container/ main/java/org/apache/webbeans/decorator/ main/java/org/apache/webbeans/intercept/ main/java/org/apache/web...
Date Thu, 18 Feb 2010 22:57:37 GMT
Author: gerdogdu
Date: Thu Feb 18 22:57:37 2010
New Revision: 911634

URL: http://svn.apache.org/viewvc?rev=911634&view=rev
Log:
[OWB-285] Interceptor and Decorator instances must be @Dependent scoped

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/DependentDecorator.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/IDestroy.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/MyDestory.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/DependentDecoratorDestroyTest.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/DependentDecoratorDestroy.xml
  (with props)
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.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/decorator/WebBeansDecoratorConfig.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java?rev=911634&r1=911633&r2=911634&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
Thu Feb 18 22:57:37 2010
@@ -127,7 +127,7 @@
             getInjectionTarget().inject(instance, creationalContext);
             
             //Call @PostConstrcut
-            postConstruct(instance);
+            postConstruct(instance, creationalContext);
         }
         //Default operations
         else
@@ -186,7 +186,7 @@
      */
     protected void destroyInstance(T instance, CreationalContext<T> creationalContext)
     {
-        destroyComponentInstance(instance);
+        destroyComponentInstance(instance,creationalContext);
     }
 
     /**
@@ -205,9 +205,9 @@
      * 
      * @param instance object instance.
      */
-    protected void destroyComponentInstance(T instance)
+    protected void destroyComponentInstance(T instance, CreationalContext<T> creationalContext)
     {
-        preDestroy(instance);
+        preDestroy(instance, creationalContext);
     }
 
     /**
@@ -239,13 +239,13 @@
         injectMethods(instance, creationalContext);
         
         //Post construct
-        postConstruct(instance);
+        postConstruct(instance, creationalContext);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void postConstruct(T instance)
+    public void postConstruct(T instance, CreationalContext<T> cretionalContext)
     {
         if (isInjectionTargetSet())
         {
@@ -253,7 +253,7 @@
         }
         else
         {
-            postConstructDefault(instance);
+            postConstructDefault(instance, cretionalContext);
         }
     }
 
@@ -262,14 +262,14 @@
      * 
      * @param instance bean instance
      */
-    protected void postConstructDefault(T instance)
+    protected void postConstructDefault(T instance, CreationalContext<T> ownerCreationalContext)
     {
         if(getWebBeansType().equals(WebBeansType.MANAGED))
         {
             // Call Post Construct
             if (WebBeansUtil.isContainsInterceptorMethod(getInterceptorStack(), InterceptorType.POST_CONSTRUCT))
             {
-                InterceptorHandler.injectInterceptorFields(getInterceptorStack());
+                InterceptorHandler.injectInterceptorFields(getInterceptorStack(), (CreationalContextImpl<T>)ownerCreationalContext);
                 
                 InvocationContextImpl impl = new InvocationContextImpl(null, instance, null,
null, WebBeansUtil.getInterceptorMethods(getInterceptorStack(), InterceptorType.POST_CONSTRUCT),
InterceptorType.POST_CONSTRUCT);
                 try
@@ -289,7 +289,7 @@
     /**
      * {@inheritDoc}
      */
-    public void preDestroy(T instance)
+    public void preDestroy(T instance, CreationalContext<T> creationalContext)
     {
         if (isInjectionTargetSet())
         {
@@ -297,7 +297,7 @@
         }
         else
         {
-            preDestroyDefault(instance);
+            preDestroyDefault(instance, creationalContext);
         }
     }
 
@@ -306,13 +306,14 @@
      * 
      * @param instance bean instance
      */
-    protected void preDestroyDefault(T instance)
+    protected void preDestroyDefault(T instance, CreationalContext<T> creationalContext)
     {
-        if(getWebBeansType().equals(WebBeansType.MANAGED))
+        if(getWebBeansType().equals(WebBeansType.MANAGED) ||
+                getWebBeansType().equals(WebBeansType.DECORATOR))                
         {
             if (WebBeansUtil.isContainsInterceptorMethod(getInterceptorStack(), InterceptorType.PRE_DESTROY))
             {
-                InterceptorHandler.injectInterceptorFields(getInterceptorStack());
+                InterceptorHandler.injectInterceptorFields(getInterceptorStack(),(CreationalContextImpl<T>)
creationalContext);
                 
                 InvocationContextImpl impl = new InvocationContextImpl(null, instance, null,
null, WebBeansUtil.getInterceptorMethods(getInterceptorStack(), InterceptorType.PRE_DESTROY),
InterceptorType.PRE_DESTROY);
                 try

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java?rev=911634&r1=911633&r2=911634&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
Thu Feb 18 22:57:37 2010
@@ -51,7 +51,7 @@
      * {@inheritDoc}
      */
     @Override
-    protected void destroyComponentInstance(T instance)
+    protected void destroyComponentInstance(T instance, CreationalContext<T> creationalContext)
     {
         
     }

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=911634&r1=911633&r2=911634&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
Thu Feb 18 22:57:37 2010
@@ -25,6 +25,7 @@
 import javax.enterprise.inject.spi.ProcessInjectionTarget;
 
 import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.intercept.InterceptorData;
 
 /**
@@ -176,14 +177,14 @@
      * 
      * @param instance bean instance
      */
-    public void postConstruct(T instance);
+    public void postConstruct(T instance, CreationalContext<T> creationalContext);
     
     /**
      * Calls predestroy method.
      * 
      * @param instance bean instance
      */
-    public void preDestroy(T instance);    
+    public void preDestroy(T instance, CreationalContext<T> creationalContext);   

     
     /**
      * Sets annotated type.

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=911634&r1=911633&r2=911634&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
Thu Feb 18 22:57:37 2010
@@ -786,7 +786,7 @@
             
             
             instance = context.get((Bean<Object>)bean, (CreationalContext<Object>)creationalContext);
    
-            instance = JavassistProxyFactory.createDependentScopedBeanProxy((AbstractOwbBean<?>)bean,
instance);
+            instance = JavassistProxyFactory.createDependentScopedBeanProxy((AbstractOwbBean<Object>)bean,
instance, (CreationalContext<Object>)creationalContext);
         }
         
         return 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=911634&r1=911633&r2=911634&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
Thu Feb 18 22:57:37 2010
@@ -301,7 +301,7 @@
     {
         Context context = BeanManagerImpl.getManager().getContext(getScope());
         Object actualInstance = context.get((Bean<Object>)this.wrappedBean, (CreationalContext<Object>)creationalContext);
-        T proxy = (T)JavassistProxyFactory.createDependentScopedBeanProxy(this.wrappedBean,
actualInstance);
+        T proxy = (T)JavassistProxyFactory.createDependentScopedBeanProxy(this.wrappedBean,
actualInstance, creationalContext);
         
         return proxy;        
     }
@@ -358,13 +358,7 @@
         InjectableMethods m = new InjectableMethods(method, instance, this.wrappedBean, creationalContext);
         m.doInjection();        
     }
-    
-    
-    public void destroy(T instance,CreationalContext<T> context)
-    {
-        wrappedBean.destroy(instance,context);
-    }
-
+        
     @Override
     public Set<Annotation> getQualifiers()
     {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java?rev=911634&r1=911633&r2=911634&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
Thu Feb 18 22:57:37 2010
@@ -30,6 +30,7 @@
 import org.apache.webbeans.component.AbstractInjectionTargetBean;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.xml.WebBeansXMLDecorator;
 import org.apache.webbeans.inject.xml.XMLInjectionPointModel;
 import org.apache.webbeans.logger.WebBeansLogger;
@@ -73,7 +74,8 @@
         }
     }
     
-    public static List<Object> getDecoratorStack(InjectionTargetBean<?> component,
Object instance, Object delegate)
+    public static List<Object> getDecoratorStack(InjectionTargetBean<?> component,
Object instance, 
+            Object delegate, CreationalContextImpl<?> ownerCreationalContext)
     {
         List<Object> decoratorStack = new ArrayList<Object>();
         List<Decorator<?>> decoratorList = component.getDecoratorStack();   
    
@@ -81,13 +83,15 @@
         BeanManager manager = BeanManagerImpl.getManager();
         while (itList.hasNext())
         {
-            WebBeansDecorator<?> decorator = (WebBeansDecorator<?>) itList.next();
-            CreationalContext<?> creationalContext = manager.createCreationalContext(decorator);
+            WebBeansDecorator<Object> decorator = (WebBeansDecorator<Object>)
itList.next();
+            CreationalContext<Object> creationalContext = manager.createCreationalContext(decorator);
             Object decoratorInstance = manager.getReference(decorator, decorator.getBeanClass(),
creationalContext);
             
             decorator.setInjections(decoratorInstance, creationalContext);
             decorator.setDelegate(decoratorInstance, delegate);
             decoratorStack.add(decoratorInstance);
+            
+            ownerCreationalContext.addDependent(decorator, decoratorInstance, creationalContext);
         }
 
         return decoratorStack;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java?rev=911634&r1=911633&r2=911634&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java
Thu Feb 18 22:57:37 2010
@@ -21,7 +21,10 @@
 import java.lang.reflect.Method;
 import java.util.List;
 
+import javax.enterprise.context.spi.CreationalContext;
+
 import org.apache.webbeans.component.AbstractOwbBean;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
 
 public class DependentScopedBeanInterceptorHandler extends InterceptorHandler
 {
@@ -29,17 +32,19 @@
     
     private Object actualInstance;
     
-    public DependentScopedBeanInterceptorHandler(AbstractOwbBean<?> bean, Object instance)
+    private CreationalContext<?> creationalContext;
+    
+    public DependentScopedBeanInterceptorHandler(AbstractOwbBean<?> bean, Object instance,
CreationalContext<?> creationalContext)
     {
-        super(bean);
-        
+        super(bean);        
         this.actualInstance = instance;
+        this.creationalContext = creationalContext;
     }
 
     @Override
     public Object invoke(Object instance, Method method, Method proceed, Object[] arguments)
throws Exception
     {
-        return super.invoke(this.actualInstance, method, proceed, arguments);
+        return super.invoke(this.actualInstance, method, proceed, arguments, (CreationalContextImpl<?>)creationalContext);
     }
     
     protected <T> Object callAroundInvokes(Method proceed, Object[] arguments, List<InterceptorData>
stack) throws Exception

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java?rev=911634&r1=911633&r2=911634&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
Thu Feb 18 22:57:37 2010
@@ -37,6 +37,7 @@
 import org.apache.webbeans.config.BeansDeployer;
 import org.apache.webbeans.config.DefinitionUtil;
 import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.DelegateHandler;
 import org.apache.webbeans.decorator.WebBeansDecorator;
 import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
@@ -150,7 +151,7 @@
         this.bean = bean;
     }
 
-    public Object invoke(Object instance, Method method, Method proceed, Object[] arguments)
throws Exception
+    public Object invoke(Object instance, Method method, Method proceed, Object[] arguments,
CreationalContextImpl<?> ownerCreationalContext) throws Exception
     {
         try
         {
@@ -173,7 +174,7 @@
                         Object delegate = delegateFactory.createClass().newInstance();
 
                         // Gets component decorator stack
-                        decorators = WebBeansDecoratorConfig.getDecoratorStack(injectionTarget,
instance, delegate);
+                        decorators = WebBeansDecoratorConfig.getDecoratorStack(injectionTarget,
instance, delegate, ownerCreationalContext);
 
                         delegateHandler.setDecorators(decorators);
                     }
@@ -184,7 +185,7 @@
                     List<InterceptorData> temp = new ArrayList<InterceptorData>(stack);
 
                     // Filter both EJB and WebBeans interceptors
-                    filterCommonInterceptorStackList(temp, method);
+                    filterCommonInterceptorStackList(temp, method, ownerCreationalContext);
 
                     // If there are both interceptors and decorators, add hook
                     // point to the end of the interceptor stack.
@@ -294,7 +295,7 @@
         return false;
     }
 
-    private void filterCommonInterceptorStackList(final List<InterceptorData> stack,
Method method)
+    private void filterCommonInterceptorStackList(final List<InterceptorData> stack,
Method method, CreationalContextImpl<?> ownerCreationalContext)
     {
         Iterator<InterceptorData> it = stack.iterator();
         while (it.hasNext())
@@ -307,11 +308,11 @@
             }
         }
         
-        injectInterceptorFields(stack);
+        injectInterceptorFields(stack, ownerCreationalContext);
     }
     
     
-    public static void injectInterceptorFields(final List<InterceptorData> stack)
+    public static void injectInterceptorFields(final List<InterceptorData> stack, CreationalContextImpl<?>
ownerCreationalContext)
     {
         Iterator<InterceptorData> it = stack.iterator();
         BeanManager manager = BeanManagerImpl.getManager();
@@ -325,14 +326,16 @@
                 {
                     if (intData.isDefinedWithWebBeansInterceptor())
                     {
-                        WebBeansInterceptor<?> interceptor = (WebBeansInterceptor<?>)intData.getWebBeansInterceptor();
-                        CreationalContext<?> creationalContext = manager.createCreationalContext(interceptor);
+                        WebBeansInterceptor<Object> interceptor = (WebBeansInterceptor<Object>)intData.getWebBeansInterceptor();
+                        CreationalContext<Object> creationalContext = manager.createCreationalContext(interceptor);
                         Object interceptorProxy = manager.getReference(interceptor,interceptor.getBeanClass(),
creationalContext);
                         
                         interceptor.setInjections(interceptorProxy, creationalContext);
 
                         //Setting interceptor proxy instance
                         intData.setInterceptorInstance(interceptorProxy);
+                        
+                        ownerCreationalContext.addDependent(interceptor, interceptorProxy,
creationalContext);
                     }
 
                 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java?rev=911634&r1=911633&r2=911634&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
Thu Feb 18 22:57:37 2010
@@ -27,6 +27,7 @@
 
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
 
 public class NormalScopedBeanInterceptorHandler extends InterceptorHandler 
 {
@@ -82,7 +83,7 @@
         }
 
 
-        return super.invoke(webbeansInstance, method, proceed, arguments);
+        return super.invoke(webbeansInstance, method, proceed, arguments, (CreationalContextImpl<?>)creationalContxt.get());
     }
     
     protected <T> Object callAroundInvokes(Method proceed, Object[] arguments, List<InterceptorData>
stack) throws Exception

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=911634&r1=911633&r2=911634&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
Thu Feb 18 22:57:37 2010
@@ -279,7 +279,7 @@
     {
         Context context = BeanManagerImpl.getManager().getContext(getScope());
         Object actualInstance = context.get((Bean<Object>)this.delegateBean, (CreationalContext<Object>)creationalContext);
-        T proxy = (T)JavassistProxyFactory.createDependentScopedBeanProxy(this.delegateBean,
actualInstance);
+        T proxy = (T)JavassistProxyFactory.createDependentScopedBeanProxy(this.delegateBean,
actualInstance, creationalContext);
         
         return proxy;
     }
@@ -328,12 +328,6 @@
         m.doInjection();        
     }
     
-
-    public void destroy(T instance,CreationalContext<T> context)
-    {
-        delegateBean.destroy(instance,context);
-    }
-
     @Override
     public Set<Annotation> getQualifiers()
     {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducer.java?rev=911634&r1=911633&r2=911634&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducer.java
Thu Feb 18 22:57:37 2010
@@ -51,7 +51,7 @@
         @SuppressWarnings("unchecked")
         InjectionTargetBean<T> bean = getBean(InjectionTargetBean.class);
         
-        bean.postConstruct(instance);
+        bean.postConstruct(instance,null);
     }
 
     @Override
@@ -60,7 +60,7 @@
         @SuppressWarnings("unchecked")
         InjectionTargetBean<T> bean = getBean(InjectionTargetBean.class);
         
-        bean.preDestroy(instance);
+        bean.preDestroy(instance,null);
     }
 
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java?rev=911634&r1=911633&r2=911634&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
Thu Feb 18 22:57:37 2010
@@ -67,7 +67,7 @@
         return result;
     }
     
-    public static Object createDependentScopedBeanProxy(AbstractOwbBean<?> bean, Object
actualInstance)
+    public static Object createDependentScopedBeanProxy(AbstractOwbBean<?> bean, Object
actualInstance, CreationalContext<?> creastionalContext)
     {
         Object result = null;
         
@@ -117,7 +117,7 @@
 
             if (!(bean instanceof WebBeansDecorator) && !(bean instanceof WebBeansInterceptor))
             {
-                fact.setHandler(new DependentScopedBeanInterceptorHandler(bean, actualInstance));
+                fact.setHandler(new DependentScopedBeanInterceptorHandler(bean, actualInstance,
creastionalContext));
             }
 
             result = fact.createClass().newInstance();

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/DependentDecorator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/DependentDecorator.java?rev=911634&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/DependentDecorator.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/DependentDecorator.java
Thu Feb 18 22:57:37 2010
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.decorators.dependent;
+
+import javax.annotation.PreDestroy;
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+@Decorator
+public class DependentDecorator implements IDestroy
+{
+    private @Inject @Delegate IDestroy destroy;
+    public static boolean dispose = false;
+
+    @Override
+    public void destroy()
+    {
+        destroy.destroy();
+        
+    }
+    
+    @PreDestroy
+    public void dispose()
+    {
+        dispose = true;
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/DependentDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/IDestroy.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/IDestroy.java?rev=911634&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/IDestroy.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/IDestroy.java
Thu Feb 18 22:57:37 2010
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.decorators.dependent;
+
+public interface IDestroy
+{
+    public void destroy();
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/IDestroy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/MyDestory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/MyDestory.java?rev=911634&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/MyDestory.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/MyDestory.java
Thu Feb 18 22:57:37 2010
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.decorators.dependent;
+
+import org.apache.webbeans.test.component.event.normal.Transactional;
+
+public class MyDestory implements IDestroy
+{
+    public static boolean destroyed = false;
+
+    @Override
+    @Transactional
+    public void destroy()
+    {
+        destroyed = true;
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/dependent/MyDestory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/DependentDecoratorDestroyTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/DependentDecoratorDestroyTest.java?rev=911634&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/DependentDecoratorDestroyTest.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/DependentDecoratorDestroyTest.java
Thu Feb 18 22:57:37 2010
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.decorators.tests;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.AnnotationLiteral;
+
+import junit.framework.Assert;
+
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.apache.webbeans.newtests.decorators.dependent.DependentDecorator;
+import org.apache.webbeans.newtests.decorators.dependent.IDestroy;
+import org.apache.webbeans.newtests.decorators.dependent.MyDestory;
+import org.apache.webbeans.test.component.event.normal.TransactionalInterceptor;
+import org.junit.Test;
+
+public class DependentDecoratorDestroyTest extends AbstractUnitTest
+{
+    public static final String PACKAGE_NAME = DependentDecoratorDestroyTest.class.getPackage().getName();
+
+    @Test
+    @SuppressWarnings("unchecked")    
+    public void testDecoratorStack()
+    {
+        Collection<Class<?>> classes = new ArrayList<Class<?>>();
+        classes.add(DependentDecorator.class);
+        classes.add(TransactionalInterceptor.class);
+        classes.add(MyDestory.class);
+
+        Collection<URL> xmls = new ArrayList<URL>();
+        xmls.add(getXMLUrl(PACKAGE_NAME, "DependentDecoratorDestroy"));
+
+        startContainer(classes, xmls);
+        
+        @SuppressWarnings("serial")
+        Bean<IDestroy> bean = (Bean<IDestroy>)getBeanManager().getBeans(IDestroy.class,
new AnnotationLiteral<Default>()
+                {
+                }).iterator().next();
+        CreationalContext<IDestroy> creationalContext = getBeanManager().createCreationalContext(bean);
+        Object instance = getBeanManager().getReference(bean, IDestroy.class, creationalContext);
+        IDestroy outputProvider = (IDestroy) instance;
+        
+        Assert.assertTrue(outputProvider != null);
+        outputProvider.destroy();
+        Assert.assertTrue(MyDestory.destroyed);
+        
+        bean.destroy(outputProvider,creationalContext);
+        
+        Assert.assertTrue(DependentDecorator.dispose);
+
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/DependentDecoratorDestroyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/DependentDecoratorDestroy.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/DependentDecoratorDestroy.xml?rev=911634&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/DependentDecoratorDestroy.xml
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/DependentDecoratorDestroy.xml
Thu Feb 18 22:57:37 2010
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<beans>
+	<interceptors>
+		<class>org.apache.webbeans.test.component.event.normal.TransactionalInterceptor</class>
+	</interceptors>
+   <decorators>
+      <class>org.apache.webbeans.newtests.decorators.dependent.DependentDecorator</class>
+   </decorators>
+</beans>
\ No newline at end of file

Propchange: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/DependentDecoratorDestroy.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message