// Obtain the Deployment Summary
DeploymentSummary dsummary = getJBossMetaData().getDeploymentSummary();
// Initialize the Default JNDI Binding Policy
DefaultJndiBindingPolicy policy = null;
try
{
// Initialize a CL
ClassLoader loader = null;
// Fall back on TCL if there's no DeploymentSummary
if (loader == null)
{
loader = Thread.currentThread().getContextClassLoader();
}
// Create Policy, falling back on the default policy if specified
policy = this.createPolicy(loader, defaultPolicy == null ? null : defaultPolicy.getClass());
}
catch (Exception e)
{
throw new RuntimeException("Error in creating " + DefaultJndiBindingPolicy.class.getSimpleName(),e);
}
// If there's still no policy
if (policy == null)
{
// Use the metadata default binding policy
policy = new BasicJndiBindingPolicy();
}
if(dsummary==null)
{
dsummary = new DeploymentSummary();
}
// Derive the summary info from this metadata and deployment summary
EjbDeploymentSummary ejbSummary = new EjbDeploymentSummary(this, dsummary);
KnownInterfaceType ifaceType = KnownInterfaces.classifyInterface(iface);
// Need to compare iface against the metadata local-home/home & business locals/remotes
if (this.isSession() && ifaceType == KnownInterfaceType.UNKNOWN)
{
JBossSessionBeanMetaData sbeanMD = (JBossSessionBeanMetaData) this;
// Figure out the interface type from the metadata
if (sbeanMD.getLocalHome() != null && sbeanMD.getLocalHome().equals(iface))
ifaceType = KnownInterfaceType.LOCAL_HOME;
else if (sbeanMD.getHome() != null && sbeanMD.getHome().equals(iface))
ifaceType = KnownInterfaceType.REMOTE_HOME;
else
{
// Check business locals
BusinessLocalsMetaData locals = sbeanMD.getBusinessLocals();
if (locals != null)
{
for (String local : locals)
{
if (local.equals(iface))
{
ifaceType = KnownInterfaceType.BUSINESS_LOCAL;
break;
}
}
}
if (ifaceType == KnownInterfaceType.UNKNOWN)
{
// Check business remotes
BusinessRemotesMetaData remotes = sbeanMD.getBusinessRemotes();
if (remotes != null)
{
for (String remote : remotes)
{
if (remote.equals(iface))
{
ifaceType = KnownInterfaceType.BUSINESS_REMOTE;
break;
}
}
}
}
}
}
else if (this.isEntity() && ifaceType == KnownInterfaceType.UNKNOWN)
{
JBossEntityBeanMetaData ebeanMD = (JBossEntityBeanMetaData) this;
// Figure out the interface type from the metadata
if (ebeanMD.getLocalHome() != null && ebeanMD.getLocalHome().equals(iface))
ifaceType = KnownInterfaceType.LOCAL_HOME;
else if (ebeanMD.getHome() != null && ebeanMD.getHome().equals(iface))
ifaceType = KnownInterfaceType.REMOTE_HOME;
}
// Have the policy generate the actual name
String resolvedJndiName = policy.getJndiName(ejbSummary, iface, ifaceType);
return resolvedJndiName;
}