{
String homeType = smd.getHome();
RefAddr refAddrHomeInterface = new StringRefAddr(
ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_REMOTE, homeType);
RefAddr refAddrRemoting = this.createRemotingRefAddr(smd);
Reference homeRef = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
+ homeType, remoteProxyFactoryKey, containerName);
homeRef.add(refAddrHomeInterface);
homeRef.add(refAddrRemoting);
String homeAddress = smd.getHomeJndiName();
assert homeAddress != null && !homeAddress.equals("") : "JNDI Address for Remote Home must be defined";
log.debug("Remote Home View for EJB " + smd.getEjbName() + " to be bound into JNDI at \"" + homeAddress
+ "\"");
bindingSet.addHomeRemoteBinding(new JndiReferenceBinding(homeAddress, homeRef));
}
// Add a Reference Address for the Remoting URL
refAddrsForDefaultRemote.add(this.createRemotingRefAddr(smd));
/*
* Bind ObjectFactory for default remote businesses (and home if bound together)
*/
// Get Classname to set for Reference
String defaultRemoteClassName = this.getHumanReadableListOfInterfacesInRefAddrs(refAddrsForDefaultRemote);
// Create a Reference
Reference defaultRemoteRef = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
+ defaultRemoteClassName, remoteProxyFactoryKey, containerName);
// Add all Reference Addresses for Default Remote Reference
for (RefAddr refAddr : refAddrsForDefaultRemote)
{
log.debug("Adding " + RefAddr.class.getSimpleName() + " to Default Remote "
+ Reference.class.getSimpleName() + ": Type \"" + refAddr.getType() + "\", Content \""
+ refAddr.getContent() + "\"");
defaultRemoteRef.add(refAddr);
}
// Bind the Default Remote Reference to JNDI
String defaultRemoteAddress = smd.getJndiName();
log.debug("Default Remote Business View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
+ defaultRemoteAddress + "\"");
bindingSet.addDefaultRemoteBinding(new JndiReferenceBinding(defaultRemoteAddress, defaultRemoteRef));
// Bind ObjectFactory specific to each Remote Business Interface
if (businessRemotes != null)
{
for (String businessRemote : businessRemotes)
{
RefAddr refAddrBusinessInterface = new StringRefAddr(
ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE, businessRemote);
RefAddr refAddrRemoting = this.createRemotingRefAddr(smd);
Reference ref = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
+ businessRemote, remoteProxyFactoryKey, containerName);
ref.add(refAddrBusinessInterface);
ref.add(refAddrRemoting);
String address = JbossSessionBeanJndiNameResolver.resolveJndiName(smd, businessRemote);
log.debug("Remote Business View for " + businessRemote + " of EJB " + smd.getEjbName()
+ " to be bound into JNDI at \"" + address + "\"");
bindingSet.addBusinessRemoteBinding(businessRemote, new JndiReferenceBinding(address, ref));
}
}
}
// If there's a local view
if (hasLocalView)
{
// Create and register a local proxy factory
String localProxyFactoryKey = this.getProxyFactoryRegistryKey(smd, true);
SessionProxyFactory factory = this.createLocalProxyFactory(localProxyFactoryKey, containerName, containerGuid,
smd, cl, advisor);
this.registerProxyFactory(localProxyFactoryKey, factory, smd);
// Initialize Reference Addresses to attach to default local JNDI Reference
List<RefAddr> refAddrsForDefaultLocal = new ArrayList<RefAddr>();
// For each of the local business interfaces, make a Reference Address
if (businessLocals != null)
{
for (String businessLocal : businessLocals)
{
RefAddr refAddr = new StringRefAddr(
ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_LOCAL, businessLocal);
refAddrsForDefaultLocal.add(refAddr);
}
}
// Determine if local home and business locals are bound to same JNDI Address
boolean bindLocalAndLocalHomeTogether = this.isHomeAndBusinessBoundTogether(smd, true);
if (bindLocalAndLocalHomeTogether)
{
// Add a Reference Address for the Local Home
RefAddr refAddr = new StringRefAddr(
ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_LOCAL, smd.getLocalHome());
refAddrsForDefaultLocal.add(refAddr);
}
// Bind Local Home (not bound together) if exists
else if (smd.getLocalHome() != null && !smd.getLocalHome().equals(""))
{
String localHomeType = smd.getLocalHome();
RefAddr refAddr = new StringRefAddr(
ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_LOCAL, localHomeType);
Reference localHomeRef = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
+ localHomeType, localProxyFactoryKey, containerName);
localHomeRef.add(refAddr);
String localHomeAddress = smd.getLocalHomeJndiName();
log.debug("Local Home View for EJB " + smd.getEjbName() + " to be bound into JNDI at \"" + localHomeAddress
+ "\"");
bindingSet.addHomeLocalBinding(new JndiReferenceBinding(localHomeAddress, localHomeRef));
}
/*
* Bind ObjectFactory for default local businesses (and LocalHome if bound together)
*/
// Get Classname to set for Reference
String defaultLocalClassName = this.getHumanReadableListOfInterfacesInRefAddrs(refAddrsForDefaultLocal);
// Create a Reference
Reference defaultLocalRef = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
+ defaultLocalClassName, localProxyFactoryKey, containerName);
// Add all Reference Addresses for Default Local Reference
for (RefAddr refAddr : refAddrsForDefaultLocal)
{
log.debug("Adding " + RefAddr.class.getSimpleName() + " to Default Local "
+ Reference.class.getSimpleName() + ": Type \"" + refAddr.getType() + "\", Content \""
+ refAddr.getContent() + "\"");
defaultLocalRef.add(refAddr);
}
// Bind the Default Local Reference to JNDI
String defaultLocalAddress = smd.getLocalJndiName();
log.debug("Default Local Business View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
+ defaultLocalAddress + "\"");
bindingSet.addDefaultLocalBinding(new JndiReferenceBinding(defaultLocalAddress, defaultLocalRef));
// Bind ObjectFactory specific to each Local Business Interface
if (businessLocals != null)
{
for (String businessLocal : businessLocals)
{
RefAddr refAddr = new StringRefAddr(
ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_LOCAL, businessLocal);
Reference ref = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
+ businessLocal, localProxyFactoryKey, containerName);
ref.add(refAddr);
String address = JbossSessionBeanJndiNameResolver.resolveJndiName(smd, businessLocal);
log.debug("Local Business View for " + businessLocal + " of EJB " + smd.getEjbName()
+ " to be bound into JNDI at \"" + address + "\"");
bindingSet.addBusinessLocalBinding(businessLocal, new JndiReferenceBinding(address, ref));