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 23:13:37 UTC

svn commit: r1435738 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

Author: struberg
Date: Sat Jan 19 22:13:37 2013
New Revision: 1435738

URL: http://svn.apache.org/viewvc?rev=1435738&view=rev
Log:
OWB-344 remove unused code

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

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=1435738&r1=1435737&r2=1435738&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 22:13:37 2013
@@ -38,8 +38,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
 import javax.decorator.Decorator;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.NormalScope;
@@ -52,7 +50,6 @@ import javax.enterprise.inject.spi.After
 import javax.enterprise.inject.spi.AfterDeploymentValidation;
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
@@ -75,8 +72,6 @@ import javax.enterprise.inject.spi.Proce
 import javax.inject.Inject;
 import javax.inject.Named;
 import javax.inject.Scope;
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.InvocationContext;
 
 import org.apache.webbeans.annotation.AnnotationManager;
 import org.apache.webbeans.component.InjectionTargetBean;
@@ -571,315 +566,6 @@ public final class WebBeansUtil
         return new InjectionPointBean(webBeansContext);
     }
 
-    /**
-     * Check the {@link PostConstruct} or {@link PreDestroy} annotated method
-     * criterias, and return post construct or pre destroyDependents method.
-     * <p>
-     * Web Beans container is responsible for setting the post construct or pre
-     * destroyDependents annotation if the web beans component is not an EJB components,
-     * in this case EJB container is responsible for this.
-     * </p>
-     *
-     * @param clazz checked class
-     * @param commonAnnotation post construct or predestroy annotation
-     * @param invocationContext whether the takes an invocationContext, as in
-     *            interceptors defiend outside of the bean class.
-     * @return post construct or predestroy method
-     */
-    public Set<Method> checkCommonAnnotationCriterias(Class<?> clazz, Class<? extends Annotation> commonAnnotation, boolean invocationContext)
-    {
-        Asserts.nullCheckForClass(clazz);
-
-        Method[] methods = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(clazz);
-        Method result = null;
-        boolean found = false;
-        for (Method method : methods)
-        {
-            if (AnnotationUtil.hasMethodAnnotation(method, commonAnnotation))
-            {
-                if (ClassUtil.isMoreThanOneMethodWithName(method.getName(), clazz))
-                {
-                    continue;
-                }
-
-                if (found)
-                {
-                    throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
-                            + " annotation is declared more than one method in the class : " + clazz.getName());
-                }
-
-                found = true;
-                result = method;
-
-                // Check method criterias
-                Class<?>[] params = method.getParameterTypes();
-                if (params.length > 0)
-                {
-                    // Check method criterias
-                    if (params.length != 1 || !params[0].equals(InvocationContext.class))
-                    {
-                        throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
-                                + " annotated method : " + method.getName() + " in class : " + clazz.getName()
-                                + " can not take any formal arguments other than InvocationContext");
-                    }
-                }
-                else if(invocationContext)
-                {
-                    // Maybe it just intercepts itself, but we were looking at it like an @Interceptor
-                    return null;
-                }
-
-                if (!method.getReturnType().equals(Void.TYPE))
-                {
-                    throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
-                            + " annotated method : " + method.getName() + " in class : " + clazz.getName()
-                            + " must return void type");
-                }
-
-                if (isNoCheckedExceptionEnforced() && ClassUtil.isMethodHasCheckedException(method))
-                {
-                    throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
-                            + " annotated method : " + method.getName() + " in class : " + clazz.getName()
-                            + " can not throw any checked exception");
-                }
-
-                if (Modifier.isStatic(method.getModifiers()))
-                {
-                    throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
-                            + " annotated method : " + method.getName() + " in class : "
-                            + clazz.getName() + " can not be static");
-                }
-            }
-        }
-
-        if (result != null)
-        {
-            Set<Method> resultSet = new HashSet<Method>();
-            resultSet.add(result);
-            return resultSet;
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-    public <T> Set<Method> checkCommonAnnotationCriterias(AnnotatedType<T> annotatedType, Class<? extends Annotation> commonAnnotation, boolean invocationContext)
-    {
-        Class<?> clazz = annotatedType.getJavaClass();
-
-        Set<Method> result = new HashSet<Method>();
-        Set<Class<?>> foundInClass = new HashSet<Class<?>>();
-        Set<AnnotatedMethod<? super T>> methods = annotatedType.getMethods();
-        for(AnnotatedMethod<? super T> methodA : methods)
-        {
-            AnnotatedMethod<T> methodB = (AnnotatedMethod<T>)methodA;
-            Method method = methodB.getJavaMember();
-            if (method.isAnnotationPresent(commonAnnotation))
-            {
-                if (ClassUtil.isMoreThanOneMethodWithName(method.getName(), clazz))
-                {
-                    continue;
-                }
-
-                if (foundInClass.contains(method.getDeclaringClass()))
-                {
-                    throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
-                            + " annotation is declared more than one method in the class : " + clazz.getName());
-                }
-                result.add(method);
-                foundInClass.add(method.getDeclaringClass());
-
-                // Check method criterias
-                if (!methodB.getParameters().isEmpty())
-                {
-                    if (methodB.getParameters().size() != 1 || !ClassUtil.getClass(methodB.getParameters().get(0).getBaseType()).equals(InvocationContext.class))
-                    {
-                        throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
-                                + " annotated method : " + method.getName() + " in class : " + clazz.getName()
-                                + " can not take any formal arguments other than InvocationContext");
-                    }
-                }
-                else if(invocationContext)
-                {
-                    // Maybe it just intercepts itself, but we were looking at it like an @Interceptor
-                    return null;
-                }
-
-                if (!method.getReturnType().equals(Void.TYPE))
-                {
-                    throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
-                            + " annotated method : " + method.getName() + " in class : " + clazz.getName()
-                            + " must return void type");
-                }
-
-                if (isNoCheckedExceptionEnforced() && ClassUtil.isMethodHasCheckedException(method))
-                {
-                    throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
-                            + " annotated method : " + method.getName() + " in class : " + clazz.getName()
-                            + " can not throw any checked exception");
-                }
-
-                if (Modifier.isStatic(method.getModifiers()))
-                {
-                    throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
-                            + " annotated method : " + method.getName() + " in class : " + clazz.getName()
-                            + " can not be static");
-                }
-            }
-
-        }
-
-
-        return result;
-    }
-
-    /**
-     * Check the {@link AroundInvoke} annotated method criterias, and return
-     * around invoke method.
-     * <p>
-     * Web Beans container is responsible for setting around invoke annotation
-     * if the web beans component is not an EJB components, in this case EJB
-     * container is responsible for this.
-     * </p>
-     *
-     * @param clazz checked class
-     * @return around invoke method
-     */
-    public Set<Method> checkAroundInvokeAnnotationCriterias(Class<?> clazz, Class<? extends Annotation> annot)
-    {
-        Asserts.nullCheckForClass(clazz);
-
-        Method[] methods = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(clazz);
-        Method result = null;
-        boolean found = false;
-        for (Method method : methods)
-        {
-            if (AnnotationUtil.hasMethodAnnotation(method, annot))
-            {
-                // Overriden methods
-                if (ClassUtil.isMoreThanOneMethodWithName(method.getName(), clazz))
-                {
-                    continue;
-                }
-
-                if (found)
-                {
-                    throw new WebBeansConfigurationException("@" + annot.getSimpleName()
-                            + " annotation is declared more than one method in the class : " + clazz.getName());
-                }
-
-                found = true;
-                result = method;
-
-                // Check method criterias
-                Class<?>[] params = method.getParameterTypes();
-                if (params.length != 1 || !params[0].equals(InvocationContext.class))
-                {
-                    throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : "
-                            + method.getName() + " in class : " + clazz.getName()
-                            + " can not take any formal arguments other than InvocationContext");
-                }
-
-                if (!method.getReturnType().equals(Object.class))
-                {
-                    throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : "
-                            + method.getName() + " in class : " + clazz.getName() + " must return Object type");
-                }
-
-                if (Modifier.isStatic(method.getModifiers()) || Modifier.isFinal(method.getModifiers()))
-                {
-                    throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : "
-                            + method.getName() + " in class : " + clazz.getName() + " can not be static or final");
-                }
-            }
-        }
-
-        if (result != null)
-        {
-            Set<Method> resultSet = new HashSet<Method>();
-            resultSet.add(result);
-            return resultSet;
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-    public <T> Set<Method> checkAroundInvokeAnnotationCriterias(AnnotatedType<T> annotatedType, Class<? extends Annotation> annot)
-    {
-        Method result = null;
-        boolean found = false;
-        Set<AnnotatedMethod<? super T>> methods = annotatedType.getMethods();
-        for(AnnotatedMethod<? super T> methodA : methods)
-        {
-            AnnotatedMethod<T> method = (AnnotatedMethod<T>)methodA;
-
-            if (method.isAnnotationPresent(annot))
-            {
-                // Overriden methods
-                if (ClassUtil.isMoreThanOneMethodWithName(method.getJavaMember().getName(),
-                                                          annotatedType.getJavaClass()))
-                {
-                    continue;
-                }
-
-                if (found)
-                {
-                    throw new WebBeansConfigurationException("@" + annot.getSimpleName()
-                            + " annotation is declared more than one method in the class : "
-                            + annotatedType.getJavaClass().getName());
-                }
-
-                found = true;
-                result = method.getJavaMember();
-
-                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))
-                {
-                    throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : "
-                            + method.getJavaMember().getName() + " in class : " + annotatedType.getJavaClass().getName()
-                            + " can not take any formal arguments other than InvocationContext");
-                }
-
-                if (!method.getJavaMember().getReturnType().equals(Object.class))
-                {
-                    throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : "
-                            + method.getJavaMember().getName()+ " in class : " + annotatedType.getJavaClass().getName()
-                            + " must return Object type");
-                }
-
-                if (Modifier.isStatic(method.getJavaMember().getModifiers()) ||
-                    Modifier.isFinal(method.getJavaMember().getModifiers()))
-                {
-                    throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : "
-                            + method.getJavaMember().getName( )+ " in class : " + annotatedType.getJavaClass().getName()
-                            + " can not be static or final");
-                }
-            }
-        }
-
-        if (result != null)
-        {
-            Set<Method> resultSet = new HashSet<Method>();
-            resultSet.add(result);
-            return resultSet;
-        }
-        else
-        {
-            return null;
-        }
-    }
-
     public static String getManagedBeanDefaultName(String clazzName)
     {
         Asserts.assertNotNull(clazzName);