[jboss-cvs] JBossAS SVN: r57813 - branches/JEE5_TCK/ejb3/src/main/org/jboss/injection

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Oct 25 06:27:08 EDT 2006


Author: thomas.diesler at jboss.com
Date: 2006-10-25 06:27:02 -0400 (Wed, 25 Oct 2006)
New Revision: 57813

Modified:
   branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/InjectionUtil.java
   branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java
   branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java
Log:
Implement @WebServiceRefs

Modified: branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/InjectionUtil.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/InjectionUtil.java	2006-10-25 06:12:33 UTC (rev 57812)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/InjectionUtil.java	2006-10-25 10:27:02 UTC (rev 57813)
@@ -201,6 +201,11 @@
 
    }
 
+   public static String getEncName(Class type)
+   {
+      return "env/" + type.getName();
+   }
+
    public static String getEncName(Method method)
    {
       String encName = method.getName().substring(3);
@@ -213,13 +218,13 @@
          encName = encName.toLowerCase();
       }
 
-      encName = "env/" + method.getDeclaringClass().getName() + "/" + encName;
+      encName = getEncName(method.getDeclaringClass()) + "/" + encName;
       return encName;
    }
 
    public static String getEncName(Field field)
    {
-      return "env/" + field.getDeclaringClass().getName() + "/" + field.getName();
+      return getEncName(field.getDeclaringClass()) + "/" + field.getName();
    }
 
    public static Object getAnnotation(Class annotation, EJBContainer container, Class annotatedClass, boolean isContainer)

Modified: branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java	2006-10-25 06:12:33 UTC (rev 57812)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java	2006-10-25 10:27:02 UTC (rev 57813)
@@ -49,13 +49,42 @@
       }
    }
 
-   public void handleClassAnnotations(Class clazz, InjectionContainer container)
+   public void handleClassAnnotations(Class type, InjectionContainer container)
    {
-      javax.xml.ws.WebServiceRef ref = container.getAnnotation(javax.xml.ws.WebServiceRef.class, clazz);
+      javax.xml.ws.WebServiceRef ref = container.getAnnotation(javax.xml.ws.WebServiceRef.class, type);
       if (ref != null)
-         throw new IllegalArgumentException("@WebServiceRef not supported at class level");
+      {
+         bindRefOnType(type, container, ref);
+      }
+
+      javax.xml.ws.WebServiceRefs refs = container.getAnnotation(javax.xml.ws.WebServiceRefs.class, type);
+      if (refs != null)
+      {
+         for (javax.xml.ws.WebServiceRef refItem : refs.value())
+         {
+            bindRefOnType(type, container, refItem);
+         }
+      }
    }
 
+   private void bindRefOnType(Class type, InjectionContainer container, javax.xml.ws.WebServiceRef ref)
+   {
+      String encName = ref.name();
+      if (encName.equals(""))
+      {
+         encName = InjectionUtil.getEncName(type);
+      }
+      else
+      {
+         encName = "env/" + encName;
+      }
+      
+      if (!container.getEncInjectors().containsKey(encName))
+      {
+         container.getEncInjectors().put(encName, new WebServiceRefInjector(container.getEnc(), encName, null, ref));
+      }
+   }
+
    public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
    {
       javax.xml.ws.WebServiceRef ref = method.getAnnotation(javax.xml.ws.WebServiceRef.class);

Modified: branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java	2006-10-25 06:12:33 UTC (rev 57812)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java	2006-10-25 10:27:02 UTC (rev 57813)
@@ -42,32 +42,35 @@
 
    private Context ctx;
    private String encName;
-   private Class type;
+   private Class refType;
+   private String refTypeName;
    private WebServiceRef ref;
 
-   public WebServiceRefInjector(Context ctx, String encName, Class type, WebServiceRef ref)
+   public WebServiceRefInjector(Context ctx, String encName, Class refType, WebServiceRef ref)
    {
       this.ctx = ctx;
       this.encName = encName;
-      this.type = type;
+      this.refType = refType;
       this.ref = ref;
+      
+      this.refTypeName = (refType != null ? refType.getName() : null);
    }
 
    public void inject(InjectionContainer container)
    {
       try
       {
-         WebServiceRefDeployer.setupWebServiceRef(ctx, encName, type, ref);
-         log.debug("@WebServiceRef bound [env=" + encName + ",ref=" + ref.getClass().getName() + "]");
+         WebServiceRefDeployer.setupWebServiceRef(ctx, encName, refType, ref);
+         log.debug("@WebServiceRef bound [env=" + encName + ",ref=" + refTypeName + "]");
       }
       catch (Exception e)
       {
-         throw new WebServiceException("Unable to bind @WebServiceRef [enc=" + encName + ",type=" + type.getName() + "]", e);
+         throw new WebServiceException("Unable to bind @WebServiceRef [enc=" + encName + ",type=" + refTypeName + "]", e);
       }
    }
 
    public String toString()
    {
-      return super.toString() + "{enc=" + encName + ",type=" + type.getName() + "}";
+      return super.toString() + "{enc=" + encName + ",type=" + refTypeName + "}";
    }
 }




More information about the jboss-cvs-commits mailing list