[jbossws-commits] JBossWS SVN: r9718 - framework/trunk/src/main/java/org/jboss/wsf/framework/invocation.

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


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

Modified:
   framework/trunk/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java
Log:
[JBWS-2074] adding support for WebServiceContext injection

Modified: framework/trunk/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java
===================================================================
--- framework/trunk/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java	2009-04-03 13:34:04 UTC (rev 9717)
+++ framework/trunk/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java	2009-04-03 13:35:51 UTC (rev 9718)
@@ -21,65 +21,21 @@
  */
 package org.jboss.wsf.framework.invocation;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import javax.annotation.Resource;
 import javax.xml.ws.WebServiceContext;
 
-import org.jboss.logging.Logger;
+import org.jboss.wsf.common.javax.JavaxAnnotationHelper;
 import org.jboss.wsf.spi.invocation.ResourceInjector;
 
 /**
  * Inject the JAXWS WebServiceContext
  *
  * @author Thomas.Diesler at jboss.org
- * @since 04-Jan-2007
+ * @author ropalka at redhat.com
  */
 public class WebServiceContextInjector extends ResourceInjector
 {
-   // provide logging
-   private static Logger log = Logger.getLogger(WebServiceContextInjector.class);
-
-   WebServiceContextInjector()
-   {
-   }
-
    public void inject(Object instance, WebServiceContext context)
    {
-      try
-      {
-         // scan fields that are marked with @Resource
-         Field[] fields = instance.getClass().getDeclaredFields();
-         for (Field field : fields)
-         {
-            Class type = field.getType();
-            if (type == WebServiceContext.class && field.isAnnotationPresent(Resource.class))
-            {
-               field.setAccessible(true);
-               field.set(instance, context);
-            }
-         }
-
-         // scan methods that are marked with @Resource
-         Method[] methods = instance.getClass().getDeclaredMethods();
-         for (Method method : methods)
-         {
-            Class[] paramTypes = method.getParameterTypes();
-            if (paramTypes.length == 1 && paramTypes[0] == WebServiceContext.class && method.isAnnotationPresent(Resource.class))
-            {
-               method.setAccessible(true);
-               method.invoke(instance, new Object[] { context });
-            }
-         }
-      }
-      catch (RuntimeException rte)
-      {
-         throw rte;
-      }
-      catch (Exception ex)
-      {
-         log.warn("Cannot inject WebServiceContext", ex);
-      }
+      JavaxAnnotationHelper.injectWebServiceContext(instance, context);
    }
 }




More information about the jbossws-commits mailing list