[jbossws-commits] JBossWS SVN: r9720 - common/trunk/src/main/java/org/jboss/wsf/common/javax.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Fri Apr 3 09:51:03 EDT 2009


Author: richard.opalka at jboss.com
Date: 2009-04-03 09:51:03 -0400 (Fri, 03 Apr 2009)
New Revision: 9720

Modified:
   common/trunk/src/main/java/org/jboss/wsf/common/javax/JavaxAnnotationHelper.java
Log:
[JBWS-2074] final cleanup

Modified: common/trunk/src/main/java/org/jboss/wsf/common/javax/JavaxAnnotationHelper.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/javax/JavaxAnnotationHelper.java	2009-04-03 13:41:28 UTC (rev 9719)
+++ common/trunk/src/main/java/org/jboss/wsf/common/javax/JavaxAnnotationHelper.java	2009-04-03 13:51:03 UTC (rev 9720)
@@ -76,51 +76,50 @@
     * @param injections injections metadata
     * @throws Exception if some error occurs
     */
-   public static void injectResources(Object instance, InjectionsMetaData injections) throws Exception
+   public static void injectResources(final Object instance, final InjectionsMetaData injections) throws Exception
    {
       if (instance == null)
          throw new IllegalArgumentException("Object instance cannot be null");
+      if (injections == null)
+         throw new IllegalArgumentException("Injections metadata cannot be null");
       
       Class<?> instanceClass = instance.getClass();
       
       InitialContext ctx = new InitialContext();
 
       // inject descriptor driven annotations
-      if (injections != null)
+      Collection<InjectionMetaData> injectionMDs = injections.getInjectionsMetaData(instanceClass);
+      for (InjectionMetaData injectionMD : injectionMDs)
       {
-         Collection<InjectionMetaData> injectionMDs = injections.getInjectionsMetaData(instanceClass);
-         for (InjectionMetaData injectionMD : injectionMDs)
+         Method method = getMethod(injectionMD, instanceClass);
+         if (method != null)
          {
-            Method method = getMethod(injectionMD, instanceClass);
-            if (method != null)
+            try
             {
+               inject(instance, method, injectionMD.getEnvEntryName(), ctx);
+            }
+            catch (Exception e)
+            {
+               LOG.warn("Cannot inject method (descriptor driven injection): " + injectionMD, e);
+            }
+         }
+         else
+         {
+            Field field = getField(injectionMD, instanceClass);
+            if (field != null)
+            {
                try
                {
-                  inject(instance, method, injectionMD.getEnvEntryName(), ctx);
+                  inject(instance, field, injectionMD.getEnvEntryName(), ctx);
                }
                catch (Exception e)
                {
-                  LOG.warn("Cannot inject method (descriptor driven injection): " + injectionMD, e);
+                  LOG.warn("Cannot inject field (descriptor driven injection): " + injectionMD, e);
                }
             }
             else
             {
-               Field field = getField(injectionMD, instanceClass);
-               if (field != null)
-               {
-                  try
-                  {
-                     inject(instance, field, injectionMD.getEnvEntryName(), ctx);
-                  }
-                  catch (Exception e)
-                  {
-                     LOG.warn("Cannot inject field (descriptor driven injection): " + injectionMD, e);
-                  }
-               }
-               else
-               {
-                  LOG.warn("Cannot find injection target for: " + injectionMD);
-               }
+               LOG.warn("Cannot find injection target for: " + injectionMD);
             }
          }
       }
@@ -154,7 +153,7 @@
       }
    }
    
-   public static void injectWebServiceContext(Object instance, WebServiceContext ctx)
+   public static void injectWebServiceContext(final Object instance, final WebServiceContext ctx)
    {
       final Class<?> instanceClass = instance.getClass();
       
@@ -195,7 +194,7 @@
     * @see org.jboss.wsf.common.javax.finders.PostConstructMethodFinder
     * @see javax.annotation.PostConstruct
     */
-   public static void callPostConstructMethod(Object instance) throws Exception
+   public static void callPostConstructMethod(final Object instance) throws Exception
    {
       if (instance == null)
          throw new IllegalArgumentException("Object instance cannot be null");
@@ -225,7 +224,7 @@
     * @see org.jboss.wsf.common.javax.finders.PreDestroyMethodFinder
     * @see javax.annotation.PreDestroy
     */
-   public static void callPreDestroyMethod(Object instance) throws Exception
+   public static void callPreDestroyMethod(final Object instance) throws Exception
    {
       if (instance == null)
          throw new IllegalArgumentException("Object instance cannot be null");
@@ -257,7 +256,8 @@
     * @throws Exception if any error occurs
     * @see org.jboss.wsf.common.javax.finders.ResourceMethodFinder
     */
-   private static void inject(final Object instance, final Method method, String resourceName, InitialContext ctx) throws Exception
+   private static void inject(final Object instance, final Method method, final String resourceName, final InitialContext ctx)
+   throws Exception
    {
       final String beanName = convertToBeanName(method.getName()); 
       final Object value = ctx.lookup(getName(resourceName, beanName));
@@ -276,7 +276,8 @@
     * @throws Exception if any error occurs
     * @see org.jboss.wsf.common.javax.finders.ResourceFieldFinder
     */
-   private static void inject(final Object instance, final Field field, String resourceName, InitialContext ctx) throws Exception
+   private static void inject(final Object instance, final Field field, final String resourceName, final InitialContext ctx)
+   throws Exception
    {
       final String beanName = field.getName();
       final Object value = ctx.lookup(getName(resourceName, beanName));
@@ -316,7 +317,8 @@
     * @param args arguments to pass
     * @throws Exception if any error occurs
     */
-   private static void invokeMethod(final Object instance, final Method method, final Object[] args) throws Exception
+   private static void invokeMethod(final Object instance, final Method method, final Object[] args)
+   throws Exception
    {
       boolean accessability = method.isAccessible();
       
@@ -339,7 +341,8 @@
     * @param value to be set
     * @throws Exception if any error occurs
     */
-   private static void setField(final Object instance, final Field field, final Object value) throws Exception
+   private static void setField(final Object instance, final Field field, final Object value)
+   throws Exception
    {
       boolean accessability = field.isAccessible();
       
@@ -362,9 +365,9 @@
     * @return method that matches the criteria or null if not found
     * @see org.jboss.wsf.common.javax.finders.InjectionMethodFinder
     */
-   private static Method getMethod(InjectionMetaData injectionMD, Class<?> clazz)
+   private static Method getMethod(final InjectionMetaData injectionMD, final Class<?> clazz)
    {
-      Collection<Method> result = new InjectionMethodFinder(injectionMD).process(clazz);
+      final Collection<Method> result = new InjectionMethodFinder(injectionMD).process(clazz);
       
       return result.isEmpty() ? null : result.iterator().next();
    }
@@ -377,9 +380,9 @@
     * @return field that matches the criteria or null if not found
     * @see org.jboss.wsf.common.javax.finders.InjectionFieldFinder
     */
-   private static Field getField(InjectionMetaData injectionMD, Class<?> clazz)
+   private static Field getField(final InjectionMetaData injectionMD, final Class<?> clazz)
    {
-      Collection<Field> result = new InjectionFieldFinder(injectionMD).process(clazz);
+      final Collection<Field> result = new InjectionFieldFinder(injectionMD).process(clazz);
       
       return result.isEmpty() ? null : result.iterator().next();
    }




More information about the jbossws-commits mailing list