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/19 16:40:04 UTC

svn commit: r1435572 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/intercept/ main/java/org/apache/webbeans/intercept/ejb/ main/java/org/apache/webbeans/util/ test/java/org/apache/webbeans/test/unittests/exception/ test/java...

Author: struberg
Date: Sat Jan 19 15:40:04 2013
New Revision: 1435572

URL: http://svn.apache.org/viewvc?rev=1435572&view=rev
Log:
OWB-344 remove OWB InterceptorData

This got replaced with InterceptorResolutionService

Removed:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorData.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/exception/ExceptionComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PostConstructComponentTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java?rev=1435572&r1=1435571&r2=1435572&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java Sat Jan 19 15:40:04 2013
@@ -22,6 +22,7 @@ import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.enterprise.inject.spi.Annotated;
 import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Decorator;
@@ -29,12 +30,14 @@ import javax.enterprise.inject.spi.Inter
 import javax.enterprise.inject.spi.Interceptor;
 import javax.interceptor.ExcludeClassInterceptors;
 import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -49,6 +52,7 @@ import org.apache.webbeans.annotation.An
 import org.apache.webbeans.component.SelfInterceptorBean;
 import org.apache.webbeans.component.creation.SelfInterceptorBeanBuilder;
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.plugins.OpenWebBeansEjbLCAPlugin;
 import org.apache.webbeans.util.AnnotationUtil;
