openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1467887 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/portable/ main/java/org/apache/webbeans/proxy/ test/java/org/apache/webbeans/newtests/interceptors/business/tests/
Date Mon, 15 Apr 2013 07:50:03 GMT
Author: struberg
Date: Mon Apr 15 07:50:02 2013
New Revision: 1467887

URL: http://svn.apache.org/r1467887
Log:
OWB-828 log proxy-proxying

this seems to happen under rare cases. We will log it for now to
get a better picture about what happens.

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/business/tests/NewProxyTest.java

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=1467887&r1=1467886&r2=1467887&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
Mon Apr 15 07:50:02 2013
@@ -72,7 +72,7 @@ public class InjectionTargetImpl<T> exte
     protected final WebBeansContext webBeansContext;
 
     protected final AnnotatedType<T> annotatedType;
-    protected AnnotatedConstructor<T> constructor;
+    protected volatile AnnotatedConstructor<T> constructor;
 
     /**
      * If the InjectionTarget has a &#064;PostConstruct method, <code>null</code>
if not.

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java?rev=1467887&r1=1467886&r2=1467887&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
Mon Apr 15 07:50:02 2013
@@ -26,9 +26,13 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ExceptionUtil;
 import org.apache.xbean.asm.ClassWriter;
 import org.apache.xbean.asm.Label;
@@ -38,8 +42,6 @@ import org.apache.xbean.asm.Type;
 
 
 /**
- * WORK IN PROGRESS
- *
  * Generate a dynamic subclass which has exactly 1 delegation point instance
  * which get's set in the Constructor of the proxy.
  * Any non-intercepted or decorated method will get delegated natively,
@@ -50,6 +52,8 @@ import org.apache.xbean.asm.Type;
  */
 public class InterceptorDecoratorProxyFactory extends AbstractProxyFactory
 {
+    private final static Logger logger = WebBeansLoggerFacade.getLogger(InterceptorDecoratorProxyFactory.class);
+
 
     /** the name of the field which stores the proxied instance */
     public static final String FIELD_PROXIED_INSTANCE = "owbIntDecProxiedInstance";
@@ -75,6 +79,25 @@ public class InterceptorDecoratorProxyFa
     public <T> T createProxyInstance(Class<? extends T> proxyClass, T instance,
InterceptorHandler interceptorDecoratorStack)
             throws ProxyGenerationException
     {
+        Asserts.assertNotNull(instance);
+
+        if (instance instanceof OwbInterceptorProxy)
+        {
+            StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+            StringBuilder sb = new StringBuilder("Proxying of a PROXY detected! Proxy class:
");
+            sb.append(instance.getClass().getName()).append(" Stacktrace:\n");
+            for (StackTraceElement ste : stackTraceElements)
+            {
+                sb.append("\t").append(ste.getClassName()).append('.')
+                        .append(ste.getMethodName()).append('#')
+                        .append(ste.getLineNumber()).append('\n');
+            }
+
+            instance = unwrapInstance(instance);
+            sb.append("\nunwrapping the proxy to: " + instance.getClass().getName());
+            logger.log(Level.SEVERE, sb.toString());
+        }
+
         try
         {
             T proxy = unsafeNewInstance(proxyClass);

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/business/tests/NewProxyTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/business/tests/NewProxyTest.java?rev=1467887&r1=1467886&r2=1467887&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/business/tests/NewProxyTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/business/tests/NewProxyTest.java
Mon Apr 15 07:50:02 2013
@@ -26,7 +26,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
@@ -66,8 +65,10 @@ public class NewProxyTest extends Abstra
         Bean bean = beanManager.resolve(beanManager.getBeans(RuntimeExceptionBindingTypeBean.class));
         CreationalContext creationalContext = beanManager.createCreationalContext(bean);
         
-        RuntimeExceptionBindingTypeBean target = (RuntimeExceptionBindingTypeBean) beanManager.getContext(RequestScoped.class).get(bean,
creationalContext);
-        RuntimeExceptionsInterceptor interceptor = (RuntimeExceptionsInterceptor) beanManager.getReference(interceptorBean,
RuntimeExceptionsInterceptor.class, creationalContext);
+        // we cannot use the container to create the proxy as it already proxies the internal
instance
+        RuntimeExceptionBindingTypeBean target = new RuntimeExceptionBindingTypeBean();
+
+        RuntimeExceptionsInterceptor interceptor = (RuntimeExceptionsInterceptor) interceptorBean.create(creationalContext);
 
         Method[] interceptedMethods = {RuntimeExceptionBindingTypeBean.class.getMethod("business")};
         Map<Method, List<Interceptor<?>>> interceptors = new HashMap<Method,
List<Interceptor<?>>>();



Mime
View raw message