openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1131302 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/decorator/ webbeans-impl/src/m...
Date Sat, 04 Jun 2011 01:19:59 GMT
Author: djencks
Date: Sat Jun  4 01:19:58 2011
New Revision: 1131302

URL: http://svn.apache.org/viewvc?rev=1131302&view=rev
Log:
OWB-581 allow configuration of ignored Decorator interfaces with a configuration property

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/config/OpenWebBeansConfiguration.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.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=1131302&r1=1131301&r2=1131302&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
Sat Jun  4 01:19:58 2011
@@ -551,7 +551,10 @@ public class OpenWebBeansEjbInterceptor 
                 WebBeansDecoratorInterceptor lastInterceptor = new WebBeansDecoratorInterceptor(delegateHandler,
instance);
                 decoratorInterceptorDataImpl = new InterceptorDataImpl(true, lastInterceptor,
webBeansContext);
                 decoratorInterceptorDataImpl.setDefinedInInterceptorClass(true);
-                decoratorInterceptorDataImpl.setAroundInvoke(webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(lastInterceptor.getClass())[0]);
+                decoratorInterceptorDataImpl.setAroundInvoke(
+                        webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(lastInterceptor.getClass(),
+                                "invokeDecorators",
+                                new Class[] {InvocationContext.class}));
                 filteredInterceptorStack.add(decoratorInterceptorDataImpl);
             }
             

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java?rev=1131302&r1=1131301&r2=1131302&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
Sat Jun  4 01:19:58 2011
@@ -118,6 +118,13 @@ public class OpenWebBeansConfiguration
     public static final String USE_BDA_BEANSXML_SCANNER = "org.apache.webbeans.useBDABeansXMLScanner";
 
     /**
+     * a comma-separated list of fully qualified class names that should be ignored
+     * when determining if a decorator matches its delegate.  These are typically added by
+     * weaving or bytecode modification.
+     */
+    public static final String IGNORED_DECORATOR_INTERFACES = "org.apache.webbeans.ignoredDecoratorInterfaces";
+
+    /**
      * you can configure this externally as well.
      *
      * @param properties

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=1131302&r1=1131301&r2=1131302&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
Sat Jun  4 01:19:58 2011
@@ -23,6 +23,7 @@ import org.apache.webbeans.component.Abs
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.config.OWBLogConst;
+import org.apache.webbeans.config.OpenWebBeansConfiguration;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.WebBeansException;
@@ -46,7 +47,10 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 /**
@@ -79,20 +83,23 @@ public class WebBeansDecorator<T> extend
     
     /**Custom Decorator*/
     private Decorator<T> customDecorator = null;
+
+    private final Set<String> ignoredDecoratorInterfaces;
     
     /**
-     * Creates a new decorator bean instance with the given wrapped bean.
+     * Creates a new decorator bean instance with the given wrapped bean and custom decorator
bean.
      * @param wrappedBean wrapped bean instance
+     * @param customDecorator custom decorator
      */
     public WebBeansDecorator(AbstractInjectionTargetBean<T> wrappedBean, Decorator<T>
customDecorator)
     {
         super(WebBeansType.DECORATOR,wrappedBean.getReturnType(), wrappedBean.getWebBeansContext());
         this.wrappedBean = wrappedBean;
         this.customDecorator = customDecorator;
+        this.ignoredDecoratorInterfaces = getIgnoredDecoratorInterfaces(wrappedBean);
         initDelegate();
     }
 
-    
     /**
      * Creates a new decorator bean instance with the given wrapped bean.
      * @param wrappedBean wrapped bean instance
@@ -103,17 +110,36 @@ public class WebBeansDecorator<T> extend
         
         this.wrappedBean = wrappedBean;
         this.clazz = wrappedBean.getReturnType();
+        this.ignoredDecoratorInterfaces = getIgnoredDecoratorInterfaces(wrappedBean);
 
         init();
     }
-    
+
+    private static <T> Set<String> getIgnoredDecoratorInterfaces(AbstractInjectionTargetBean<T>
wrappedBean)
+    {
+        OpenWebBeansConfiguration config = wrappedBean.getWebBeansContext().getOpenWebBeansConfiguration();
+        String ignoredDecoratorInterfacesString = config.getProperty(OpenWebBeansConfiguration.IGNORED_DECORATOR_INTERFACES);
+        if (ignoredDecoratorInterfacesString != null)
+        {
+            return new HashSet<String>(Arrays.asList(ignoredDecoratorInterfacesString.split("[,\\p{javaWhitespace}]")));
+        }
+        else
+        {
+            return Collections.singleton(Serializable.class.getName());
+        }
+    }
+
     protected void init()
     {
         ClassUtil.setInterfaceTypeHierarchy(this.decoratedTypes, this.clazz);
 
-        if (this.decoratedTypes.contains(Serializable.class))
+        for (Iterator<Type> i = this.decoratedTypes.iterator(); i.hasNext(); )
         {
-            this.decoratedTypes.remove(Serializable.class);
+            Type t = i.next();
+            if (t instanceof Class<?> && ignoredDecoratorInterfaces.contains(((Class)
t).getName()))
+            {
+                i.remove();
+            }
         }
 
         initDelegate();

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=1131302&r1=1131301&r2=1131302&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
Sat Jun  4 01:19:58 2011
@@ -29,6 +29,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import javax.interceptor.InvocationContext;
 import javassist.util.proxy.MethodHandler;
 import javassist.util.proxy.ProxyFactory;
 import javassist.util.proxy.ProxyObject;
@@ -234,7 +235,10 @@ public abstract class InterceptorHandler
                             WebBeansDecoratorInterceptor lastInterceptor = new WebBeansDecoratorInterceptor(delegateHandler,
instance);
                             decoratorInterceptorDataImpl = new InterceptorDataImpl(true,
lastInterceptor, webBeansContext);
                             decoratorInterceptorDataImpl.setDefinedInInterceptorClass(true);
-                            decoratorInterceptorDataImpl.setAroundInvoke(webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(lastInterceptor.getClass())[0]);
+                            decoratorInterceptorDataImpl.setAroundInvoke(
+                                    webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(lastInterceptor.getClass(),
+                                            "invokeDecorators",
+                                            new Class[] {InvocationContext.class}));
                         }
 
                         List<InterceptorData> interceptorMethods = this.interceptedMethodMap.get(method);



Mime
View raw message