You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2013/01/14 21:50:16 UTC

svn commit: r1433121 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/ webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ webbeans-impl/src/main/java/org/apache/webbeans/intercept/ webbeans-...

Author: struberg
Date: Mon Jan 14 20:50:16 2013
New Revision: 1433121

URL: http://svn.apache.org/viewvc?rev=1433121&view=rev
Log:
OWB-755 temp rollback of lifecycle interceptor handling


Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/LifecycleInterceptorInvocationContext.java
Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DefaultInterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorInvocationContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractEjbInjectionTarget.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/business/tests/NewProxyTest.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java?rev=1433121&r1=1433120&r2=1433121&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java Mon Jan 14 20:50:16 2013
@@ -18,7 +18,6 @@
  */
 package org.apache.webbeans.ejb.common.component;
 
-import java.lang.reflect.Method;
 import java.util.Set;
 
 import javax.enterprise.context.spi.CreationalContext;
@@ -79,11 +78,9 @@ public abstract class EjbBeanBuilder<T, 
     @Override
     protected InjectionTarget<T> buildInjectionTarget(AnnotatedType<T> annotatedType,
                                                       Set<InjectionPoint> points,
-                                                      WebBeansContext webBeansContext,
-                                                      Method[] postConstructMethod,
-                                                      Method[] preDestroyMethod)
+                                                      WebBeansContext webBeansContext)
     {
-        return new AbstractEjbInjectionTarget<T>(annotatedType, points, webBeansContext, postConstructMethod, preDestroyMethod)
+        return new AbstractEjbInjectionTarget<T>(annotatedType, points, webBeansContext)
         {
             public T produce(CreationalContext<T> creationalContext)
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java?rev=1433121&r1=1433120&r2=1433121&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java Mon Jan 14 20:50:16 2013
@@ -677,11 +677,10 @@ public abstract class AbstractInjectionT
 
     protected InjectionTarget<T> buildInjectionTarget(AnnotatedType<T> annotatedType,
                                                       Set<InjectionPoint> points,
-                                                      WebBeansContext webBeansContext,
-                                                      Method[] postConstructMethod,
-                                                      Method[] preDestroyMethod)
+                                                      WebBeansContext webBeansContext)
     {
-        return new InjectionTargetImpl<T>(annotatedType, points, webBeansContext, postConstructMethod, preDestroyMethod);
+        //X TODO set interceptor information
+        return new InjectionTargetImpl<T>(annotatedType, points, webBeansContext);
     }
 
     protected abstract I createBean(Set<Type> types,
@@ -707,7 +706,7 @@ public abstract class AbstractInjectionT
         I bean =  createBean(types, qualifiers, scope, name, nullable, beanClass, stereotypes, alternative, enabled);
 
         //X TODO hack to set the InjectionTarget
-        InjectionTarget<T> injectionTarget = buildInjectionTarget(bean.getAnnotatedType(), bean.getInjectionPoints(), webBeansContext, null, null);
+        InjectionTarget<T> injectionTarget = buildInjectionTarget(bean.getAnnotatedType(), bean.getInjectionPoints(), webBeansContext);
         bean.setInjectionTarget(injectionTarget);
 
         return bean;

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=1433121&r1=1433120&r2=1433121&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 Mon Jan 14 20:50:16 2013
@@ -32,12 +32,12 @@ public class DefaultInterceptorHandler<T
 {
 
     private T target;
-    private Map<Method, List<Interceptor<T>>> interceptors;
-    private Map<Interceptor<T>, T> instances;
+    private Map<Method, List<Interceptor<?>>> interceptors;
+    private Map<Interceptor<?>, ?> instances;
 
     public DefaultInterceptorHandler(T target,
-                                     Map<Method, List<Interceptor<T>>> interceptors,
-                                     Map<Interceptor<T>, T> instances)
+                                     Map<Method, List<Interceptor<?>>> interceptors,
+                                     Map<Interceptor<?>, ?> instances)
     {
         this.target = target;
         this.instances = instances;
@@ -48,7 +48,7 @@ public class DefaultInterceptorHandler<T
     {
         try
         {
-            List<Interceptor<T>> methodInterceptors = interceptors.get(method);
+            List<Interceptor<?>> methodInterceptors = interceptors.get(method);
 
             InterceptorInvocationContext<T> ctx
                 = new InterceptorInvocationContext<T>(target, InterceptionType.AROUND_INVOKE, methodInterceptors, instances, method, parameters);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorInvocationContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorInvocationContext.java?rev=1433121&r1=1433120&r2=1433121&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorInvocationContext.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorInvocationContext.java Mon Jan 14 20:50:16 2013
@@ -25,15 +25,18 @@ import java.util.Map;
 import javax.enterprise.inject.spi.InterceptionType;
 import javax.enterprise.inject.spi.Interceptor;
 
+/**
+ * InvocationContext for business method interceptors
+ */
 public class InterceptorInvocationContext<T> extends AbstractInvocationContext<T>
 {
 
     private InterceptionType type;
-    private List<Interceptor<T>> interceptors;
-    private Map<Interceptor<T>, T> instances;
+    private List<Interceptor<?>> interceptors;
+    private Map<Interceptor<?>, ?> instances;
     private int index = 0;
     
-    public InterceptorInvocationContext(T target, InterceptionType type, List<Interceptor<T>> interceptors, Map<Interceptor<T>, T> instances, Method method, Object[] parameters)
+    public InterceptorInvocationContext(T target, InterceptionType type, List<Interceptor<?>> interceptors, Map<Interceptor<?>, ?> instances, Method method, Object[] parameters)
     {
         super(target, method, parameters);
         this.type = type;
@@ -46,7 +49,7 @@ public class InterceptorInvocationContex
     {
         if (index < interceptors.size())
         {
-            Interceptor<T> interceptor = interceptors.get(index++);
+            Interceptor interceptor = interceptors.get(index++);
             return interceptor.intercept(type, instances.get(interceptor), this);
         }
         else

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/LifecycleInterceptorInvocationContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/LifecycleInterceptorInvocationContext.java?rev=1433121&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/LifecycleInterceptorInvocationContext.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/LifecycleInterceptorInvocationContext.java Mon Jan 14 20:50:16 2013
@@ -0,0 +1,33 @@
+/*
+ * 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.intercept;
+
+import java.lang.reflect.Method;
+
+/**
+ * InvocationContext for lifecycle methods like &#064;PostConstruct, etc.
+ */
+public class LifecycleInterceptorInvocationContext<T> extends AbstractInvocationContext<T>
+{
+    public LifecycleInterceptorInvocationContext(T target, Method method, Object[] parameters)
+    {
+        super(target, method, parameters);
+    }
+
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractEjbInjectionTarget.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractEjbInjectionTarget.java?rev=1433121&r1=1433120&r2=1433121&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractEjbInjectionTarget.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractEjbInjectionTarget.java Mon Jan 14 20:50:16 2013
@@ -18,7 +18,6 @@
  */
 package org.apache.webbeans.portable;
 
-import java.lang.reflect.Method;
 import java.util.Set;
 
 import javax.enterprise.context.spi.CreationalContext;
@@ -32,11 +31,9 @@ public abstract class AbstractEjbInjecti
 
     public AbstractEjbInjectionTarget(AnnotatedType<T> annotatedType,
                                       Set<InjectionPoint> points,
-                                      WebBeansContext webBeansContext,
-                                      Method[] postConstructMethod,
-                                      Method[] preDestroyMethod)
+                                      WebBeansContext webBeansContext)
     {
-        super(annotatedType, points, webBeansContext, postConstructMethod, preDestroyMethod);
+        super(annotatedType, points, webBeansContext);
     }
 
     public abstract T produce(CreationalContext<T> creationalContext);

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=1433121&r1=1433120&r2=1433121&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 Jan 14 20:50:16 2013
@@ -45,7 +45,6 @@ import org.apache.webbeans.inject.Inject
 import org.apache.webbeans.inject.InjectableField;
 import org.apache.webbeans.inject.InjectableMethod;
 import org.apache.webbeans.util.Asserts;
-import org.apache.webbeans.util.ExceptionUtil;
 
 
 public class InjectionTargetImpl<T> extends AbstractProducer<T> implements InjectionTarget<T>
@@ -61,7 +60,7 @@ public class InjectionTargetImpl<T> exte
      * This methods must have the signature <code>void METHOD();</code>
      * They are ordered as <b>superclass first</b>.
      */
-    private Method[] postConstructMethods;
+    private AnnotatedMethod[] postConstructMethods;
 
     /**
      * If the InjectionTarget has a &#064;PreDestroy method, <code>null</code> if not.
@@ -69,18 +68,15 @@ public class InjectionTargetImpl<T> exte
      * This methods must have the signature <code>void METHOD();</code>
      * They are ordered as <b>subclass first</b>.
      */
-    private Method[] preDestroyMethods;
+    private AnnotatedMethod[] preDestroyMethods;
 
-    public InjectionTargetImpl(AnnotatedType<T> annotatedType, Set<InjectionPoint> points, WebBeansContext webBeansContext,
-                               Method[] postConstructMethods, Method[] preDestroyMethods)
+    public InjectionTargetImpl(AnnotatedType<T> annotatedType, Set<InjectionPoint> points, WebBeansContext webBeansContext)
     {
         super(points);
         Asserts.assertNotNull(annotatedType);
         Asserts.assertNotNull(webBeansContext);
         type = annotatedType;
         context = webBeansContext;
-        this.postConstructMethods = postConstructMethods;
-        this.preDestroyMethods = preDestroyMethods;
     }
 
     @Override
@@ -164,55 +160,11 @@ public class InjectionTargetImpl<T> exte
     @Override
     public void postConstruct(T instance)
     {
-        if (postConstructMethods != null)
-        {
-            try
-            {
-                for (Method m : postConstructMethods)
-                {
-                    if (!m.isAccessible())
-                    {
-                        m.setAccessible(true);
-                    }
-                    m.invoke(instance);
-                }
-            }
-            catch (Exception e)
-            {
-                ExceptionUtil.throwAsRuntimeException(e);
-            }
-        }
-        else
-        {
-            //X TODO check if there is an interceptor
-        }
     }
 
     @Override
     public void preDestroy(T instance)
     {
-        if (preDestroyMethods != null)
-        {
-            try
-            {
-                for (Method m : preDestroyMethods)
-                {
-                    if (!m.isAccessible())
-                    {
-                        m.setAccessible(true);
-                    }
-                    m.invoke(instance);
-                }
-            }
-            catch (Exception e)
-            {
-                ExceptionUtil.throwAsRuntimeException(e);
-            }
-        }
-        else
-        {
-            //X TODO check if there is an interceptor
-        }
     }
 
     private AnnotatedConstructor<T> getConstructor()

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=1433121&r1=1433120&r2=1433121&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 Jan 14 20:50:16 2013
@@ -70,12 +70,12 @@ public class NewProxyTest extends Abstra
         RuntimeExceptionsInterceptor interceptor = (RuntimeExceptionsInterceptor) beanManager.getReference(interceptorBean, RuntimeExceptionsInterceptor.class, creationalContext);
 
         Method[] interceptedMethods = {RuntimeExceptionBindingTypeBean.class.getMethod("business")};
-        Map<Method, List<Interceptor<RuntimeExceptionBindingTypeBean>>> interceptors = new HashMap<Method, List<Interceptor<RuntimeExceptionBindingTypeBean>>>();
-        interceptors.put(interceptedMethods[0], Arrays.<Interceptor<RuntimeExceptionBindingTypeBean>> asList(interceptorBean));
+        Map<Method, List<Interceptor<?>>> interceptors = new HashMap<Method, List<Interceptor<?>>>();
+        interceptors.put(interceptedMethods[0], Arrays.<Interceptor<?>> asList(interceptorBean));
         Map instances = new HashMap();
         instances.put(interceptorBean, interceptor);
         InterceptorHandler interceptorHandler
-                = new DefaultInterceptorHandler<RuntimeExceptionBindingTypeBean>(target, interceptors, (Map<Interceptor<RuntimeExceptionBindingTypeBean>, RuntimeExceptionBindingTypeBean>) instances);
+                = new DefaultInterceptorHandler<RuntimeExceptionBindingTypeBean>(target, interceptors, instances);
         
         InterceptorDecoratorProxyFactory factory = new InterceptorDecoratorProxyFactory();
         Class<RuntimeExceptionBindingTypeBean> proxyClass