use of org.jboss.metadata.javaee.spec.MessageDestinationReferencesMetaData in project wildfly by wildfly.
the class ResourceReferenceProcessor method getMessageDestinationRefs.
/**
* TODO: should this be part of the messaging subsystem
*/
private List<BindingConfiguration> getMessageDestinationRefs(final DeploymentDescriptorEnvironment environment, final ClassLoader classLoader, final DeploymentReflectionIndex deploymentReflectionIndex, final ResourceInjectionTarget resourceInjectionTarget, final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
final List<BindingConfiguration> bindings = new ArrayList<BindingConfiguration>();
final MessageDestinationReferencesMetaData messageDestinationReferences = environment.getEnvironment().getMessageDestinationReferences();
if (messageDestinationReferences == null) {
return bindings;
}
for (final MessageDestinationReferenceMetaData messageRef : messageDestinationReferences) {
final String name;
if (messageRef.getName().startsWith("java:")) {
name = messageRef.getName();
} else {
name = environment.getDefaultContext() + messageRef.getName();
}
Class<?> classType = null;
if (messageRef.getType() != null) {
try {
classType = classLoader.loadClass(messageRef.getType());
} catch (ClassNotFoundException e) {
throw EeLogger.ROOT_LOGGER.cannotLoad(e, messageRef.getType());
}
}
// our injection (source) comes from the local (ENC) lookup, no matter what.
final LookupInjectionSource injectionSource = new LookupInjectionSource(name);
classType = processInjectionTargets(resourceInjectionTarget, injectionSource, classLoader, deploymentReflectionIndex, messageRef, classType);
final BindingConfiguration bindingConfiguration;
if (!isEmpty(messageRef.getLookupName())) {
bindingConfiguration = new BindingConfiguration(name, new LookupInjectionSource(messageRef.getLookupName()));
bindings.add(bindingConfiguration);
} else if (!isEmpty(messageRef.getMappedName())) {
bindingConfiguration = new BindingConfiguration(name, new LookupInjectionSource(messageRef.getMappedName()));
bindings.add(bindingConfiguration);
} else if (!isEmpty(messageRef.getLink())) {
final MessageDestinationInjectionSource messageDestinationInjectionSource = new MessageDestinationInjectionSource(messageRef.getLink(), name);
bindingConfiguration = new BindingConfiguration(name, messageDestinationInjectionSource);
deploymentUnit.addToAttachmentList(Attachments.MESSAGE_DESTINATIONS, messageDestinationInjectionSource);
bindings.add(bindingConfiguration);
} else {
ROOT_LOGGER.cannotResolve("message-destination-ref", name);
}
}
return bindings;
}
Aggregations