openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1436524 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
Date Mon, 21 Jan 2013 18:11:03 GMT
Author: struberg
Date: Mon Jan 21 18:11:02 2013
New Revision: 1436524

URL: http://svn.apache.org/viewvc?rev=1436524&view=rev
Log:
OWB_344 adopt our eventing to the new split proxies

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java?rev=1436524&r1=1436523&r2=1436524&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
Mon Jan 21 18:11:02 2013
@@ -59,6 +59,7 @@ import org.apache.webbeans.logger.WebBea
 import org.apache.webbeans.portable.AnnotatedElementFactory;
 import org.apache.webbeans.portable.EventProducer;
 import org.apache.webbeans.portable.InjectionPointProducer;
+import org.apache.webbeans.proxy.OwbNormalScopeProxy;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -198,7 +199,6 @@ public class ObserverMethodImpl<T> imple
 
         Object object = null;
         
-        CreationalContext<Object> creationalContext = null;
         List<ObserverParams> methodArgsMap;
         if(annotatedMethod == null)
         {
@@ -208,16 +208,14 @@ public class ObserverMethodImpl<T> imple
         {
             methodArgsMap = getAnnotatedMethodArguments(event);
         }
-        
+
+        BeanManagerImpl manager = bean.getWebBeansContext().getBeanManagerImpl();
+        CreationalContext<Object> creationalContext = manager.createCreationalContext(component);
+
+
         ObserverParams[] obargs = null;
         try
         {
-            boolean isPrivateMethod = !observerMethod.isAccessible();
-            if (isPrivateMethod)
-            {
-                bean.getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(observerMethod,
true);
-            }
-
             obargs = new ObserverParams[methodArgsMap.size()];
             obargs = methodArgsMap.toArray(obargs);
             Object[] args = new Object[obargs.length];
@@ -230,12 +228,15 @@ public class ObserverMethodImpl<T> imple
             //Static or not
             if (Modifier.isStatic(observerMethod.getModifiers()))
             {
+                if (!observerMethod.isAccessible())
+                {
+                    observerMethod.setAccessible(true);
+                }
                 //Invoke Method
-                observerMethod.invoke(object, args);
+                observerMethod.invoke(null, args);
             }
             else
             {
-                BeanManagerImpl manager = bean.getWebBeansContext().getBeanManagerImpl();
                 Context context;
                 try
                 {
@@ -257,25 +258,14 @@ public class ObserverMethodImpl<T> imple
                     return;
                 }
 
-                creationalContext = manager.createCreationalContext(component);
-
-                if (isPrivateMethod)
+                if (object == null)
                 {
-                    // since private methods cannot be intercepted, we can just call them
directly
-                    // so we get the contextual instance directly from the context because
we do not
-                    // proxy private methods (thus the invocation on the contextual reference
would fail)
-                    if (object == null)
-                    {
-                        object = context.get(component, creationalContext);
-                    }
+                    object = context.get(component, creationalContext);
                 }
-                else
+
+                if (object == null)
                 {
-                    // on Reception.ALWAYS we must get a contextual reference if we didn't
find the contextual instance
-                    // we need to pick the contextual reference because of section 7.2:
-                    //  "Invocations of producer, disposer and observer methods by the container
are
-                    //  business method invocations and are in- tercepted by method interceptors
and decorators."
-                    
+                    // this might happen for EJB components.
                     Type t = component.getBeanClass();
 
                     // If the bean is an EJB, its beanClass may not be one of
@@ -286,10 +276,25 @@ public class ObserverMethodImpl<T> imple
                     }
 
                     object = manager.getReference(component, t, creationalContext);
+
                 }
 
                 if (object != null)
                 {
+                    if (!observerMethod.isAccessible())
+                    {
+                        bean.getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(observerMethod,
true);
+                    }
+
+                    if (Modifier.isPrivate(observerMethod.getModifiers()))
+                    {
+                        // since private methods cannot be intercepted, we have to unwrap
anny possible proxy
+                        if (object instanceof OwbNormalScopeProxy)
+                        {
+                            object = getWebBeansContext().getInterceptorDecoratorProxyFactory().getInternalInstance(object);
+                        }
+                    }
+
                     //Invoke Method
                     observerMethod.invoke(object, args);
                 }



Mime
View raw message