[jboss-cvs] JBossAS SVN: r67842 - trunk/ejb3/src/main/org/jboss/ejb3/deployers.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Dec 4 02:46:48 EST 2007


Author: scott.stark at jboss.org
Date: 2007-12-04 02:46:48 -0500 (Tue, 04 Dec 2007)
New Revision: 67842

Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
Log:
JBCTS-720, create a link from the deployment based jndi name to the metadata if linkDeploymentJndiName is true.

Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java	2007-12-04 06:07:28 UTC (rev 67841)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java	2007-12-04 07:46:48 UTC (rev 67842)
@@ -57,6 +57,8 @@
 {
    private Kernel kernel;
    private MBeanServer server;
+   /** A flag indicating if a deployment based jndi should be linked to the JBossClientMetaData.jndiName */
+   private boolean linkDeploymentJndiName = true;
 
    /**
     * Create a new Ejb3ClientDeployer.
@@ -67,12 +69,27 @@
       setOutput(ClientENCInjectionContainer.class);
    }
 
+   public boolean isLinkDeploymentJndiName()
+   {
+      return linkDeploymentJndiName;
+   }
+
+   public void setLinkDeploymentJndiName(boolean linkDeploymentJndiName)
+   {
+      this.linkDeploymentJndiName = linkDeploymentJndiName;
+   }
+
    @Override
    public void deploy(VFSDeploymentUnit unit, JBossClientMetaData metaData) throws DeploymentException
    {
       log.debug("deploy " + unit.getName());
       
-      String appClientName = getJndiName(unit, metaData);
+      String appClientName = getJndiName(metaData);
+      String deploymentClientName = null;
+      if(appClientName == null)
+         appClientName = getDeploymentJndiName(unit);
+      else if(linkDeploymentJndiName)
+         deploymentClientName = getDeploymentJndiName(unit);
 
       try
       {
@@ -80,6 +97,10 @@
          InitialContext iniCtx = InitialContextFactory.getInitialContext();
          Context encCtx = Util.createSubcontext(iniCtx, appClientName);
          log.debug("Creating client ENC binding under: " + appClientName);
+         if(deploymentClientName != null && deploymentClientName.equals(appClientName) == false)
+         {
+            Util.createLinkRef(iniCtx, deploymentClientName, appClientName);
+         }
 
          // Notify the client launcher of extra class path entries in an EAR (See EE 8.2)
          encCtx.bind("classPathEntries", getClassPathEntries(unit));
@@ -128,12 +149,14 @@
     * @param dd
     * @return   a good JNDI name
     */
-   private String getJndiName(DeploymentUnit unit, JBossClientMetaData dd)
+   private String getJndiName(JBossClientMetaData dd)
    {
       String jndiName = dd.getJndiName();
-      if(jndiName != null)
-         return jndiName;
-
+      return jndiName;
+   }
+   private String getDeploymentJndiName(DeploymentUnit unit)
+   {
+      String jndiName;
       String shortName = unit.getSimpleName();
       if(shortName.endsWith(".jar/"))
          jndiName = shortName.substring(0, shortName.length() - 5);
@@ -216,12 +239,20 @@
       if(container != null)
          getKernelAbstraction().uninstall(container.getObjectName().getCanonicalName());
 
-      String jndiName = getJndiName(unit, metaData);
-      log.debug("Removing client ENC from: " + jndiName);
+      String appClientName = getJndiName(metaData);
+      String deploymentClientName = null;
+      if(appClientName == null)
+         appClientName = getDeploymentJndiName(unit);
+      else if(linkDeploymentJndiName)
+         deploymentClientName = getDeploymentJndiName(unit);
+
+      log.debug("Removing client ENC from: " + appClientName);
       try
       {
          InitialContext iniCtx = InitialContextFactory.getInitialContext();
-         Util.unbind(iniCtx, jndiName);
+         Util.unbind(iniCtx, appClientName);
+         if(deploymentClientName != null && deploymentClientName.equals(appClientName) == false)
+            Util.removeLinkRef(deploymentClientName);
       }
       catch(NameNotFoundException e)
       {




More information about the jboss-cvs-commits mailing list