Index: component-matrix/pom.xml
===================================================================
--- component-matrix/pom.xml (revision 75838)
+++ component-matrix/pom.xml (working copy)
@@ -39,7 +39,7 @@
1.4.1.CR1
2.1.1.CR4
2.0.0.CR13
- 0.1.7
+ 0.1.8
2.0.0.Beta15
2.0.0.Beta20
2.0.0.Beta12
@@ -48,7 +48,7 @@
5.0.0.Beta5
2.0.0.CR11
2.0.0.Beta15
- 1.0.0.Beta28
+ 1.0.0.Beta29
2.0.0.Beta16
2.0.2.CR6
1.3.4-jboss-update1
Index: server/src/main/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
===================================================================
--- server/src/main/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java (revision 75838)
+++ server/src/main/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java (working copy)
@@ -34,7 +34,6 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployment.dependency.ContainerDependencyMetaData;
import org.jboss.deployment.dependency.JndiDependencyMetaData;
-import org.jboss.deployment.plugin.LegacyEjb3JndiPolicy;
import org.jboss.deployment.plugin.MappedDeploymentEndpointResolver;
import org.jboss.deployment.spi.DeploymentEndpointResolver;
import org.jboss.deployment.spi.EndpointInfo;
@@ -47,8 +46,6 @@
import org.jboss.metadata.ejb.jboss.JBossGenericBeanMetaData;
import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.metadata.ejb.jboss.jndipolicy.plugins.SessionJndiBindingPolicy;
-import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DeploymentSummary;
import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces;
@@ -313,17 +310,7 @@
{
if(ejbMetaData.getDeploymentSummary() == null)
{
- DeploymentSummary deploymentSummary = new DeploymentSummary();
- deploymentSummary.setDeploymentName(unit.getSimpleName());
- if(unit.getTopLevel() != unit)
- {
- String deploymentScopeBaseName = unit.getTopLevel().getSimpleName();
- int dot = deploymentScopeBaseName.lastIndexOf('.');
- if(dot > 0)
- deploymentScopeBaseName = deploymentScopeBaseName.substring(0, dot);
- deploymentSummary.setDeploymentScopeBaseName(deploymentScopeBaseName);
- }
- deploymentSummary.setLoader(unit.getClassLoader());
+ DeploymentSummary deploymentSummary = getDeploymentSummary(unit);
ejbMetaData.setDeploymentSummary(deploymentSummary);
}
beans = ejbMetaData.getEnterpriseBeans();
@@ -337,13 +324,13 @@
{
// The unique id for this ejb in the deployment
String ejbCompID = prefix + "#" + bean.getEjbName();
- LegacyEjb3JndiPolicy policy = new LegacyEjb3JndiPolicy();
- String jndiName = bean.determineResolvedJndiName(null, policy);
+ //LegacyEjb3JndiPolicy policy = new LegacyEjb3JndiPolicy();
+ String jndiName = bean.determineJndiName();
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);
+ //ClassLoader loader = unit.getClassLoader();
+ EjbDeploymentSummary unitSummary = getEjbDeploymentSummary(unit, bean);
cdmd.setUnitSummary(unitSummary);
endpointMap.put(ejbCompID, cdmd);
@@ -370,7 +357,7 @@
// home
if(sbean.getHome() != null && sbean.getHome().length() > 0)
{
- cdmd.addJndiName(sbean.determineResolvedJndiName(KnownInterfaces.HOME, policy));
+ cdmd.addJndiName(sbean.determineResolvedJndiName(KnownInterfaces.HOME));
// Add ejb/vfsPath@iface
String home = sbean.getHome();
String ifacePath = prefix + "@" + home;
@@ -431,7 +418,7 @@
// local-home
if(sbean.getLocalHome() != null && sbean.getLocalHome().length() > 0)
{
- cdmd.addJndiName(sbean.determineResolvedJndiName(KnownInterfaces.LOCAL_HOME, policy));
+ cdmd.addJndiName(sbean.determineResolvedJndiName(KnownInterfaces.LOCAL_HOME));
// Add ejb/vfsPath@iface
String local = sbean.getLocalHome();
String ifacePath = prefix + "@" + local;
@@ -493,12 +480,13 @@
BusinessLocalsMetaData locals = sbean.getBusinessLocals();
if(locals != null && locals.size() > 0)
{
- String localBaseJndiName = sbean.determineResolvedJndiName(KnownInterfaces.LOCAL, policy);
+ String localBaseJndiName = sbean.determineResolvedJndiName(KnownInterfaces.LOCAL);
cdmd.addJndiName(localBaseJndiName);
for(String local : locals)
{
// Add a targeted jndi name
- cdmd.addJndiName(localBaseJndiName + "-" + local);
+ String localJndiName = sbean.determineResolvedJndiName(local);
+ cdmd.addJndiName(localJndiName);
// Add ejb/vfsPath@iface
String ifacePath = prefix + "@" + local;
if(endpointAlternateMap.containsKey(ifacePath))
@@ -529,12 +517,13 @@
BusinessRemotesMetaData remotes = sbean.getBusinessRemotes();
if(remotes != null && remotes.size() > 0)
{
- String remoteBaseJndiName = sbean.determineResolvedJndiName(KnownInterfaces.REMOTE, policy);
+ String remoteBaseJndiName = sbean.determineResolvedJndiName(KnownInterfaces.REMOTE);
cdmd.addJndiName(remoteBaseJndiName);
for(String remote : remotes)
{
// Add a targeted jndi name
- cdmd.addJndiName(remoteBaseJndiName + "-" + remote);
+ String remoteJndiName = sbean.determineResolvedJndiName(remote);
+ cdmd.addJndiName(remoteJndiName);
// Add ejb/vfsPath/iface
String ifacePath = prefix + "@" + remote;
if(endpointAlternateMap.containsKey(ifacePath))
@@ -569,7 +558,7 @@
// home
if(ebean.getHome() != null && ebean.getHome().length() > 0)
{
- cdmd.addJndiName(ebean.determineResolvedJndiName(KnownInterfaces.HOME, policy));
+ cdmd.addJndiName(ebean.determineResolvedJndiName(KnownInterfaces.HOME));
// Add ejb/vfsPath@iface
String home = ebean.getHome();
String ifacePath = prefix + "@" + home;
@@ -630,7 +619,7 @@
// local-home
if(ebean.getLocalHome() != null && ebean.getLocalHome().length() > 0)
{
- cdmd.addJndiName(ebean.determineResolvedJndiName(KnownInterfaces.LOCAL_HOME, policy));
+ cdmd.addJndiName(ebean.determineResolvedJndiName(KnownInterfaces.LOCAL_HOME));
// Add ejb/vfsPath@iface
String local = ebean.getLocalHome();
String ifacePath = prefix + "@" + local;
@@ -786,8 +775,8 @@
// Determine the jndi name for the reference interface
String ifaceName = iface != null ? iface.getName() : null;
- LegacyEjb3JndiPolicy policy = new LegacyEjb3JndiPolicy();
- String containerJndiName = target.getBeanMetaData().determineResolvedJndiName(ifaceName, policy);
+ //LegacyEjb3JndiPolicy policy = new LegacyEjb3JndiPolicy();
+ String containerJndiName = target.getBeanMetaData().determineResolvedJndiName(ifaceName);
if(containerJndiName != null)
ref.setResolvedJndiName(containerJndiName);
}
@@ -956,8 +945,8 @@
cdmd.addDependency(target);
// Determine the jndi name for the reference interface
String iface = getInterface(ref);
- LegacyEjb3JndiPolicy policy = new LegacyEjb3JndiPolicy();
- String containerJndiName = target.getBeanMetaData().determineResolvedJndiName(iface, policy);
+ //LegacyEjb3JndiPolicy policy = new LegacyEjb3JndiPolicy();
+ String containerJndiName = target.getBeanMetaData().determineResolvedJndiName(iface);
if(containerJndiName != null)
ref.setResolvedJndiName(containerJndiName);
}
@@ -1074,102 +1063,102 @@
getAllAttachments(child, type, attachments);
}
- private static String getJndiName(JBossEnterpriseBeanMetaData beanMD, boolean isLocal,
- DeploymentUnit unit)
+ /*
+ * Unused
+ */
+// private static String getJndiName(JBossEnterpriseBeanMetaData beanMD, boolean isLocal,
+// DeploymentUnit unit)
+// {
+// String jndiName = beanMD.getMappedName();
+// if (isLocal && jndiName == null)
+// {
+// // Validate that there is a local home associated with this bean
+// if(jndiName == null)
+// jndiName = beanMD.determineLocalJndiName();
+// if (jndiName == null)
+// {
+// log.warn("LocalHome jndi name requested for: '" +beanMD.getEjbName() + "' but there is no LocalHome class");
+// }
+// }
+// else if(jndiName == null)
+// {
+// // TODO, this is a mess that should be simply from the metadata
+// ClassLoader loader = unit.getClassLoader();
+// EjbDeploymentSummary unitSummary = getUnitSummary(unit, beanMD);
+// Class extends DefaultJndiBindingPolicy> defaultPolicyClass = null;
+// try
+// {
+// if(beanMD.getJBossMetaData().isEJB3x())
+// {
+// String policyClassName = "org.jboss.ejb3.jndipolicy.impl.PackagingBasedJndiBindingPolicy";
+// defaultPolicyClass = (Class extends DefaultJndiBindingPolicy>) loader.loadClass(policyClassName);
+// }
+// else if(beanMD.isSession())
+// defaultPolicyClass = SessionJndiBindingPolicy.class;
+// DefaultJndiBindingPolicy policy = beanMD.createPolicy(loader, defaultPolicyClass);
+// // Run through the options for which jndi name
+// if(beanMD.isSession())
+// {
+// JBossSessionBeanMetaData sbeanMD = (JBossSessionBeanMetaData) beanMD;
+// jndiName = sbeanMD.getJndiName();
+// if(jndiName == null)
+// {
+// if(sbeanMD.getBusinessRemotes() != null && sbeanMD.getBusinessRemotes().size() > 0)
+// jndiName = policy.getDefaultRemoteJndiName(unitSummary);
+// else if(sbeanMD.getHome() != null)
+// jndiName = policy.getDefaultRemoteHomeJndiName(unitSummary);
+// else if(sbeanMD.getRemote() != null)
+// jndiName = policy.getDefaultRemoteJndiName(unitSummary);
+// else if(sbeanMD.getLocalHome() != null)
+// jndiName = policy.getDefaultLocalHomeJndiName(unitSummary);
+// else if(sbeanMD.getLocal() != null)
+// jndiName = policy.getDefaultLocalJndiName(unitSummary);
+// else
+// jndiName = policy.getJndiName(unitSummary);
+// }
+// }
+// else if(policy != null)
+// {
+// jndiName = policy.getJndiName(unitSummary);
+// }
+// else if(beanMD.isEntity())
+// {
+// JBossEntityBeanMetaData ebeanMD = (JBossEntityBeanMetaData) beanMD;
+// jndiName = ebeanMD.determineJndiName();
+// }
+// }
+// catch(Exception e)
+// {
+// log.warn("Failed to obtain jndi name for bean: "+beanMD.getEjbName(), e);
+// jndiName = beanMD.getEjbName();
+// }
+// }
+// return jndiName;
+// }
+
+ private static EjbDeploymentSummary getEjbDeploymentSummary(DeploymentUnit unit, JBossEnterpriseBeanMetaData beanMD)
{
- String jndiName = beanMD.getMappedName();
- if (isLocal && jndiName == null)
- {
- // Validate that there is a local home associated with this bean
- if(jndiName == null)
- jndiName = beanMD.determineLocalJndiName();
- if (jndiName == null)
- {
- log.warn("LocalHome jndi name requested for: '" +beanMD.getEjbName() + "' but there is no LocalHome class");
- }
- }
- else if(jndiName == null)
- {
- // TODO, this is a mess that should be simply from the metadata
- ClassLoader loader = unit.getClassLoader();
- EjbDeploymentSummary unitSummary = getUnitSummary(unit, beanMD);
- Class extends DefaultJndiBindingPolicy> defaultPolicyClass = null;
- try
- {
- if(beanMD.getJBossMetaData().isEJB3x())
- {
- String policyClassName = "org.jboss.ejb3.jndipolicy.impl.PackagingBasedJndiBindingPolicy";
- defaultPolicyClass = (Class extends DefaultJndiBindingPolicy>) loader.loadClass(policyClassName);
- }
- else if(beanMD.isSession())
- defaultPolicyClass = SessionJndiBindingPolicy.class;
- DefaultJndiBindingPolicy policy = beanMD.createPolicy(loader, defaultPolicyClass);
- // Run through the options for which jndi name
- if(beanMD.isSession())
- {
- JBossSessionBeanMetaData sbeanMD = (JBossSessionBeanMetaData) beanMD;
- jndiName = sbeanMD.getJndiName();
- if(jndiName == null)
- {
- if(sbeanMD.getBusinessRemotes() != null && sbeanMD.getBusinessRemotes().size() > 0)
- jndiName = policy.getDefaultRemoteJndiName(unitSummary);
- else if(sbeanMD.getHome() != null)
- jndiName = policy.getDefaultRemoteHomeJndiName(unitSummary);
- else if(sbeanMD.getRemote() != null)
- jndiName = policy.getDefaultRemoteJndiName(unitSummary);
- else if(sbeanMD.getLocalHome() != null)
- jndiName = policy.getDefaultLocalHomeJndiName(unitSummary);
- else if(sbeanMD.getLocal() != null)
- jndiName = policy.getDefaultLocalJndiName(unitSummary);
- else
- jndiName = policy.getJndiName(unitSummary);
- }
- }
- else if(policy != null)
- {
- jndiName = policy.getJndiName(unitSummary);
- }
- else if(beanMD.isEntity())
- {
- JBossEntityBeanMetaData ebeanMD = (JBossEntityBeanMetaData) beanMD;
- jndiName = ebeanMD.determineJndiName();
- }
- }
- catch(Exception e)
- {
- log.warn("Failed to obtain jndi name for bean: "+beanMD.getEjbName(), e);
- jndiName = beanMD.getEjbName();
- }
- }
- return jndiName;
+ DeploymentSummary dSummary = getDeploymentSummary(unit);
+
+ EjbDeploymentSummary summary = new EjbDeploymentSummary(beanMD,dSummary);
+ return summary;
}
-
- private static EjbDeploymentSummary getUnitSummary(DeploymentUnit unit, JBossEnterpriseBeanMetaData beanMD)
+
+ private static DeploymentSummary getDeploymentSummary(DeploymentUnit unit)
{
- ClassLoader loader = unit.getClassLoader();
- EjbDeploymentSummary summary = new EjbDeploymentSummary();
- summary.setBeanMD(beanMD);
- summary.setBeanClassName(beanMD.getEjbClass());
- summary.setDeploymentName(unit.getSimpleName());
- // This name cannot contain any .suffix because of the ejb3 DeploymentScope behavior
+ DeploymentSummary dSummary = new DeploymentSummary();
+ dSummary.setDeploymentName(unit.getSimpleName());
String baseName = unit.getTopLevel().getSimpleName();
int dot = baseName.lastIndexOf('.');
if(dot > 0)
{
baseName = baseName.substring(0, dot);
}
- summary.setDeploymentScopeBaseName(baseName);
- summary.setEjbName(beanMD.getEjbName());
- summary.setLoader(loader);
- summary.setLocal(beanMD.isMessageDriven());
- if(beanMD instanceof JBossSessionBeanMetaData)
- {
- JBossSessionBeanMetaData sbeanMD = (JBossSessionBeanMetaData) beanMD;
- summary.setStateful(sbeanMD.isStateful());
- }
- summary.setService(beanMD.isService());
- return summary;
+ dSummary.setDeploymentScopeBaseName(baseName);
+
+ return dSummary;
}
+
private void dump(DeploymentUnit unit)
{
DeploymentUnit top = unit.getTopLevel();
Index: server/src/main/org/jboss/ejb/deployers/EjbMetadataJndiPolicyDecoratorDeployer.java
===================================================================
--- server/src/main/org/jboss/ejb/deployers/EjbMetadataJndiPolicyDecoratorDeployer.java (revision 0)
+++ server/src/main/org/jboss/ejb/deployers/EjbMetadataJndiPolicyDecoratorDeployer.java (revision 0)
@@ -0,0 +1,259 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEntityBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.plugins.BasicJndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.plugins.JBossSessionPolicyDecorator;
+import org.jboss.metadata.ejb.jboss.jndipolicy.plugins.JbossEntityPolicyDecorator;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
+
+/**
+ * EjbMetadataJndiPolicyDecoratorDeployer
+ *
+ * Decorates merged EJB Metadata with the ability to resolve
+ * JNDI targets as dictated by an optionally-specified
+ * DefaultJndiBindingPolicy
+ *
+ * @author ALR
+ * @version $Revision: $
+ */
+public class EjbMetadataJndiPolicyDecoratorDeployer extends AbstractDeployer
+{
+
+ // ------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(EjbMetadataJndiPolicyDecoratorDeployer.class);
+
+ /**
+ * Deployer Output flag signaling that this deployer has been run
+ */
+ public static final String EJB_DECORATED_FLAG = EjbMetadataJndiPolicyDecoratorDeployer.class.getSimpleName();
+
+ // ------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /**
+ * Constructor; sets deployment stage and requisite input/output chain
+ */
+ public EjbMetadataJndiPolicyDecoratorDeployer()
+ {
+ // Set the Stage to post-CL
+ this.setStage(DeploymentStages.POST_CLASSLOADER);
+
+ // Input is the JBossMetaData post-merge
+ this.addInput(MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME);
+
+ // Output is a flag upon which other deployers may rely
+ this.addOutput(EjbMetadataJndiPolicyDecoratorDeployer.EJB_DECORATED_FLAG);
+ }
+
+ // ------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.deployers.spi.deployer.Deployer#deploy(org.jboss.deployers.structure.spi.DeploymentUnit)
+ */
+ public void deploy(DeploymentUnit du) throws DeploymentException
+ {
+ // Obtain the Merged Metadata
+ JBossMetaData md = du.getAttachment(MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME, JBossMetaData.class);
+
+ // If metadata's not present as an attachment, return
+ if (md == null)
+ {
+ return;
+ }
+
+ // If this is not an EJB3 Deployment, return
+ if (!md.isEJB3x())
+ {
+ return;
+ }
+
+ // Initialize Map of beans to replace
+ Map beansToReplace = new HashMap();
+
+ // Obtain defined JNDI Binding Policy
+ String mdJndiPolicyName = md.getJndiBindingPolicy();
+ if (mdJndiPolicyName != null && mdJndiPolicyName.trim().length() == 0)
+ {
+ mdJndiPolicyName = null;
+ }
+ if (mdJndiPolicyName != null)
+ {
+ log.debug(JBossMetaData.class.getSimpleName() + " " + md + " has defined "
+ + DefaultJndiBindingPolicy.class.getSimpleName() + " \"" + mdJndiPolicyName + "\"");
+ }
+
+ // For each of the Enterprise Beans
+ JBossEnterpriseBeansMetaData beans = md.getEnterpriseBeans();
+ for (JBossEnterpriseBeanMetaData bean : beans)
+ {
+ // Initialize a decorated instance
+ JBossEnterpriseBeanMetaData decoratedBean = null;
+
+ // Obtain a Policy
+ DefaultJndiBindingPolicy policy = this.getJndiBindingPolicy(bean, mdJndiPolicyName, du.getClassLoader());
+
+ // If this is a Session or Service Bean
+ if (bean.isSession() || bean.isService())
+ {
+ // Cast
+ assert bean instanceof JBossSessionBeanMetaData : JBossEnterpriseBeanMetaData.class.getSimpleName()
+ + " representing as Session Bean is not castable to " + JBossSessionBeanMetaData.class.getName();
+ JBossSessionBeanMetaData sessionBean = (JBossSessionBeanMetaData) bean;
+
+ // Create a Session JNDI Policy Decorated Bean
+ decoratedBean = new JBossSessionPolicyDecorator(sessionBean, policy);
+ }
+
+ // If this is an Entity Bean
+ if (bean.isEntity())
+ {
+ // Cast
+ assert bean instanceof JBossEntityBeanMetaData : JBossEnterpriseBeanMetaData.class.getSimpleName()
+ + " representing as Entity Bean is not castable to " + JBossEntityBeanMetaData.class.getName();
+ JBossEntityBeanMetaData entityBean = (JBossEntityBeanMetaData) bean;
+
+ // Create a Entity JNDI Policy Decorated Bean
+ decoratedBean = new JbossEntityPolicyDecorator(entityBean, policy);
+ }
+
+ // If we've decorated this bean, add to the map of beans to replace
+ if (decoratedBean != null)
+ {
+ beansToReplace.put(bean, decoratedBean);
+ }
+ }
+
+ // Replace with decorated beans
+ for (JBossEnterpriseBeanMetaData beanToReplace : beansToReplace.keySet())
+ {
+ JBossEnterpriseBeanMetaData beanToReplaceWith = beansToReplace.get(beanToReplace);
+ boolean removed = beans.remove(beanToReplace);
+ assert removed : "Remove operation of " + beanToReplace + " from " + beans + " resulted in no action";
+ beans.add(beanToReplaceWith);
+ log.debug("Replaced " + beanToReplace.getEjbName() + " with decorated instance fit with "
+ + DefaultJndiBindingPolicy.class.getSimpleName());
+ }
+
+ // Output
+ du.addAttachment(EjbMetadataJndiPolicyDecoratorDeployer.EJB_DECORATED_FLAG, true, Boolean.class);
+ }
+
+ // ------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the JNDI Binding Policy instance to use for the specified metadata,
+ * defaulting to a BasicJndiBindingPolicy if none is explicitly specified either in
+ * the metadata itself or in its parent deployable unit
+ *
+ * @param md The Bean Metadata
+ * @param deployableUnitDefaultJndiPolicyClassName The (optional) JNDI Policy declared
+ * by the deployable unit (JBossMetaData)
+ * @param cl The Deployable Unit's ClassLoader
+ */
+ protected DefaultJndiBindingPolicy getJndiBindingPolicy(JBossEnterpriseBeanMetaData md,
+ String deployableUnitDefaultJndiPolicyClassName, ClassLoader cl)
+ {
+ // Initialize a JNDI Binding Policy
+ DefaultJndiBindingPolicy policy = null;
+
+ // Obtain JNDI Policy Name defined at the EJB level
+ String beanJndiPolicyName = md.getJndiBindingPolicy();
+ if (beanJndiPolicyName != null && beanJndiPolicyName.trim().length() == 0)
+ {
+ beanJndiPolicyName = null;
+ }
+ if (beanJndiPolicyName != null)
+ {
+ log.debug("Session EJB " + md.getEjbName() + " has defined " + DefaultJndiBindingPolicy.class.getSimpleName()
+ + " of \"" + beanJndiPolicyName);
+ }
+
+ // Use JNDI Policy defined by MD, then override at bean level
+ String jndiPolicyName = deployableUnitDefaultJndiPolicyClassName != null
+ ? deployableUnitDefaultJndiPolicyClassName
+ : beanJndiPolicyName;
+
+ // If JNDI Policy is defined
+ if (jndiPolicyName != null)
+ {
+ // Load the configured JNDI Binding Policy
+ Class> policyClass = null;
+ try
+ {
+ policyClass = Class.forName(jndiPolicyName, true, cl);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new RuntimeException("Could not find defined JNDI Binding Policy Class: " + jndiPolicyName, cnfe);
+ }
+
+ // Instanciate the configured JNDI Binding Policy
+ try
+ {
+ policy = (DefaultJndiBindingPolicy) policyClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error in instanciating defined JNDI Binding Policy Class: " + jndiPolicyName, t);
+ }
+
+ // Log
+ log.debug("Using " + DefaultJndiBindingPolicy.class.getSimpleName() + " \"" + policy.getClass().getName()
+ + "\" for Session Bean " + md.getEjbName());
+ }
+
+ // If no JNDI Binding Policy was defined
+ if (policy == null)
+ {
+ // Default to BasicJndiBindingPolicy
+ policy = new BasicJndiBindingPolicy();
+ log.warn("Defaulting to " + DefaultJndiBindingPolicy.class.getSimpleName() + " of \""
+ + BasicJndiBindingPolicy.class.getName() + "\" for Session Bean " + md.getEjbName());
+ }
+
+ // Return
+ return policy;
+ }
+
+}
Index: server/src/etc/deployers/ejb-deployer-beans.xml
===================================================================
--- server/src/etc/deployers/ejb-deployer-beans.xml (revision 75838)
+++ server/src/etc/deployers/ejb-deployer-beans.xml (working copy)
@@ -76,4 +76,5 @@
+
Index: testsuite/src/main/org/jboss/test/ejb3/test/SimpleSessionUnitTestCase.java
===================================================================
--- testsuite/src/main/org/jboss/test/ejb3/test/SimpleSessionUnitTestCase.java (revision 75838)
+++ testsuite/src/main/org/jboss/test/ejb3/test/SimpleSessionUnitTestCase.java (working copy)
@@ -50,9 +50,7 @@
throws Exception
{
InitialContext ctx = getInitialContext();
- // TODO after proxy factory updates, this should be using the mappedName
- // String jndiName = "ejb3/basic/SimpleSessionBean/remote"
- String jndiName = "SimpleSessionBean/remote";
+ String jndiName = "ejb3/basic/SimpleSessionBean";
Object ref = ctx.lookup(jndiName);
SimpleSession test = (SimpleSession) ref;
test.ping();