[jboss-cvs] JBossAS SVN: r82670 - projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 7 13:05:36 EST 2009


Author: petemuir
Date: 2009-01-07 13:05:36 -0500 (Wed, 07 Jan 2009)
New Revision: 82670

Modified:
   projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb/JBossEjbResolver.java
Log:
Support methods annotated with @EJB

Modified: projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb/JBossEjbResolver.java
===================================================================
--- projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb/JBossEjbResolver.java	2009-01-07 17:59:58 UTC (rev 82669)
+++ projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/ejb/JBossEjbResolver.java	2009-01-07 18:05:36 UTC (rev 82670)
@@ -1,10 +1,13 @@
 package org.jboss.webbeans.integration.jbossas.ejb;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 
 import javax.ejb.EJB;
 import javax.persistence.PersistenceContext;
 import javax.servlet.ServletContext;
+import javax.webbeans.DefinitionException;
 import javax.webbeans.InjectionPoint;
 
 import org.jboss.deployers.structure.spi.DeploymentUnit;
@@ -48,9 +51,24 @@
       String mappedName = annotation.mappedName();
 
       // Supply beanInterface from reflection if not explicitly-defined
-      if (beanInterface == null || beanInterface.equals(Object.class.getName()) && injectionPoint.getType() instanceof Class)
+      if (beanInterface == null || beanInterface.equals(Object.class.getName()))
       {
-         beanInterface = ((Class<?>) injectionPoint.getType()).getName();
+         if (injectionPoint.getMember() instanceof Field && injectionPoint.getType() instanceof Class)
+         {
+            beanInterface = ((Class<?>) injectionPoint.getType()).getName();
+         }
+         else if (injectionPoint.getMember() instanceof Method)
+         {
+            Method method = (Method) injectionPoint.getMember();
+            if (method.getParameterTypes().length == 1)
+            {
+               beanInterface = method.getParameterTypes()[0].getName();
+            }
+            else
+            {
+               throw new DefinitionException("Can only inject into a method with one parameter " + injectionPoint);
+            }
+         }
       }
 
       return JBossEjb.lookupEjbReferenceResolver(controller).resolveEjb(topLevelDeploymentUnit, new EjbReference(beanName, beanInterface, mappedName));




More information about the jboss-cvs-commits mailing list