if(jndiEnvironmentRefsGroup == null)
jndiEnvironmentRefsGroup = new JBossEnvironmentRefsGroupMetaData();
jndiEnvironmentRefsGroup.merge(jbossEnv, specEnv, "jboss-client.xml", "application-client.xml", false);
// Get the merged resource-env-refs
ResourceEnvironmentReferencesMetaData resEnvRefs = jndiEnvironmentRefsGroup.getResourceEnvironmentReferences();
// Merge the message-destinations
messageDestinations = MessageDestinationsMetaData.merge(jbossMsgs, specMsgs, "jboss-client.xml", "application-client.xml");
/* Need to map message-destinations to resource-env-refs for legacy
* descriptors that did not have message-destinations
*/
if(messageDestinations != null && resEnvRefs != null)
{
for(MessageDestinationMetaData md : messageDestinations)
{
if(md.getMappedName() == null)
{
ResourceEnvironmentReferenceMetaData ref = resEnvRefs.get(md.getMessageDestinationName());
if(ref != null)
md.setMappedName(ref.getMappedName());
}
}
}
/** A HashMap<String, ArrayList<MessageDestinationReferenceMetaData>> of
* message-destination-ref that resolve to a jndi-name via a message-destination
* via a message-destination-link
*/
HashMap<String, ArrayList<MessageDestinationReferenceMetaData>> resourceEnvReferenceLinks
= new HashMap<String, ArrayList<MessageDestinationReferenceMetaData>>();
/* Merge the message-destination-ref elements
This is a bit convoluted because legacy jboss descriptors did not support
message-destination-ref elements.
A message-destination-ref is linked to a jndi-name either via
the message-destination-ref/message-destination-ref-name mapping to
a jboss resource-env-ref/resource-env-ref-name if there is no
message-destination-link, or by the message-destination-link ->
message-destination/message-destination-name mapping to a jboss
resource-env-ref/resource-env-ref-name.
*/
if(specEnv != null)
{
ResourceEnvironmentReferencesMetaData specEnvRefs = specEnv.getResourceEnvironmentReferences();
MessageDestinationReferencesMetaData specMsgRefs = specEnv.getMessageDestinationReferences();
MessageDestinationReferencesMetaData msgRefs = jndiEnvironmentRefsGroup.getMessageDestinationReferences();
if(msgRefs == null)
{
msgRefs = new MessageDestinationReferencesMetaData();
jndiEnvironmentRefsGroup.setMessageDestinationReferences(msgRefs);
}
if(specMsgRefs != null)
for(MessageDestinationReferenceMetaData ref : specMsgRefs)
{
ref = (MessageDestinationReferenceMetaData)ref.clone();
String link = ref.getLink();
if (link != null)
{
ArrayList<MessageDestinationReferenceMetaData> linkedRefs = resourceEnvReferenceLinks.get(link);
if (linkedRefs == null)
{
linkedRefs = new ArrayList<MessageDestinationReferenceMetaData>();
resourceEnvReferenceLinks.put(link, linkedRefs);
}
linkedRefs.add(ref);
}
msgRefs.add(ref);
}
// Merge the spec resource-env-refs
if(resEnvRefs != null && specEnvRefs != null)
for(ResourceEnvironmentReferenceMetaData ref : resEnvRefs)
{
String resRefName = ref.getResourceEnvRefName();
ResourceEnvironmentReferenceMetaData specRef = specEnvRefs.get(resRefName);
if (specRef == null)
{
// Try the resourceEnvReferenceLinks
ArrayList<MessageDestinationReferenceMetaData> linkedRefs = resourceEnvReferenceLinks.get(resRefName);
if (linkedRefs != null)