{
// first check lookup name
String lookupName = messageDestRef.getLookupName();
if (lookupName != null && !lookupName.trim().isEmpty())
{
return new LinkRefResource(lookupName);
}
// now check mapped name
String mappedName = messageDestRef.getMappedName();
if (mappedName != null && !mappedName.trim().isEmpty())
{
return new LinkRefResource(mappedName);
}
// now check (JBoss specific) jndi name!
String jndiName = messageDestRef.getJNDIName();
if (jndiName != null && !jndiName.trim().isEmpty())
{
return new LinkRefResource(jndiName);
}
// Now check if a message-destination link is specified.
// The "link" itself is a logical name to the destination, so we'll
// use a resolver to resolve a jndi name out of it.
String messageDestLink = messageDestRef.getMessageDestinationLink();
if (messageDestLink != null && !messageDestLink.trim().isEmpty())
{
if (this.messageDestinationResolver == null)
{
logger.warn("Cannot resolve message-destination link: " + messageDestLink
+ " for message-destination-ref: " + messageDestRef.getName() + " due to absence of a "
+ MessageDestinationReferenceResolver.class.getName());
}
else
{
// the DU which depends on this message-destination-ref
DeploymentUnit dependentDU = unit;
// the MessageDestinationReferenceResolver works on non-component deployment units.
// So if we are currently processing component DUs (like we do for EJBs), then pass the
// component DUs parent during resolution.
if (unit.isComponent())
{
dependentDU = unit.getParent();
}
String resolvedJNDIName = this.messageDestinationResolver.resolveMessageDestinationJndiName(dependentDU, messageDestLink);
logger.debug("Resolved jndi-name: " + resolvedJNDIName + " for message-destination link: "
+ messageDestLink + " in message-destination-ref: " + messageDestRef.getName());
if (resolvedJNDIName != null && !resolvedJNDIName.trim().isEmpty())
{
return new LinkRefResource(resolvedJNDIName);
}
}
}
throw new RuntimeException("Cannot provide a resource for message-destination-ref: " + messageDestRef.getName() + " in unit: " + unit);