Author: dblevins
Date: Tue Jun 26 13:52:25 2007
New Revision: 550944

URL: http://svn.apache.org/viewvc?view=rev&rev=550944
Log:
Consolodate jndi binding code

Modified:
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?view=diff&rev=550944&r1=550943&r2=550944
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
 Tue Jun 26 13:52:25 2007
@@ -92,7 +92,6 @@
 
     public static final Logger logger = Logger.getInstance("OpenEJB.startup", 
Assembler.class.getPackage().getName());
 
-
     private final CoreContainerSystem containerSystem;
     private final PersistenceClassLoaderHandler persistenceClassLoaderHandler;
     private final JndiBuilder jndiBuilder;

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java?view=diff&rev=550944&r1=550943&r2=550944
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
 Tue Jun 26 13:52:25 2007
@@ -22,6 +22,7 @@
 import javax.jms.MessageListener;
 
 import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.util.Logger;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.core.CoreDeploymentInfo;
 import org.apache.openejb.core.ivm.naming.BusinessLocalReference;
@@ -41,6 +42,8 @@
  */
 public class JndiBuilder {
 
+    public static final Logger logger = Logger.getInstance("OpenEJB.startup", 
JndiBuilder.class.getPackage().getName());
+
     private JndiNameStrategy strategy = new LegacyAddedSuffixStrategy();
     private final Context context;
 
@@ -189,12 +192,10 @@
 
                 String name = "openejb/ejb/" + strategy.getName(deployment, 
deploymentInfo.getRemoteInterface(), JndiNameStrategy.Interface.REMOTE_HOME);
                 ObjectReference ref = new 
ObjectReference(deployment.getEJBHome());
-                context.bind(name, ref);
-                bindings.add(name);
+                bind(name, ref, bindings);
 
                 name = "openejb/Deployment/" + deployment.getDeploymentID() + 
"/" + deployment.getRemoteInterface().getName();
-                context.bind(name, ref);
-                bindings.add(name);
+                bind(name, ref, bindings);
             }
         } catch (NamingException e) {
             throw new RuntimeException("Unable to bind home interface for 
deployment " + id, e);
@@ -206,12 +207,10 @@
 
                 String name = "openejb/ejb/" + strategy.getName(deployment, 
deploymentInfo.getLocalInterface(), JndiNameStrategy.Interface.LOCAL_HOME);
                 ObjectReference ref = new 
ObjectReference(deployment.getEJBLocalHome());
-                context.bind(name, ref);
-                bindings.add(name);
+                bind(name, ref, bindings);
 
                 name = "openejb/Deployment/" + deployment.getDeploymentID() + 
"/" + deployment.getLocalInterface().getName();
-                context.bind(name, ref);
-                bindings.add(name);
+                bind(name, ref, bindings);
             }
         } catch (NamingException e) {
             throw new RuntimeException("Unable to bind local interface for 
deployment " + id, e);
@@ -223,21 +222,18 @@
 
                 String name = "openejb/ejb/" + strategy.getName(deployment, 
businessLocalInterface, JndiNameStrategy.Interface.BUSINESS_LOCAL);
                 DeploymentInfo.BusinessLocalHome businessLocalHome = 
deployment.getBusinessLocalHome();
-                context.bind(name, new 
BusinessLocalReference(businessLocalHome));
-                bindings.add(name);
+                bind(name, new BusinessLocalReference(businessLocalHome), 
bindings);
 
                 for (Class interfce : deployment.getBusinessLocalInterfaces()) 
{
                     DeploymentInfo.BusinessLocalHome home = 
deployment.getBusinessLocalHome(asList(interfce));
                     BusinessLocalReference ref = new 
BusinessLocalReference(home);
 
                     name = "openejb/Deployment/" + 
deployment.getDeploymentID() + "/" + interfce.getName();
-                    context.bind(name, ref);
-                    bindings.add(name);
+                    bind(name, ref, bindings);
 
                     try {
                         name = "openejb/ejb/" + strategy.getName(deployment, 
interfce, JndiNameStrategy.Interface.BUSINESS_LOCAL);
-                        context.bind(name, ref);
-                        bindings.add(name);
+                        bind(name, ref, bindings);
                     } catch (NamingException dontCareJustYet) {
                     }
                 }
@@ -254,21 +250,18 @@
                 BusinessRemoteReference ref = new 
BusinessRemoteReference(businessRemoteHome);
 
                 String name = "openejb/ejb/" + strategy.getName(deployment, 
businessRemoteInterface, JndiNameStrategy.Interface.BUSINESS_REMOTE);
-                context.bind(name, ref);
-                bindings.add(name);
+                bind(name, ref, bindings);
 
                 for (Class interfce : 
deployment.getBusinessRemoteInterfaces()) {
                     DeploymentInfo.BusinessRemoteHome home = 
deployment.getBusinessRemoteHome(asList(interfce));
                     ref = new BusinessRemoteReference(home);
 
                     name = "openejb/Deployment/" + 
deployment.getDeploymentID() + "/" + interfce.getName();
-                    context.bind(name, ref);
-                    bindings.add(name);
+                    bind(name, ref, bindings);
 
                     try {
                         name = "openejb/ejb/" + strategy.getName(deployment, 
interfce, JndiNameStrategy.Interface.BUSINESS_REMOTE);
-                        context.bind(name, ref);
-                        bindings.add(name);
+                        bind(name, ref, bindings);
                     } catch (NamingException dontCareJustYet) {
                     }
                 }
@@ -285,11 +278,20 @@
                 String jndiName = "java:openejb/Resource/" + destinationId;
                 Reference reference = new IntraVmJndiReference(jndiName);
 
-                context.bind(name, reference);
-                bindings.add(name);
+                bind(name, reference, bindings);
             }
         } catch (NamingException e) {
             throw new RuntimeException("Unable to bind mdb destination in 
jndi.", e);
+        }
+    }
+
+
+    private void bind(String name, Reference ref, Bindings bindings) throws 
NamingException {
+        context.bind(name, ref);
+        bindings.add(name);
+        if (name.startsWith("openejb/ejb/")) {
+            name = name.replaceFirst("openejb/ejb/", "");
+            logger.info("Jndi(name=" + name+")");
         }
     }
 


Reply via email to