Author: struberg
Date: Mon Dec 31 16:03:50 2012
New Revision: 1427158

URL: http://svn.apache.org/viewvc?rev=1427158&view=rev
Log:
OWB-549 remove trivial methods from ClassUtil

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

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=1427158&r1=1427157&r2=1427158&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
 Mon Dec 31 16:03:50 2012
@@ -218,7 +218,7 @@ public final class InterceptorUtil
                         Class<?>[] params = clazzParameters.toArray(new 
Class<?>[clazzParameters.size()]);
                         if (params.length == 1 && 
params[0].equals(InvocationContext.class))
                         {
-                            if 
(ClassUtil.getReturnType(method.getJavaMember()).equals(Object.class))
+                            if 
(method.getJavaMember().getReturnType().equals(Object.class))
                             {
                                 if 
(!ClassUtil.isMethodHasCheckedException(method.getJavaMember()))
                                 {
@@ -245,12 +245,12 @@ public final class InterceptorUtil
         {
             if (AnnotationUtil.hasMethodAnnotation(method, AroundInvoke.class))
             {
-                if (ClassUtil.isMethodHasParameter(method))
+                Class<?>[] params = method.getParameterTypes();
+                if (params.length > 0)
                 {
-                    Class<?>[] params = 
ClassUtil.getMethodParameterTypes(method);
                     if (params.length == 1 && 
params[0].equals(InvocationContext.class))
                     {
-                        if 
(ClassUtil.getReturnType(method).equals(Object.class))
+                        if (method.getReturnType().equals(Object.class))
                         {
                             if (!Modifier.isStatic(method.getModifiers()) && 
!Modifier.isFinal(method.getModifiers()))
                             {
@@ -258,7 +258,6 @@ public final class InterceptorUtil
                             }
                         }
                     }
-
                 }
             }
         }
@@ -277,12 +276,13 @@ public final class InterceptorUtil
                 || AnnotationUtil.hasMethodAnnotation(method, 
prePassivateClass)
                )
             {
-                if (ClassUtil.isMethodHasParameter(method))
+                Class<?>[] params = method.getParameterTypes();
+                if (params.length > 0)
                 {
-                    Class<?>[] params = 
ClassUtil.getMethodParameterTypes(method);
+
                     if (params.length == 1 && 
params[0].equals(InvocationContext.class))
                     {
-                        if (ClassUtil.getReturnType(method).equals(Void.TYPE))
+                        if (method.getReturnType().equals(Void.TYPE))
                         {
                             if (!ClassUtil.isMethodHasCheckedException(method))
                             {
@@ -325,7 +325,7 @@ public final class InterceptorUtil
                         Class<?>[] params = clazzParameters.toArray(new 
Class<?>[clazzParameters.size()]);
                         if (params.length == 1 && 
params[0].equals(InvocationContext.class))
                         {
-                            if 
(ClassUtil.getReturnType(method.getJavaMember()).equals(Void.TYPE))
+                            if 
(method.getJavaMember().getReturnType().equals(Void.TYPE))
                             {
                                 if 
(!ClassUtil.isMethodHasCheckedException(method.getJavaMember()))
                                 {

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=1427158&r1=1427157&r2=1427158&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
 Mon Dec 31 16:03:50 2012
@@ -30,7 +30,6 @@ import org.apache.webbeans.inject.Inject
 import org.apache.webbeans.inject.InjectableMethods;
 import org.apache.webbeans.intercept.OwbInterceptor;
 import org.apache.webbeans.util.AnnotationUtil;
-import org.apache.webbeans.util.WebBeansUtil;
 
 import javax.enterprise.context.spi.Context;
 import javax.enterprise.context.spi.CreationalContext;
@@ -254,12 +253,12 @@ public class WebBeansInterceptor<T> exte
         
         if(type.equals(InterceptionType.AROUND_INVOKE))
         {
-            method = 
WebBeansUtil.checkAroundInvokeAnnotationCriterias(getClazz(),AroundInvoke.class);
+            method = 
webBeansContext.getWebBeansUtil().checkAroundInvokeAnnotationCriterias(getClazz(),
 AroundInvoke.class);
         }
 
         else if(type.equals(InterceptionType.AROUND_TIMEOUT))
         {
-            method = 
WebBeansUtil.checkAroundInvokeAnnotationCriterias(getClazz(),AroundTimeout.class);
+            method = 
webBeansContext.getWebBeansUtil().checkAroundInvokeAnnotationCriterias(getClazz(),
 AroundTimeout.class);
         }
         
         else

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=1427158&r1=1427157&r2=1427158&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
 Mon Dec 31 16:03:50 2012
@@ -208,33 +208,6 @@ public final class ClassUtil
     }
 
     /**
-     * Check that method has any formal arguments.
-     * 
-     * @param method method instance
-     * @return true or false
-     * @deprecated it's better to do such easy things directly in the code
-     */
-    public static boolean isMethodHasParameter(Method method)
-    {
-        Asserts.nullCheckForMethod(method);
-
-        return method.getParameterTypes().length > 0;
-    }
-
-    /**
-     * Gets the return type of the method.
-     * 
-     * @param method method instance
-     * @return return type
-     * @deprecated it's better to do such easy things directly in the code
-     */
-    public static Class<?> getReturnType(Method method)
-    {
-        Asserts.nullCheckForMethod(method);
-        return method.getReturnType();
-    }
-
-    /**
      * Check method throws checked exception or not.
      * 
      * @param method method instance

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=1427158&r1=1427157&r2=1427158&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
 Mon Dec 31 16:03:50 2012
@@ -755,7 +755,7 @@ public final class WebBeansUtil
     {
         Asserts.nullCheckForClass(clazz);
 
-        Method[] methods = ClassUtil.getDeclaredMethods(clazz);
+        Method[] methods = 
webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(clazz);
         Method result = null;
         boolean found = false;
         for (Method method : methods)
@@ -777,10 +777,10 @@ public final class WebBeansUtil
                 result = method;
 
                 // Check method criterias
-                if (ClassUtil.isMethodHasParameter(method))
+                Class<?>[] params = method.getParameterTypes();
+                if (params.length > 0)
                 {
                     // Check method criterias
-                    Class<?>[] params = 
ClassUtil.getMethodParameterTypes(method);
                     if (params.length != 1 || 
!params[0].equals(InvocationContext.class))
                     {
                         throw new WebBeansConfigurationException("@" + 
commonAnnotation.getSimpleName()
@@ -794,7 +794,7 @@ public final class WebBeansUtil
                     return null;
                 }
 
-                if (!ClassUtil.getReturnType(method).equals(Void.TYPE))
+                if (!method.getReturnType().equals(Void.TYPE))
                 {
                     throw new WebBeansConfigurationException("@" + 
commonAnnotation.getSimpleName()
                             + " annotated method : " + method.getName() + " in 
class : " + clazz.getName()
@@ -878,7 +878,7 @@ public final class WebBeansUtil
                             + " must take a parameter with class type 
javax.interceptor.InvocationContext.");
                 }
 
-                if (!ClassUtil.getReturnType(method).equals(Void.TYPE))
+                if (!method.getReturnType().equals(Void.TYPE))
                 {
                     throw new WebBeansConfigurationException("@" + 
commonAnnotation.getSimpleName()
                             + " annotated method : " + method.getName() + " in 
class : " + clazz.getName()
@@ -918,11 +918,11 @@ public final class WebBeansUtil
      * @param clazz checked class
      * @return around invoke method
      */
-    public static Method checkAroundInvokeAnnotationCriterias(Class<?> clazz, 
Class<? extends Annotation> annot)
+    public Method checkAroundInvokeAnnotationCriterias(Class<?> clazz, Class<? 
extends Annotation> annot)
     {
         Asserts.nullCheckForClass(clazz);
 
-        Method[] methods = ClassUtil.getDeclaredMethods(clazz);
+        Method[] methods = 
webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(clazz);
         Method result = null;
         boolean found = false;
         for (Method method : methods)
@@ -945,7 +945,7 @@ public final class WebBeansUtil
                 result = method;
 
                 // Check method criterias
-                Class<?>[] params = ClassUtil.getMethodParameterTypes(method);
+                Class<?>[] params = method.getParameterTypes();
                 if (params.length != 1 || 
!params[0].equals(InvocationContext.class))
                 {
                     throw new WebBeansConfigurationException("@" + 
annot.getSimpleName() + " annotated method : "
@@ -953,7 +953,7 @@ public final class WebBeansUtil
                             + " can not take any formal arguments other than 
InvocationContext");
                 }
 
-                if (!ClassUtil.getReturnType(method).equals(Object.class))
+                if (!method.getReturnType().equals(Object.class))
                 {
                     throw new WebBeansConfigurationException("@" + 
annot.getSimpleName() + " annotated method : "
                             + method.getName() + " in class : " + 
clazz.getName() + " must return Object type");
@@ -970,7 +970,7 @@ public final class WebBeansUtil
         return result;
     }
 
-    public static <T> Method 
checkAroundInvokeAnnotationCriterias(AnnotatedType<T> annotatedType, Class<? 
extends Annotation> annot)
+    public <T> Method checkAroundInvokeAnnotationCriterias(AnnotatedType<T> 
annotatedType, Class<? extends Annotation> annot)
     {
         Method result = null;
         boolean found = false;
@@ -1014,7 +1014,7 @@ public final class WebBeansUtil
                             + " can not take any formal arguments other than 
InvocationContext");
                 }
 
-                if 
(!ClassUtil.getReturnType(method.getJavaMember()).equals(Object.class))
+                if 
(!method.getJavaMember().getReturnType().equals(Object.class))
                 {
                     throw new WebBeansConfigurationException("@" + 
annot.getSimpleName() + " annotated method : "
                             + method.getJavaMember().getName()+ " in class : " 
+ annotatedType.getJavaClass().getName()
@@ -1059,9 +1059,9 @@ public final class WebBeansUtil
                                              Method 
annotatedInterceptorClassMethod,
                                              boolean 
defineWithInterceptorBinding)
     {
-        InterceptorData intData = null;
+        InterceptorData intData;
         Method method = null;
-        OpenWebBeansEjbLCAPlugin ejbPlugin = null;
+        OpenWebBeansEjbLCAPlugin ejbPlugin;
         Class<? extends Annotation> prePassivateClass  = null;
         Class<? extends Annotation> postActivateClass  = null;
 
@@ -1088,7 +1088,7 @@ public final class WebBeansUtil
 
         if (interceptionType.equals(AroundInvoke.class) || 
interceptionType.equals(AroundTimeout.class))
         {
-            method = 
WebBeansUtil.checkAroundInvokeAnnotationCriterias(interceptorClass, 
interceptionType);
+            method = checkAroundInvokeAnnotationCriterias(interceptorClass, 
interceptionType);
         }
         else if (interceptionType.equals(PostConstruct.class) || 
((postActivateClass != null) && (interceptionType.equals(postActivateClass)))
                  || interceptionType.equals(PreDestroy.class) || 
((prePassivateClass != null) && (interceptionType.equals(prePassivateClass))))
@@ -1124,9 +1124,9 @@ public final class WebBeansUtil
                                                  List<InterceptorData> stack,
                                                  Method 
annotatedInterceptorClassMethod)
     {
-        InterceptorData intData = null;
+        InterceptorData intData;
         Method method = null;
-        OpenWebBeansEjbLCAPlugin ejbPlugin = null;
+        OpenWebBeansEjbLCAPlugin ejbPlugin;
         Class<? extends Annotation> prePassivateClass  = null;
         Class<? extends Annotation> postActivateClass  = null;
 
@@ -1140,7 +1140,7 @@ public final class WebBeansUtil
         if (annotation.equals(AroundInvoke.class) ||
                 annotation.equals(AroundTimeout.class))
         {
-            method = 
WebBeansUtil.checkAroundInvokeAnnotationCriterias(annotatedType, annotation);
+            method = checkAroundInvokeAnnotationCriterias(annotatedType, 
annotation);
         }
         else if (annotation.equals(PostConstruct.class) || ((postActivateClass 
!= null) && (annotation.equals(postActivateClass)))
                  || annotation.equals(PreDestroy.class) || ((prePassivateClass 
!= null) && (annotation.equals(prePassivateClass))))


Reply via email to