openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1433689 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: intercept/DefaultInterceptorHandler.java portable/InjectionTargetImpl.java
Date Tue, 15 Jan 2013 22:05:44 GMT
Author: struberg
Date: Tue Jan 15 22:05:43 2013
New Revision: 1433689

URL: http://svn.apache.org/viewvc?rev=1433689&view=rev
Log:
OWB-344 do postConstruct and preDestroy on internal instance

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DefaultInterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java

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=1433689&r1=1433688&r2=1433689&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 22:05:43 2013
@@ -44,6 +44,11 @@ public class DefaultInterceptorHandler<T
         this.interceptors = interceptors;
     }
 
+    public T getTarget()
+    {
+        return target;
+    }
+
     public Map<Interceptor<?>, ?> getInstances()
     {
         return instances;

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=1433689&r1=1433688&r2=1433689&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 22:05:43 2013
@@ -235,7 +235,7 @@ public class InjectionTargetImpl<T> exte
     }
 
     @Override
-    public void postConstruct(T instance)
+    public void postConstruct(final T instance)
     {
         if (postConstructMethods == null)
         {
@@ -245,6 +245,7 @@ public class InjectionTargetImpl<T> exte
 
         Map<Interceptor<?>, ?> interceptorInstances = null;
         List<Interceptor<?>> postConstructInterceptors = null;
+        T internalInstance = instance;
 
         if (interceptorInfo != null && instance instanceof OwbInterceptorProxy)
         {
@@ -254,13 +255,14 @@ public class InjectionTargetImpl<T> exte
             {
                 DefaultInterceptorHandler dih = (DefaultInterceptorHandler) ih;
                 interceptorInstances = dih.getInstances();
+                internalInstance = (T) dih.getTarget();
             }
 
             // 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,
+        InvocationContext ic = new LifecycleInterceptorInvocationContext<T>(internalInstance,
InterceptionType.POST_CONSTRUCT, postConstructInterceptors,
                                                                             interceptorInstances,
postConstructMethods);
         try
         {
@@ -280,7 +282,27 @@ public class InjectionTargetImpl<T> exte
             return;
         }
 
-        InvocationContext ic = new LifecycleInterceptorInvocationContext<T>(instance,
InterceptionType.PRE_DESTROY, null, null, preDestroyMethods);
+        Map<Interceptor<?>, ?> interceptorInstances = null;
+        List<Interceptor<?>> preDestroyInterceptors = null;
+        T internalInstance = instance;
+
+        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();
+                internalInstance = (T) dih.getTarget();
+            }
+
+            // we are cheating a bit right now. We could also calculate the real ones upfront
+            preDestroyInterceptors = new ArrayList<Interceptor<?>>(interceptorInfo.getInterceptors());
+        }
+
+        InvocationContext ic = new LifecycleInterceptorInvocationContext<T>(instance,
InterceptionType.PRE_DESTROY, preDestroyInterceptors,
+                                                                            interceptorInstances,
preDestroyMethods);
         try
         {
             ic.proceed();



Mime
View raw message