@@ -315,8 +319,6 @@ public class InterceptorResolutionServic
      */
     private Method getDecoratingMethod(Decorator decorator, AnnotatedMethod annotatedMethod)
     {
-        String annotatedMethodName = annotatedMethod.getJavaMember().getName();
-
         Set<Type> decoratedTypes = decorator.getDecoratedTypes();
         for (Type decoratedType : decoratedTypes)
         {
@@ -453,24 +455,29 @@ public class InterceptorResolutionServic
         Set<InterceptionType> interceptionTypes = new HashSet<InterceptionType>();
         for (Annotation annotation : interceptableAnnotatedMethod.getAnnotations())
         {
-            if (annotation.equals(PostConstruct.class))
+            if (annotation instanceof PostConstruct)
             {
+                verifyLifecycleMethodParameters(annotation, interceptableAnnotatedMethod);
                 interceptionTypes.add(InterceptionType.POST_CONSTRUCT);
             }
-            if (annotation.equals(PreDestroy.class))
+            if (annotation instanceof PreDestroy)
             {
+                verifyLifecycleMethodParameters(annotation, interceptableAnnotatedMethod);
                 interceptionTypes.add(InterceptionType.PRE_DESTROY);
             }
-            if (null != ejbPlugin && annotation.equals(prePassivateClass))
+            if (null != ejbPlugin && prePassivateClass.isAssignableFrom(annotation.getClass()))
             {
+                verifyLifecycleMethodParameters(annotation, interceptableAnnotatedMethod);
                 interceptionTypes.add(InterceptionType.PRE_PASSIVATE);
             }
-            if (null != ejbPlugin && annotation.equals(postActivateClass))
+            if (null != ejbPlugin && postActivateClass.isAssignableFrom(annotation.getClass()))
             {
+                verifyLifecycleMethodParameters(annotation, interceptableAnnotatedMethod);
                 interceptionTypes.add(InterceptionType.POST_ACTIVATE);
             }
-            if (null != ejbPlugin && annotation.equals(aroundTimeoutClass))
+            if (null != ejbPlugin && aroundTimeoutClass.isAssignableFrom(annotation.getClass()))
             {
+                verifyLifecycleMethodParameters(annotation, interceptableAnnotatedMethod);
                 interceptionTypes.add(InterceptionType.AROUND_TIMEOUT);
             }
         }
@@ -479,6 +486,24 @@ public class InterceptorResolutionServic
     }
 
     /**
+     * Check that the given lifecycle method either has
+     * no parameter at all (standard case), or
+     * exactly one InvocationContext parameter (self-interception)
+     * @param annotatedMethod
+     */
+    private void verifyLifecycleMethodParameters(Annotation lifecycleAnnotation, AnnotatedMethod annotatedMethod)
+    {
+        List<AnnotatedParameter<?>> params = annotatedMethod.getParameters();
+        if (params.size() > 0 && (params.size() > 1 || !params.get(0).getBaseType().equals(InvocationContext.class)))
+        {
+            throw new WebBeansConfigurationException(lifecycleAnnotation + " LifecycleMethod "
+                                                     + annotatedMethod.getJavaMember()
+                                                     + " must either have no parameter or InvocationContext but has:"
+                                                     + Arrays.toString(annotatedMethod.getJavaMember().getParameterTypes()));
+        }
+    }
+
+    /**
      * @return the list of all non-overloaded non-private and non-static methods
      */
     private List<AnnotatedMethod> getInterceptableBusinessMethods(AnnotatedType annotatedType)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java?rev=1435572&r1=1435571&r2=1435572&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java Sat Jan 19 15:40:04 2013
@@ -19,48 +19,22 @@
 package org.apache.webbeans.intercept;
 
 import java.lang.annotation.Annotation;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
 import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.InterceptionType;
-import javax.inject.Inject;
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.AroundTimeout;
-import javax.interceptor.ExcludeClassInterceptors;
-import javax.interceptor.Interceptors;
-import javax.interceptor.InvocationContext;
 
 import org.apache.webbeans.annotation.AnnotationManager;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.exception.WebBeansException;
-import org.apache.webbeans.logger.WebBeansLoggerFacade;
-import org.apache.webbeans.plugins.OpenWebBeansEjbLCAPlugin;
-import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
-import org.apache.webbeans.util.ClassUtil;
 
 
 public final class InterceptorUtil
 {
-    private static final Logger logger = WebBeansLoggerFacade.getLogger(InterceptorUtil.class);
-
-    private final OpenWebBeansEjbLCAPlugin ejbPlugin;
-    private final Class<? extends Annotation> prePassivateClass;
-    private final Class<? extends Annotation> postActivateClass;
 
     /**
      * all the bit flags of private static and final modifiers
@@ -72,17 +46,7 @@ public final class InterceptorUtil
     public InterceptorUtil(WebBeansContext webBeansContext)
     {
         this.webBeansContext = webBeansContext;
-        ejbPlugin = webBeansContext.getPluginLoader().getEjbLCAPlugin();
-        if (ejbPlugin != null)
-        {
-            prePassivateClass = ejbPlugin.getPrePassivateClass();
-            postActivateClass = ejbPlugin.getPostActivateClass();
-        }
-        else
-        {
-            prePassivateClass = null;
-            postActivateClass = null;
-        }
+
     }
 
     /**
@@ -152,270 +116,6 @@ public final class InterceptorUtil
         return true;
     }
 
-    /**
-     * Check if the given method is a 'business method'
-     * in the sense of the Interceptor specification
-     * @param method
-     * @return <code>true</code> if the given method is an interceptable business method
-     * @deprecated TODO remove this method as it does not take AnnotatedType/Extensions into account
-     */
-    public boolean isWebBeansBusinessMethod(Method method)
-    {
-        int modifiers = method.getModifiers();
-
-        if ((modifiers & MODIFIER_STATIC_FINAL_PRIVATE) != 0)
-        {
-            // static, final and private methods are NO business methods!
-            return false;
-        }
-
-        Annotation[] anns = method.getDeclaredAnnotations();
-
-        // filter out all container 'special' methods
-        for (Annotation ann : anns)
-        {
-            Class <? extends Annotation> annCls = ann.annotationType();
-            if (annCls.equals(Inject.class)        ||
-                annCls.equals(PreDestroy.class)    ||
-                annCls.equals(PostConstruct.class) ||
-                annCls.equals(AroundInvoke.class)  ||
-                annCls.equals(AroundTimeout.class) ||    // JSR-299 7.2
-                ((ejbPlugin != null)              &&
-                 (annCls.equals(prePassivateClass)   ||  // JSR-299 7.2
-                  annCls.equals(postActivateClass))))    // JSR-299 7.2
-            {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    public Class<? extends Annotation> getInterceptorAnnotationClazz(InterceptionType type)
-    {
-        if (type.equals(InterceptionType.AROUND_INVOKE))
-        {
-            return AroundInvoke.class;
-        }
-        else if (type.equals(InterceptionType.POST_ACTIVATE))
-        {
-            return postActivateClass;
-        }
-        else if (type.equals(InterceptionType.POST_CONSTRUCT))
-        {
-            return PostConstruct.class;
-        }
-        else if (type.equals(InterceptionType.PRE_DESTROY))
-        {
-            return PreDestroy.class;
-        }
-        else if (type.equals(InterceptionType.PRE_PASSIVATE))
-        {
-            return prePassivateClass;
-        }
-        else if (type.equals(InterceptionType.AROUND_TIMEOUT))
-        {
-            return AroundTimeout.class;
-        }
-        else
-        {
-            throw new WebBeansException("Undefined interceotion type");
-        }
-    }
-
-    public <T> boolean isBusinessMethodInterceptor(AnnotatedType<T> annotatedType)
-    {
-        Set<AnnotatedMethod<? super T>> methods = annotatedType.getMethods();
-        for(AnnotatedMethod<? super T> methodA : methods)
-        {
-            AnnotatedMethod<T> method = (AnnotatedMethod<T>)methodA;
-            if(method.isAnnotationPresent(AroundInvoke.class))
-            {
-                    if (!methodA.getParameters().isEmpty())
-                    {
-                        List<AnnotatedParameter<T>> parameters = method.getParameters();
-                        List<Class<?>> clazzParameters = new ArrayList<Class<?>>();
-                        for(AnnotatedParameter<T> parameter : parameters)
-                        {
-                            clazzParameters.add(ClassUtil.getClazz(parameter.getBaseType()));
-                        }
-
-                        Class<?>[] params = clazzParameters.toArray(new Class<?>[clazzParameters.size()]);
-                        if (params.length == 1 && params[0].equals(InvocationContext.class))
-                        {
-                            if (method.getJavaMember().getReturnType().equals(Object.class))
-                            {
-                                if (!ClassUtil.isMethodHasCheckedException(method.getJavaMember()))
-                                {
-                                    if (!Modifier.isStatic(method.getJavaMember().getModifiers()) && !Modifier.isFinal(method.getJavaMember().getModifiers()))
-                                    {
-                                        return true;
-                                    }
-                                }
-                            }
-                        }
-                    }
-            }
-        }
-
-        return false;
-    }
-
-
-    public boolean isBusinessMethodInterceptor(Class<?> clazz)
-    {
-        Asserts.nullCheckForClass(clazz);
-        Method[] methods = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(clazz);
-        for (Method method : methods)
-        {
-            if (AnnotationUtil.hasMethodAnnotation(method, AroundInvoke.class))
-            {
-                Class<?>[] params = method.getParameterTypes();
-                if (params.length > 0)
-                {
-                    if (params.length == 1 && params[0].equals(InvocationContext.class))
-                    {
-                        if (method.getReturnType().equals(Object.class))
-                        {
-                            if (!Modifier.isStatic(method.getModifiers()) && !Modifier.isFinal(method.getModifiers()))
-                            {
-                                return true;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        return false;
-    }
-
-    public boolean isLifecycleMethodInterceptor(Class<?> clazz)
-    {
-        Asserts.nullCheckForClass(clazz);
-        Method[] methods = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(clazz);
-        for (Method method : methods)
-        {
-            if (AnnotationUtil.hasMethodAnnotation(method, PostConstruct.class) || AnnotationUtil.hasMethodAnnotation(method, PreDestroy.class)
-                || AnnotationUtil.hasMethodAnnotation(method, postActivateClass)
-                || AnnotationUtil.hasMethodAnnotation(method, prePassivateClass)
-               )
-            {
-                Class<?>[] params = method.getParameterTypes();
-                if (params.length > 0)
-                {
-
-                    if (params.length == 1 && params[0].equals(InvocationContext.class))
-                    {
-                        if (method.getReturnType().equals(Void.TYPE))
-                        {
-                            if (!ClassUtil.isMethodHasCheckedException(method))
-                            {
-                                if (!Modifier.isStatic(method.getModifiers()))
-                                {
-                                    return true;
-                                }
-                            }
-                        }
-                    }
-
-                }
-            }
-        }
-
-        return false;
-    }
-
-    @SuppressWarnings("unchecked")
-    public <T> boolean isLifecycleMethodInterceptor(AnnotatedType<T> annotatedType)
-    {
-        Set<AnnotatedMethod<? super T>> methods = annotatedType.getMethods();
-        for(AnnotatedMethod<? super T> methodA : methods)
-        {
-            AnnotatedMethod<T> method = (AnnotatedMethod<T>)methodA;
-            if(method.isAnnotationPresent(PostConstruct.class)
-                    || method.isAnnotationPresent(PreDestroy.class)
-                    || method.isAnnotationPresent(postActivateClass)
-                    || method.isAnnotationPresent(prePassivateClass))
-            {
-                    if (!methodA.getParameters().isEmpty())
-                    {
-                        List<AnnotatedParameter<T>> parameters = method.getParameters();
-                        List<Class<?>> clazzParameters = new ArrayList<Class<?>>();
-                        for(AnnotatedParameter<T> parameter : parameters)
-                        {
-                            clazzParameters.add(ClassUtil.getClazz(parameter.getBaseType()));
-                        }
-
-                        Class<?>[] params = clazzParameters.toArray(new Class<?>[clazzParameters.size()]);
-                        if (params.length == 1 && params[0].equals(InvocationContext.class))
-                        {
-                            if (method.getJavaMember().getReturnType().equals(Void.TYPE))
-                            {
-                                if (!ClassUtil.isMethodHasCheckedException(method.getJavaMember()))
-                                {
-                                    if (!Modifier.isStatic(method.getJavaMember().getModifiers()))
-                                    {
-                                        return true;
-                                    }
-                                }
-                            }
-                        }
-                    }
-            }
-        }
-
-        return false;
-    }
-
-
-    /**
-     * @param clazz AUTSCH! we should use the AnnotatedType for all that stuff!
-     * @deprecated TODO remove and only use the AnnotatedType version for all
-     */
-    public <T> void checkLifecycleConditions(Class<T> clazz, Annotation[] annots, String errorMessage)
-    {
-        Asserts.nullCheckForClass(clazz);
-
-        if (isLifecycleMethodInterceptor(clazz) && !isBusinessMethodInterceptor(clazz))
-        {
-            Annotation[] anns = webBeansContext.getAnnotationManager().getInterceptorBindingMetaAnnotations(annots);
-
-            for (Annotation annotation : anns)
-            {
-                Target target = annotation.annotationType().getAnnotation(Target.class);
-                ElementType[] elementTypes = target.value();
-
-                if (!(elementTypes.length == 1 && elementTypes[0].equals(ElementType.TYPE)))
-                {
-                    throw new WebBeansConfigurationException(errorMessage);
-                }
-            }
-        }
-
-    }
-
-    public <T> void checkLifecycleConditions(AnnotatedType<T> annotatedType, Set<Annotation> annots, String errorMessage)
-    {
-        if (isLifecycleMethodInterceptor(annotatedType) && !isBusinessMethodInterceptor(annotatedType))
-        {
-            Annotation[] anns = webBeansContext.getAnnotationManager().getInterceptorBindingMetaAnnotations(annots);
-
-            for (Annotation annotation : anns)
-            {
-                Target target = annotation.annotationType().getAnnotation(Target.class);
-                ElementType[] elementTypes = target.value();
-
-                if (!(elementTypes.length == 1 && elementTypes[0].equals(ElementType.TYPE)))
-                {
-                    throw new WebBeansConfigurationException(errorMessage);
-                }
-            }
-        }
-
-    }
-
-
     public void checkSimpleWebBeansInterceptorConditions(Class<?> clazz)
     {
         Asserts.nullCheckForClass(clazz);
@@ -475,263 +175,6 @@ public final class InterceptorUtil
 
     }
 
-    /**
-     * Returns true if this interceptor data is not related
-     * false otherwise.
-     * @param id interceptor data
-     * @param method called method
-     * @return true if this interceptor data is not related
-     */
-    private boolean shouldRemoveInterceptorCommon(InterceptorData id, Method method)
-    {
-        boolean isMethodAnnotatedWithExcludeInterceptorClass = false;
-        if (AnnotationUtil.hasMethodAnnotation(method, ExcludeClassInterceptors.class))
-        {
-            isMethodAnnotatedWithExcludeInterceptorClass = true;
-        }
-
-        if (isMethodAnnotatedWithExcludeInterceptorClass)
-        {
-            // If the interceptor is defined at the class level it should be
-            // removed due to ExcludeClassInterceptors method annotation
-            if (!id.isDefinedInMethod() && id.isDefinedInInterceptorClass())
-            {
-                return true;
-            }
-        }
-
-        // If the interceptor is defined in a different method, remove it
-        if (id.isDefinedInMethod() && !id.getInterceptorBindingMethod().equals(method))
-        {
-            return true;
-        }
-
-        return false;
-    }
-
-
-
-    /**
-     * Return true if candidate class is a super class of given interceptor
-     * class.
-     *
-     * @param interceptorClass interceptor class
-     * @param candidateClass candaite class
-     * @return true if candidate class is a super class of given interceptor
-     *         class
-     */
-    public boolean checkInInterceptorHierarchy(Class<?> interceptorClass, Class<?> candidateClass)
-    {
-        Class<?> superClassInterceptor = interceptorClass.getSuperclass();
-        if (superClassInterceptor != null && !superClassInterceptor.equals(Object.class))
-        {
-            if (superClassInterceptor.equals(candidateClass))
-            {
-                return true;
-            }
-
-            else
-            {
-                return checkInInterceptorHierarchy(superClassInterceptor, candidateClass);
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Remove bean inherited and overriden lifecycle interceptor method from its
-     * stack list.
-     *
-     * @param beanClass bean class
-     * @param stack bean interceptor stack
-     */
-    public void filterOverridenLifecycleInterceptor(Class<?> beanClass, List<InterceptorData> stack)
-    {
-        List<InterceptorData> overridenInterceptors = new ArrayList<InterceptorData>();
-        Iterator<InterceptorData> it = stack.iterator();
-        while (it.hasNext())
-        {
-            InterceptorData interceptorData = it.next();
-            if (interceptorData.isLifecycleInterceptor())
-            {
-                InterceptorData overridenInterceptor = getOverridenInterceptor(beanClass, interceptorData, stack);
-                if (null != overridenInterceptor)
-                {
-                    if (logger.isLoggable(Level.FINE))
-                    {
-                        logger.fine("REMOVING parent " + overridenInterceptor);
-                    }
-
-                    it.remove();
-                }
-            }
-        }
-        stack.removeAll(overridenInterceptors);
-    }
-
-    /**
-     * If an AroundInvoke method is overridden by another method (regardless of
-     * whether that method is itself an AroundInvoke method), it will not be
-     * invoked. Remove bean inherited but overriden around invoke interceptor
-     * method from its stack list.
-     *
-     * @param beanClass bean class
-     * @param stack bean interceptor stack
-     */
-    public void filterOverridenAroundInvokeInterceptor(Class<?> beanClass, List<InterceptorData> stack)
-    {
-
-        List<InterceptorData> overridenInterceptors = null;
-        if (stack.size() > 0)
-        {
-            Iterator<InterceptorData> it = stack.iterator();
-            while (it.hasNext())
-            {
-                InterceptorData interceptorData = it.next();
-                if (interceptorData.getAroundInvoke() != null)
-                {
-                    InterceptorData overridenInterceptor = getOverridenInterceptor(beanClass, interceptorData, stack);
-                    if (null != overridenInterceptor)
-                    {
-                        if (overridenInterceptors == null)
-                        {
-                            overridenInterceptors = new ArrayList<InterceptorData>();
-                        }
-                        overridenInterceptors.add(overridenInterceptor);
-                        if (logger.isLoggable(Level.FINE))
-                        {
-                            logger.fine("REMOVING parent " + overridenInterceptor);
-                        }
-
-                    }
-                }
-            }
-        }
-
-        if (overridenInterceptors != null)
-        {
-            stack.removeAll(overridenInterceptors);
-        }
-    }
-
-    /**
-     * Check to see if any parent class in the hierarchy is in this interceptor
-     * stack If any method in the current interceptor has the same name and
-     * signature as the parent's interceptor method remove the parent
-     * interceptor from the stack
-     *
-     * @param interceptorData
-     * @param stack
-     * @return the overriden InterceptorData that represents the parent
-     */
-    private InterceptorData getOverridenInterceptor(Class<?> clazz, InterceptorData interceptorData, List<InterceptorData> stack)
-    {
-        Method interceptor = interceptorData.getInterceptorMethod();
-        Class<?> interceptorClass = interceptor.getDeclaringClass();
-
-        for (InterceptorData superInterceptorData : stack)
-        {
-
-            if (interceptorClass.equals(superInterceptorData.getInterceptorClass()))
-            {
-                continue; // we are looking at ourself
-            }
-
-            // parent interceptor in the interceptor stack
-            if (checkInInterceptorHierarchy(interceptorClass, superInterceptorData.getInterceptorClass()))
-            {
-
-                // get the interceptor method of the parent
-                Method superInterceptorMethod = superInterceptorData.getInterceptorMethod();
-                Method childInterceptorMethod = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(interceptorClass,
-                                              superInterceptorMethod.getName(), superInterceptorMethod.getParameterTypes());
-
-                if (null != childInterceptorMethod && ClassUtil.isOverridden(childInterceptorMethod, superInterceptorMethod))
-                {
-                    return superInterceptorData;
-                }
-            }
-            else
-            { // the class may be overriding the interceptor method
-                return removeInheritedButOverridenInterceptor(clazz, interceptorData);
-
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * This returns the Interceptor that is defined in a super class of the bean
-     * and has the same method as the bean. i.e. the bean method overrides the
-     * Interceptor method defined in the super class.
-     *
-     * @param clazz
-     * @param interceptorData
-     * @return
-     */
-    private InterceptorData removeInheritedButOverridenInterceptor(Class<?> clazz, InterceptorData interceptorData)
-    {
-        Method interceptor = interceptorData.getInterceptorMethod();
-        Class<?> declaringClass = interceptor.getDeclaringClass();
-
-        // Not look for Interceptor classes
-        if (checkGivenClassIsInInterceptorList(clazz, declaringClass))
-        {
-            return null;
-        }
-
-        if (!declaringClass.equals(clazz) && checkInInterceptorHierarchy(clazz, declaringClass))
-        {
-            Method found = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(clazz, interceptor.getName(), interceptor.getParameterTypes());
-
-            if (found == null)
-            {
-                Class<?> superClass = clazz.getSuperclass();
-                if (superClass != null && !superClass.equals(Object.class))
-                {
-                    return removeInheritedButOverridenInterceptor(superClass, interceptorData);
-                }
-            }
-
-            return interceptorData;
-        }
-
-        return null;
-    }
-
-    /**
-     * Return true if given candidate is listed in interceptors list.
-     *
-     * @param mainClass bean class
-     * @param candidateClass interceptor candidate class
-     * @return true if given candidate is listed in interceptors list
-     */
-    public boolean checkGivenClassIsInInterceptorList(Class<?> mainClass, Class<?> candidateClass)
-    {
-        if (AnnotationUtil.hasClassAnnotation(mainClass, Interceptors.class))
-        {
-            Interceptors incs = mainClass.getAnnotation(Interceptors.class);
-            Class<?>[] intClasses = incs.value();
 
-            for (Class<?> intClass : intClasses)
-            {
-                if (intClass.equals(candidateClass))
-                {
-                    return true;
-                }
-                else
-                {
-                    if (checkInInterceptorHierarchy(intClass, candidateClass))
-                    {
-                        return true;
-                    }
-                }
-            }
-        }
-
-        return false;
-    }
 
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java?rev=1435572&r1=1435571&r2=1435572&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ejb/EJBInterceptorConfig.java Sat Jan 19 15:40:04 2013
@@ -18,21 +18,10 @@
  */
 package org.apache.webbeans.intercept.ejb;
 
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.enterprise.inject.spi.AnnotatedMethod;
+
 import javax.enterprise.inject.spi.AnnotatedType;
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.AroundTimeout;
-import javax.interceptor.Interceptors;
 
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.intercept.InterceptorData;
 import org.apache.webbeans.util.Asserts;
 
 /**
@@ -62,83 +51,6 @@ public final class EJBInterceptorConfig
         Asserts.assertNotNull(annotatedType);
 
 
-        Interceptors incs = annotatedType.getAnnotation(Interceptors.class);
-        if (incs != null)
-        {
-            Class<?>[] interceptorClasses = incs.value();
-
-            for (Class<?> intClass : interceptorClasses)
-            {
-                configureInterceptorAnnots(webBeansContext.getAnnotatedElementFactory().newAnnotatedType(intClass), Collections.EMPTY_LIST, false, null);
-            }
-
-        }
-        configureBeanAnnots(annotatedType, Collections.EMPTY_LIST);
-
-        Class clazz = annotatedType.getJavaClass();
-        webBeansContext.getInterceptorUtil().filterOverridenLifecycleInterceptor(clazz, Collections.EMPTY_LIST);
     }
 
-    /**
-     * Configure {@link Interceptors} on bean class.
-     * @param annotatedType
-     * @param stack interceptor stack of bean
-     * @param isMethod if interceptor definition is on the bean
-     * @param m if isMethod true, then it is intercepted method
-     */
-    private void configureInterceptorAnnots(AnnotatedType<?> annotatedType, List<InterceptorData> stack, boolean isMethod, Method m)
-    {
-
-        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, annotatedType, AroundInvoke.class,
-                                                                      true, isMethod, stack, m, false);
-        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, annotatedType, AroundTimeout.class,
-                                                                      true, isMethod, stack, m, false);
-        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, annotatedType, PostConstruct.class,
-                                                                      true, isMethod, stack, m, false);
-        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, annotatedType, PreDestroy.class,
-                                                                      true, isMethod, stack, m, false);
-
-    }
-
-    /**
-     * Configure bean class defined interceptors.
-     * @param annotatedType bean class
-     * @param stack interceptor stack
-     */
-    private void configureBeanAnnots(AnnotatedType annotatedType, List<InterceptorData> stack)
-    {
-        // 1- Look method intercepor class annotations
-        // 2- Look super class around invoke
-        // 3- Look bean around invoke
-
-        // 1-
-        Set<AnnotatedMethod<?>> annotatedMethods = annotatedType.getMethods();
-
-        for (AnnotatedMethod<?> annotatedMethod : annotatedMethods)
-        {
-            Interceptors incs = annotatedMethod.getAnnotation(Interceptors.class);
-            if (incs != null)
-            {
-                Method method = annotatedMethod.getJavaMember();
-                Class<?>[] intClasses = incs.value();
-
-                for (Class<?> intClass : intClasses)
-                {
-                    configureInterceptorAnnots(webBeansContext.getAnnotatedElementFactory().newAnnotatedType(intClass), stack, true, method);
-                }
-
-            }
-        }
-
-        // 3- Bean itself
-        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, annotatedType, AroundInvoke.class,
-                                                                      false, false, stack, null, false);
-        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, annotatedType, AroundTimeout.class,
-                                                                      false, false, stack, null, false);
-        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, annotatedType, PostConstruct.class,
-                                                                      false, false, stack, null, false);
-        webBeansContext.getWebBeansUtil().configureInterceptorMethods(null, annotatedType, PreDestroy.class,
-                                                                      false, false, stack, null, false);
-
-    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1435572&r1=1435571&r2=1435572&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java Sat Jan 19 15:40:04 2013
@@ -61,8 +61,6 @@ import javax.enterprise.inject.spi.Befor
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.InjectionTarget;
-import javax.enterprise.inject.spi.InterceptionType;
-import javax.enterprise.inject.spi.Interceptor;
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.inject.spi.PassivationCapable;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
@@ -78,7 +76,6 @@ import javax.inject.Inject;
 import javax.inject.Named;
 import javax.inject.Scope;
 import javax.interceptor.AroundInvoke;
-import javax.interceptor.AroundTimeout;
 import javax.interceptor.InvocationContext;
 
 import org.apache.webbeans.annotation.AnnotationManager;
@@ -116,10 +113,7 @@ import org.apache.webbeans.exception.Web
 import org.apache.webbeans.exception.inject.DefinitionException;
 import org.apache.webbeans.exception.inject.InconsistentSpecializationException;
 import org.apache.webbeans.inject.AlternativesManager;
-import org.apache.webbeans.intercept.InterceptorData;
-import org.apache.webbeans.intercept.InterceptorDataImpl;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
-import org.apache.webbeans.plugins.OpenWebBeansEjbLCAPlugin;
 import org.apache.webbeans.plugins.PluginLoader;
 import org.apache.webbeans.portable.ProducerFieldProducer;
 import org.apache.webbeans.portable.events.discovery.ErrorStack;
@@ -886,142 +880,6 @@ public final class WebBeansUtil
         }
     }
 
-
-    /**
-     * Configures the interceptor stack of the web beans component.
-     *
-     * @param annotation annotation type
-     * @param definedInInterceptorClass check if annotation is defined in
-     *            interceptor class (as opposed to bean class)
-     * @param definedInMethod check if the interceptor is defined in the comp.
-     *            method
-     * @param stack interceptor stack
-     * @param annotatedInterceptorClassMethod if definedInMethod, this specify
-     *            method
-     * @param defineWithInterceptorBinding if interceptor is defined with WebBeans
-     *            spec, not EJB spec
-     */
-    public <T> void configureInterceptorMethods(Interceptor<?> webBeansInterceptor,
-                                                 AnnotatedType<T> annotatedType,
-                                                 Class<? extends Annotation> annotation,
-                                                 boolean definedInInterceptorClass,
-                                                 boolean definedInMethod,
-                                                 List<InterceptorData> stack,
-                                                 Method annotatedInterceptorClassMethod,
-                                                 boolean defineWithInterceptorBinding)
-    {
-        InterceptorData intData;
-        Set<Method> methods = null;
-        OpenWebBeansEjbLCAPlugin ejbPlugin;
-        Class<? extends Annotation> prePassivateClass  = null;
-        Class<? extends Annotation> postActivateClass  = null;
-
-        ejbPlugin = webBeansContext.getPluginLoader().getEjbLCAPlugin();
-        if(ejbPlugin != null)
-        {
-            prePassivateClass  = ejbPlugin.getPrePassivateClass();
-            postActivateClass  = ejbPlugin.getPostActivateClass();
-        }
-
-        //Check for default constructor of EJB based interceptor
-        if(webBeansInterceptor == null)
-        {
-            if(definedInInterceptorClass)
-            {
-                Constructor<?> ct = getNoArgConstructor(annotatedType.getJavaClass());
-                if (ct == null)
-                {
-                    throw new WebBeansConfigurationException("class : " + annotatedType.getJavaClass().getName()
-                            + " must have no-arg constructor");
-                }
-            }
-        }
-
-        if (annotation.equals(AroundInvoke.class) ||
-                annotation.equals(AroundTimeout.class))
-        {
-            methods = checkAroundInvokeAnnotationCriterias(annotatedType, annotation);
-        }
-        else if (annotation.equals(PostConstruct.class) || ((postActivateClass != null) && (annotation.equals(postActivateClass)))
-                 || annotation.equals(PreDestroy.class) || ((prePassivateClass != null) && (annotation.equals(prePassivateClass))))
-        {
-            methods = checkCommonAnnotationCriterias(annotatedType, annotation, definedInInterceptorClass);
-        }
-
-        if (methods != null && !methods.isEmpty())
-        {
-            for (Method method : methods)
-            {
-                intData = new InterceptorDataImpl(defineWithInterceptorBinding, webBeansContext);
-                intData.setDefinedInInterceptorClass(definedInInterceptorClass);
-                intData.setDefinedInMethod(definedInMethod);
-                intData.setInterceptorBindingMethod(annotatedInterceptorClassMethod);
-                intData.setWebBeansInterceptor(webBeansInterceptor);
-
-                if (definedInInterceptorClass)
-                {
-                    intData.setInterceptorClass(annotatedType.getJavaClass());
-                }
-
-                intData.setInterceptorMethod(method, annotation);
-                stack.add(intData);
-            }
-        }
-    }
-
-    /**
-     * Returns true if interceptor stack contains interceptor with given type.
-     *
-     * @param stack interceptor stack
-     * @param type interceptor type
-     * @return true if stack contains the interceptor with given type
-     */
-    public static boolean isContainsInterceptorMethod(List<InterceptorData> stack, InterceptionType type)
-    {
-        if (stack.size() > 0)
-        {
-            Iterator<InterceptorData> it = stack.iterator();
-            while (it.hasNext())
-            {
-                Method m = null;
-                InterceptorData data = it.next();
-
-                if (type.equals(InterceptionType.AROUND_INVOKE))
-                {
-                    m = data.getAroundInvoke();
-                }
-                else if (type.equals(InterceptionType.AROUND_TIMEOUT))
-                {
-                    m = data.getAroundTimeout();
-                }
-                else if (type.equals(InterceptionType.POST_CONSTRUCT))
-                {
-                    m = data.getPostConstruct();
-                }
-                else if (type.equals(InterceptionType.POST_ACTIVATE))
-                {
-                    m = data.getPostActivate();
-                }
-                else if (type.equals(InterceptionType.PRE_DESTROY))
-                {
-                    m = data.getPreDestroy();
-                }
-                else if (type.equals(InterceptionType.PRE_PASSIVATE))
-                {
-                    m = data.getPrePassivate();
-                }
-
-                if (m != null)
-                {
-                    return true;
-                }
-
-            }
-        }
-
-        return false;
-    }
-
     public static String getManagedBeanDefaultName(String clazzName)
     {
         Asserts.assertNotNull(clazzName);

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/exception/ExceptionComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/exception/ExceptionComponentTest.java?rev=1435572&r1=1435571&r2=1435572&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/exception/ExceptionComponentTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/exception/ExceptionComponentTest.java Sat Jan 19 15:40:04 2013
@@ -18,15 +18,12 @@
  */
 package org.apache.webbeans.test.unittests.exception;
 
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Bean;
 
 import junit.framework.Assert;
 
 import org.apache.webbeans.component.AbstractOwbBean;
-import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.test.TestContext;
+import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.test.component.exception.AroundInvokeWithFinalMethodComponent;
 import org.apache.webbeans.test.component.exception.AroundInvokeWithSameMethodNameComponent;
 import org.apache.webbeans.test.component.exception.AroundInvokeWithStaticMethodComponent;
@@ -49,29 +46,16 @@ import org.apache.webbeans.test.componen
 import org.apache.webbeans.test.component.exception.ProducerTypeStaticComponent;
 import org.apache.webbeans.test.component.exception.InnerComponent.InnerInnerComponent;
 import org.apache.webbeans.test.component.intercept.NoArgConstructorInterceptorComponent;
-import org.junit.Before;
 import org.junit.Test;
 
-public class ExceptionComponentTest extends TestContext
+public class ExceptionComponentTest extends AbstractUnitTest
 {
 
-    public ExceptionComponentTest()
-    {
-        super(ExceptionComponentTest.class.getName());
-    }
-
-    @Before
-    public void init()
-    {
-        super.init();
-
-    }
-
     @Test
     public void testFinal()
     {
-        clear();
-        defineManagedBean(FinalComponent.class);
+        startContainer(FinalComponent.class);
+        shutDownContainer();
     }
 
     @Test
@@ -79,8 +63,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            defineManagedBean(AbstractOwbBean.class);
+            startContainer(AbstractOwbBean.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -88,6 +71,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -95,8 +79,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            defineManagedBean(InnerInnerComponent.class);
+            startContainer(InnerInnerComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -104,6 +87,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -111,8 +95,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            defineManagedBean(HasFinalMethodComponent.class);
+            startContainer(HasFinalMethodComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -120,6 +103,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -127,9 +111,9 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            defineManagedBean(MoreThanOneConstructureComponent.class);
+            startContainer(MoreThanOneConstructureComponent.class);
             Assert.fail("expecting an exception!");
+            shutDownContainer();
         }
         catch (WebBeansConfigurationException e)
         {
@@ -139,24 +123,24 @@ public class ExceptionComponentTest exte
 
         try
         {
-            clear();
-            defineManagedBean(MoreThanOneConstructureComponent2.class);
+            startContainer(MoreThanOneConstructureComponent2.class);
             // all ok
         }
         catch (WebBeansConfigurationException e)
         {
             System.out.println("got expected exception: " + e.getMessage());
         }
+        shutDownContainer();
 
-        clear();
-        defineManagedBean(NoConstructureComponent.class);
+        startContainer(NoConstructureComponent.class);
+        shutDownContainer();
     }
 
     @Test
     public void testStaticProducerMethod()
     {
-        clear();
-        defineManagedBean(ProducerTypeStaticComponent.class);
+        startContainer(ProducerTypeStaticComponent.class);
+        shutDownContainer();
     }
 
     @Test
@@ -164,8 +148,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            defineManagedBean(MultipleDisposalMethodComponent.class);
+            startContainer(MultipleDisposalMethodComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -173,6 +156,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -186,8 +170,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            defineManagedBean(NewComponentBindingComponent.class);
+            startContainer(NewComponentBindingComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -195,6 +178,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -208,10 +192,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            InjectionTargetBean<MoreThanOnePostConstructComponent> component = defineManagedBean(MoreThanOnePostConstructComponent.class);
-            AnnotatedType annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(component.getReturnType());
-            getWebBeansContext().getEJBInterceptorConfig().configure(annotatedType);
+            startContainer(MoreThanOnePostConstructComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -219,6 +200,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -226,10 +208,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            InjectionTargetBean<PostContructMethodHasParameterComponent> component = defineManagedBean(PostContructMethodHasParameterComponent.class);
-            AnnotatedType annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(component.getReturnType());
-            getWebBeansContext().getEJBInterceptorConfig().configure(annotatedType);
+            startContainer(PostContructMethodHasParameterComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -237,6 +216,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -244,10 +224,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            InjectionTargetBean<?> component = defineManagedBean(PostContructMethodHasReturnTypeComponent.class);
-            AnnotatedType annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(component.getReturnType());
-            getWebBeansContext().getEJBInterceptorConfig().configure(annotatedType);
+            startContainer(PostContructMethodHasReturnTypeComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -255,6 +232,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -262,10 +240,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            InjectionTargetBean<?> component = defineManagedBean(PostContructMethodHasCheckedExceptionComponent.class);
-            AnnotatedType annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(component.getReturnType());
-            getWebBeansContext().getEJBInterceptorConfig().configure(annotatedType);
+            startContainer(PostContructMethodHasCheckedExceptionComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -273,6 +248,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -280,10 +256,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            InjectionTargetBean<?> component = defineManagedBean(PostContructMethodHasStaticComponent.class);
-            AnnotatedType annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(component.getReturnType());
-            getWebBeansContext().getEJBInterceptorConfig().configure(annotatedType);
+            startContainer(PostContructMethodHasStaticComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -291,6 +264,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -298,10 +272,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            InjectionTargetBean<?> component = defineManagedBean(MoreThanOneAroundInvokeComponent.class);
-            AnnotatedType annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(component.getReturnType());
-            getWebBeansContext().getEJBInterceptorConfig().configure(annotatedType);
+            startContainer(MoreThanOneAroundInvokeComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -309,16 +280,14 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
     public void testAroundInvokeWithSameMethodName()
     {
-        clear();
-        defineManagedBean(AroundInvokeWithSameMethodNameComponent.class);
-        Bean<?> comp = getComponents().get(0);
-
-        //X TODO reimplement with new test suite: Assert.assertEquals(0, ((InjectionTargetBean<?>) comp).getInterceptorStack().size());
+        startContainer(AroundInvokeWithSameMethodNameComponent.class);
+        shutDownContainer();
     }
 
     @Test
@@ -326,10 +295,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            InjectionTargetBean<?> component = defineManagedBean(AroundInvokeWithoutParameterComponent.class);
-            AnnotatedType annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(component.getReturnType());
-            getWebBeansContext().getEJBInterceptorConfig().configure(annotatedType);
+            startContainer(AroundInvokeWithoutParameterComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -337,6 +303,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -344,10 +311,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            InjectionTargetBean<?> component = defineManagedBean(AroundInvokeWithoutReturnTypeComponent.class);
-            AnnotatedType annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(component.getReturnType());
-            getWebBeansContext().getEJBInterceptorConfig().configure(annotatedType);
+            startContainer(AroundInvokeWithoutReturnTypeComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -355,6 +319,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -362,10 +327,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            InjectionTargetBean<?> component = defineManagedBean(AroundInvokeWithWrongReturnTypeComponent.class);
-            AnnotatedType annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(component.getReturnType());
-            getWebBeansContext().getEJBInterceptorConfig().configure(annotatedType);
+            startContainer(AroundInvokeWithWrongReturnTypeComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -373,6 +335,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -380,10 +343,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            InjectionTargetBean<?> component = defineManagedBean(AroundInvokeWithStaticMethodComponent.class);
-            AnnotatedType annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(component.getReturnType());
-            getWebBeansContext().getEJBInterceptorConfig().configure(annotatedType);
+            startContainer(AroundInvokeWithStaticMethodComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -391,6 +351,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -398,10 +359,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            InjectionTargetBean<?> component = defineManagedBean(AroundInvokeWithFinalMethodComponent.class);
-            AnnotatedType annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(component.getReturnType());
-            getWebBeansContext().getEJBInterceptorConfig().configure(annotatedType);
+            startContainer(AroundInvokeWithFinalMethodComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -409,6 +367,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
     @Test
@@ -416,10 +375,7 @@ public class ExceptionComponentTest exte
     {
         try
         {
-            clear();
-            InjectionTargetBean<?> component = defineManagedBean(NoArgConstructorInterceptorComponent.class);
-            AnnotatedType annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(component.getReturnType());
-            getWebBeansContext().getEJBInterceptorConfig().configure(annotatedType);
+            startContainer(NoArgConstructorInterceptorComponent.class);
         }
         catch (WebBeansConfigurationException e)
         {
@@ -427,6 +383,7 @@ public class ExceptionComponentTest exte
             return; // all ok!
         }
         Assert.fail("expecting an exception!");
+        shutDownContainer();
     }
 
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PostConstructComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PostConstructComponentTest.java?rev=1435572&r1=1435571&r2=1435572&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PostConstructComponentTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PostConstructComponentTest.java Sat Jan 19 15:40:04 2013
@@ -25,10 +25,8 @@ import javax.enterprise.inject.spi.BeanM
 import junit.framework.Assert;
 
 import org.apache.webbeans.component.AbstractOwbBean;
-import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.ContextFactory;
-import org.apache.webbeans.intercept.InterceptorData;
 import org.apache.webbeans.test.TestContext;
 import org.apache.webbeans.test.component.CheckWithCheckPayment;
 import org.apache.webbeans.test.component.PostConstructComponent;