Search in sources :

Example 1 with MessageDestinationReferenceMetaData

use of org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData 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;
}
Also used : ArrayList(java.util.ArrayList) MessageDestinationReferencesMetaData(org.jboss.metadata.javaee.spec.MessageDestinationReferencesMetaData) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration) LookupInjectionSource(org.jboss.as.ee.component.LookupInjectionSource) MessageDestinationReferenceMetaData(org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData)

Aggregations

ArrayList (java.util.ArrayList)1 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)1 LookupInjectionSource (org.jboss.as.ee.component.LookupInjectionSource)1 MessageDestinationReferenceMetaData (org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData)1 MessageDestinationReferencesMetaData (org.jboss.metadata.javaee.spec.MessageDestinationReferencesMetaData)1