[jboss-cvs] JBossAS SVN: r82355 - in projects/ejb3/trunk: testsuite/src/test/resources and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Dec 17 23:43:18 EST 2008


Author: ALRubinger
Date: 2008-12-17 23:43:18 -0500 (Wed, 17 Dec 2008)
New Revision: 82355

Modified:
   projects/ejb3/trunk/mc-int/src/main/java/org/jboss/ejb3/mcint/metadata/plugins/AbstractEjbReferenceValueMetadata.java
   projects/ejb3/trunk/testsuite/src/test/resources/known-issues.xml
Log:
[EJBTHREE-1624] @EJB in MC Beans to define dependency on the target JNDI name, tests passing

Modified: projects/ejb3/trunk/mc-int/src/main/java/org/jboss/ejb3/mcint/metadata/plugins/AbstractEjbReferenceValueMetadata.java
===================================================================
--- projects/ejb3/trunk/mc-int/src/main/java/org/jboss/ejb3/mcint/metadata/plugins/AbstractEjbReferenceValueMetadata.java	2008-12-18 04:24:22 UTC (rev 82354)
+++ projects/ejb3/trunk/mc-int/src/main/java/org/jboss/ejb3/mcint/metadata/plugins/AbstractEjbReferenceValueMetadata.java	2008-12-18 04:43:18 UTC (rev 82355)
@@ -24,7 +24,7 @@
 import javax.naming.Context;
 import javax.naming.NamingException;
 
-import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
 import org.jboss.deployers.client.spi.DeployerClient;
 import org.jboss.deployers.client.spi.Deployment;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
@@ -39,11 +39,16 @@
 
 /**
  * AbstractEjbReferenceValueMetadata
+ * 
+ * Describes both the requisite JNDI dependency and target Proxy for injection
+ * based upon a supplied resolver, reference, and naming context.  Will 
+ * search through all eligible EJB3 deployments available from the
+ * MainDeployer
  *
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
  */
-public class AbstractEjbReferenceValueMetadata extends AbstractValueMetaData
+public class AbstractEjbReferenceValueMetadata extends AbstractDependencyValueMetaData
 {
    // --------------------------------------------------------------------------------||
    // Class Members ------------------------------------------------------------------||
@@ -53,6 +58,8 @@
 
    private static final String MC_BEAN_NAME_MAIN_DEPLOYER = "MainDeployer";
 
+   private static final String DEPENDS_JNDI_PREFIX = "jndi:";
+
    // --------------------------------------------------------------------------------||
    // Instance Members ---------------------------------------------------------------||
    // --------------------------------------------------------------------------------||  
@@ -61,7 +68,7 @@
 
    private EjbReference reference;
 
-   private Context context;
+   private Context namingContext;
 
    // --------------------------------------------------------------------------------||
    // Constructor --------------------------------------------------------------------||
@@ -80,7 +87,7 @@
       // Set properties
       this.setResolver(resolver);
       this.setReference(reference);
-      this.setContext(context);
+      this.setNamingContext(context);
    }
 
    // --------------------------------------------------------------------------------||
@@ -99,19 +106,29 @@
       return this.resolveEjb();
    }
 
+   /**
+    * Used in defining the dependency
+    */
+   @Override
+   public Object getUnderlyingValue()
+   {
+      return DEPENDS_JNDI_PREFIX + this.getTargetJndiName();
+   }
+
    // --------------------------------------------------------------------------------||
    // Functional Methods -------------------------------------------------------------||
    // --------------------------------------------------------------------------------||
 
    /**
-    * Obtains the EJB from JNDI based upon the resolved JNDI name
+    * Obtains the target JNDI name, whose value is to be injected
+    * 
+    * @return The target JNDI Name
     */
-   protected Object resolveEjb()
+   protected String getTargetJndiName()
    {
       // Initialize
-      Object obj = null;
       String jndiName = null;
-      
+
       /*
        * Look through all EJB3 DeploymentUnits
        */
@@ -150,16 +167,33 @@
          throw new UnresolvableReferenceException("Could not resolve in current deployments reference: " + reference);
       }
 
+      // Return the JNDI Name
+      return jndiName;
+   }
+
+   /**
+    * Obtains the EJB Proxy from JNDI based upon the resolved JNDI name
+    * 
+    * @return The Proxy to inject
+    */
+   protected Object resolveEjb()
+   {
+      // Initialize
+      Object obj = null;
+      String jndiName = this.getTargetJndiName();
+
       // Lookup 
       try
       {
-         obj = getContext().lookup(jndiName);
+         obj = getNamingContext().lookup(jndiName);
       }
       catch (NamingException e)
       {
          throw new RuntimeException("Could not obtain " + jndiName + "from JNDI", e);
       }
 
+      this.addDependencyItem();
+
       // Return
       return obj;
    }
@@ -188,13 +222,14 @@
       this.resolver = resolver;
    }
 
-   protected Context getContext()
+   protected Context getNamingContext()
    {
-      return context;
+      return namingContext;
    }
 
-   protected void setContext(Context context)
+   protected void setNamingContext(Context context)
    {
-      this.context = context;
+      this.namingContext = context;
    }
+
 }

Modified: projects/ejb3/trunk/testsuite/src/test/resources/known-issues.xml
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/resources/known-issues.xml	2008-12-18 04:24:22 UTC (rev 82354)
+++ projects/ejb3/trunk/testsuite/src/test/resources/known-issues.xml	2008-12-18 04:43:18 UTC (rev 82355)
@@ -24,17 +24,6 @@
   <!-- EJBTHREE-1222 / EJBTHREE-1621 -->
   <entry key="org.jboss.ejb3.test.ejbthree1222.unit.RegularRemoveMethodUnitTestCase.testRemoteNormalMethodNamedRemove">show</entry>
   <entry key="org.jboss.ejb3.test.ejbthree1222.unit.RegularRemoveMethodUnitTestCase.testLocalNormalMethodNamedRemove">show</entry>
-  <!-- EJBTHREE-1624 -->
-  <!-- 
-  
-  Just needs a new dependency for the ValueMetaData
-  http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4196761
-  
-   -->
-  <entry key="org.jboss.ejb3.test.ejbthree1624.unit.Ejb3IntoMcBeanInjectionTestCase.testLocalBusinessInterfaceInjectionIntoMcBean">show</entry>
-  <entry key="org.jboss.ejb3.test.ejbthree1624.unit.Ejb3IntoMcBeanInjectionTestCase.testRemoteBusinessInterfaceInjectionIntoMcBean">show</entry>
-  <entry key="org.jboss.ejb3.test.ejbthree1624.unit.Ejb3IntoMcBeanInjectionTestCase.testLocalHomeInterfaceInjectionIntoMcBean">show</entry>
-  <entry key="org.jboss.ejb3.test.ejbthree1624.unit.Ejb3IntoMcBeanInjectionTestCase.testRemoteHomeInterfaceInjectionIntoMcBean">show</entry>
   <!-- EJBTHREE-1637 -->
   <entry key="org.jboss.ejb3.test.jacc.unit.JaccTestCase.testSomeEntityDelete">show</entry>
   <!-- EJBTHREE-1640 -->




More information about the jboss-cvs-commits mailing list