[jboss-cvs] JBossAS SVN: r72850 - in trunk/server/src/main/org/jboss/deployment: dependency and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Apr 29 00:46:54 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-04-29 00:46:54 -0400 (Tue, 29 Apr 2008)
New Revision: 72850

Added:
   trunk/server/src/main/org/jboss/deployment/plugin/BasicJndiBindingPolicy.java
Modified:
   trunk/server/src/main/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
   trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java
Log:
More logic to deal with ejb21 homes on ejb3x beans

Modified: trunk/server/src/main/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java	2008-04-29 04:46:27 UTC (rev 72849)
+++ trunk/server/src/main/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java	2008-04-29 04:46:54 UTC (rev 72850)
@@ -34,6 +34,7 @@
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployment.dependency.ContainerDependencyMetaData;
 import org.jboss.deployment.dependency.JndiDependencyMetaData;
+import org.jboss.deployment.plugin.BasicJndiBindingPolicy;
 import org.jboss.deployment.plugin.MappedDeploymentEndpointResolver;
 import org.jboss.deployment.spi.DeploymentEndpointResolver;
 import org.jboss.deployment.spi.EndpointInfo;
@@ -309,6 +310,31 @@
             String ejbCompID = prefix + "#" + bean.getEjbName();
             String jndiName = getJndiName(bean, bean.isMessageDriven(), unit);
             ContainerDependencyMetaData cdmd = new ContainerDependencyMetaData(jndiName, bean.getEjbName(), vfsPath);
+            cdmd.setEjb3X(ejbMetaData.isEJB3x());
+            // TODO, this is a mess that should be simply from the metadata
+            ClassLoader loader = unit.getClassLoader();
+            EjbDeploymentSummary unitSummary = getUnitSummary(unit, bean);
+            Class<? extends DefaultJndiBindingPolicy> defaultPolicyClass = null;
+            try
+            {
+               if(bean.getJBossMetaData().isEJB3x())
+               {
+                  String policyClassName = "org.jboss.ejb3.jndipolicy.impl.PackagingBasedJndiBindingPolicy";
+                  defaultPolicyClass = (Class<? extends DefaultJndiBindingPolicy>) loader.loadClass(policyClassName);
+               }
+               else if(bean.isSession())
+                  defaultPolicyClass = SessionJndiBindingPolicy.class;
+               else
+                  defaultPolicyClass = BasicJndiBindingPolicy.class;
+               DefaultJndiBindingPolicy policy = bean.createPolicy(loader, defaultPolicyClass);
+               cdmd.setJndiPolicy(policy);
+               cdmd.setUnitSummary(unitSummary);
+            }
+            catch(Exception e)
+            {
+               log.debug("Failed to create DefaultJndiBindingPolicy", e);
+            }
+
             endpointMap.put(ejbCompID, cdmd);
             // debug info for the mappings each ejb has
             ArrayList<String> mappings = new ArrayList<String>();
@@ -650,12 +676,27 @@
                target = resolveEjbInterface(ref.getRemote(), unit,
                      endpointMap, resolver);
             }
+
             if(target == null)
                unresolvedRefs.add(cdmd.getComponentID()+":"+ref);
             else
             {
                cdmd.addDependency(target);
+               // Hacking to get the correct jndi name
                String containerJndiName = target.getContainerName();
+               if(target.isEjb3X())
+               {
+                  DefaultJndiBindingPolicy jndiPolicy = target.getJndiPolicy();
+                  if(ref.getHome() != null && ref.getHome().length() > 0)
+                  {
+                     // From StatelessRemoteProxyFactory
+                     String homeJndiName = jndiPolicy.getDefaultRemoteHomeJndiName(target.getUnitSummary());
+                     String remoteBusinessJndiName = jndiPolicy.getDefaultRemoteJndiName(target.getUnitSummary());
+                     if(homeJndiName.equals(remoteBusinessJndiName) == false)
+                        containerJndiName = homeJndiName;
+                  }
+               }  
+
                if(containerJndiName != null)
                   ref.setResolvedJndiName(containerJndiName);
             }

Modified: trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java	2008-04-29 04:46:27 UTC (rev 72849)
+++ trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java	2008-04-29 04:46:54 UTC (rev 72850)
@@ -25,6 +25,8 @@
 import java.util.Set;
 
 import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
 import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
 import org.jboss.util.JBossObject;
 import org.jboss.util.JBossStringBuilder;
@@ -60,6 +62,11 @@
    private Set<JndiDependencyMetaData> jndiDepends = new HashSet<JndiDependencyMetaData>();
    /** The jndi names for other container this container depends on */
    private Set<String> jndiAliasDepends = new HashSet<String>();
+   /** The jndi binding policy associated with the bean deployment */
+   private DefaultJndiBindingPolicy jndiPolicy;
+   /** Is this an ejb3 endpoint */
+   private boolean isEjb3X;
+   private EjbDeploymentSummary unitSummary;
 
    /**
     * 
@@ -103,6 +110,33 @@
    }
 
 
+   public DefaultJndiBindingPolicy getJndiPolicy()
+   {
+      return jndiPolicy;
+   }
+   public void setJndiPolicy(DefaultJndiBindingPolicy jndiPolicy)
+   {
+      this.jndiPolicy = jndiPolicy;
+   }
+
+   public EjbDeploymentSummary getUnitSummary()
+   {
+      return unitSummary;
+   }
+   public void setUnitSummary(EjbDeploymentSummary unitSummary)
+   {
+      this.unitSummary = unitSummary;
+   }
+
+   public boolean isEjb3X()
+   {
+      return isEjb3X;
+   }
+   public void setEjb3X(boolean isEjb3X)
+   {
+      this.isEjb3X = isEjb3X;
+   }
+
    public void addDependency(ContainerDependencyMetaData endpointCDMD)
    {
       jndiAliasDepends.add(endpointCDMD.getContainerName());

Added: trunk/server/src/main/org/jboss/deployment/plugin/BasicJndiBindingPolicy.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/plugin/BasicJndiBindingPolicy.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/deployment/plugin/BasicJndiBindingPolicy.java	2008-04-29 04:46:54 UTC (rev 72850)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.deployment.plugin;
+
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
+
+/**
+ * Basic DefaultJndiBindingPolicy impl based on ejb/mapped name
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class BasicJndiBindingPolicy
+   implements DefaultJndiBindingPolicy
+{
+
+   public String getDefaultLocalHomeJndiName(EjbDeploymentSummary summary)
+   {
+      return summary.getEjbName() + "LocalHome";
+   }
+
+   public String getDefaultLocalJndiName(EjbDeploymentSummary summary)
+   {
+      return summary.getEjbName() + "Local";
+   }
+
+   public String getDefaultRemoteHomeJndiName(EjbDeploymentSummary summary)
+   {
+      return summary.getEjbName() + "Home";
+   }
+
+   public String getDefaultRemoteJndiName(EjbDeploymentSummary summary)
+   {
+      return summary.getEjbName() + "Remote";
+   }
+
+   public String getJndiName(EjbDeploymentSummary summary)
+   {
+      String name = summary.getBeanMD().getMappedName();
+      if(name == null)
+         name = summary.getEjbName();
+      return name;
+   }
+}




More information about the jboss-cvs-commits mailing list