use of org.jboss.as.ee.component.BindingConfiguration in project wildfly by wildfly.
the class ResourceDefinitionAnnotationProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
if (moduleDescription == null) {
return;
}
final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
if (index == null) {
return;
}
final PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
final DotName annotationName = getAnnotationDotName();
for (AnnotationInstance annotationInstance : index.getAnnotations(annotationName)) {
final List<BindingConfiguration> bindingConfigurations = getAnnotatedClassBindingConfigurations(moduleDescription, annotationInstance);
final ResourceDefinitionInjectionSource injectionSource = processAnnotation(annotationInstance, propertyReplacer);
bindingConfigurations.add(new BindingConfiguration(injectionSource.getJndiName(), injectionSource));
}
final DotName collectionAnnotationName = getAnnotationCollectionDotName();
if (collectionAnnotationName != null) {
for (AnnotationInstance annotationInstance : index.getAnnotations(collectionAnnotationName)) {
final AnnotationInstance[] nestedAnnotationInstances = annotationInstance.value().asNestedArray();
if (nestedAnnotationInstances != null && nestedAnnotationInstances.length > 0) {
final List<BindingConfiguration> bindingConfigurations = getAnnotatedClassBindingConfigurations(moduleDescription, annotationInstance);
for (AnnotationInstance nestedAnnotationInstance : nestedAnnotationInstances) {
final ResourceDefinitionInjectionSource injectionSource = processAnnotation(nestedAnnotationInstance, propertyReplacer);
bindingConfigurations.add(new BindingConfiguration(injectionSource.getJndiName(), injectionSource));
}
}
}
}
}
use of org.jboss.as.ee.component.BindingConfiguration in project wildfly by wildfly.
the class EjbContextJndiBindingProcessor method processComponentConfig.
protected void processComponentConfig(final DeploymentUnit deploymentUnit, final DeploymentPhaseContext phaseContext, final CompositeIndex index, final ComponentDescription componentDescription) throws DeploymentUnitProcessingException {
if (!(componentDescription instanceof EJBComponentDescription)) {
// Only process EJBs
return;
}
// if the EJB is packaged in a .war, then we need to bind the java:comp/EJBContext only once for the entire module
if (componentDescription.getNamingMode() != ComponentNamingMode.CREATE) {
// get the module description
final EEModuleDescription moduleDescription = componentDescription.getModuleDescription();
// the java:module/EJBContext binding configuration
// Note that we bind to java:module/EJBContext since it's a .war. End users can still lookup java:comp/EJBContext
// and that will internally get translated to java:module/EJBContext for .war, since java:comp == java:module in
// a web ENC. So binding to java:module/EJBContext is OK.
final BindingConfiguration ejbContextBinding = new BindingConfiguration("java:module/EJBContext", directEjbContextReferenceSource);
moduleDescription.getBindingConfigurations().add(ejbContextBinding);
} else {
// EJB packaged outside of a .war. So process normally.
// add the binding configuration to the component description
final BindingConfiguration ejbContextBinding = new BindingConfiguration("java:comp/EJBContext", directEjbContextReferenceSource);
componentDescription.getBindingConfigurations().add(ejbContextBinding);
}
}
use of org.jboss.as.ee.component.BindingConfiguration in project wildfly by wildfly.
the class TimerServiceJndiBindingProcessor method processComponentConfig.
@Override
protected void processComponentConfig(DeploymentUnit deploymentUnit, DeploymentPhaseContext phaseContext, CompositeIndex index, ComponentDescription componentDescription) throws DeploymentUnitProcessingException {
if (!(componentDescription instanceof EJBComponentDescription)) {
// Only process EJBs
return;
}
// if the EJB is packaged in a .war, then we need to bind the java:comp/TimerService only once for the entire module
if (componentDescription.getNamingMode() != ComponentNamingMode.CREATE) {
// get the module description
final EEModuleDescription moduleDescription = componentDescription.getModuleDescription();
// the java:module/TimerService binding configuration
// Note that we bind to java:module/TimerService since it's a .war. End users can still lookup java:comp/TimerService
// and that will internally get translated to java:module/TimerService for .war, since java:comp == java:module in
// a web ENC. So binding to java:module/TimerService is OK.
final BindingConfiguration timerServiceBinding = new BindingConfiguration("java:module/TimerService", new TimerServiceBindingSource());
moduleDescription.getBindingConfigurations().add(timerServiceBinding);
} else {
// EJB packaged outside of a .war. So process normally.
// add the binding configuration to the component description
final BindingConfiguration timerServiceBinding = new BindingConfiguration("java:comp/TimerService", new TimerServiceBindingSource());
componentDescription.getBindingConfigurations().add(timerServiceBinding);
}
}
use of org.jboss.as.ee.component.BindingConfiguration in project wildfly by wildfly.
the class EjbResourceInjectionAnnotationProcessor method process.
private void process(final DeploymentUnit deploymentUnit, final String beanInterface, final String beanName, final String lookup, final ClassInfo classInfo, final InjectionTarget targetDescription, final String localContextName, final EEModuleDescription eeModuleDescription) {
if (!isEmpty(lookup) && !isEmpty(beanName)) {
EjbLogger.DEPLOYMENT_LOGGER.debugf("Both beanName = %s and lookup = %s have been specified in @EJB annotation. Lookup will be given preference. Class: %s", beanName, lookup, classInfo.name());
}
final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
final InjectionSource valueSource;
EjbInjectionSource ejbInjectionSource = null;
//give preference to lookup
if (!isEmpty(lookup)) {
if (!lookup.startsWith("java:")) {
valueSource = new EjbLookupInjectionSource(lookup, targetDescription == null ? null : targetDescription.getDeclaredValueClassName());
} else {
valueSource = createLookup(lookup, appclient);
}
} else if (!isEmpty(beanName)) {
valueSource = ejbInjectionSource = new EjbInjectionSource(beanName, beanInterface, localContextName, deploymentUnit, appclient);
} else {
valueSource = ejbInjectionSource = new EjbInjectionSource(beanInterface, localContextName, deploymentUnit, appclient);
}
if (ejbInjectionSource != null) {
deploymentUnit.addToAttachmentList(EjbDeploymentAttachmentKeys.EJB_INJECTIONS, ejbInjectionSource);
}
// our injection comes from the local lookup, no matter what.
final ResourceInjectionConfiguration injectionConfiguration = targetDescription != null ? new ResourceInjectionConfiguration(targetDescription, createLookup(localContextName, appclient)) : null;
// Create the binding from whence our injection comes.
final BindingConfiguration bindingConfiguration = new BindingConfiguration(localContextName, valueSource);
classDescription.getBindingConfigurations().add(bindingConfiguration);
if (injectionConfiguration != null) {
classDescription.addResourceInjection(injectionConfiguration);
}
}
use of org.jboss.as.ee.component.BindingConfiguration in project wildfly by wildfly.
the class WSRefDDProcessor method processDescriptorEntries.
@Override
protected List<BindingConfiguration> processDescriptorEntries(final DeploymentUnit unit, final DeploymentDescriptorEnvironment environment, final ResourceInjectionTarget resourceInjectionTarget, final ComponentDescription componentDescription, final ClassLoader classLoader, final DeploymentReflectionIndex deploymentReflectionIndex, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException {
final ServiceReferencesMetaData serviceRefsMD = environment.getEnvironment().getServiceReferences();
if (serviceRefsMD == null) {
return Collections.<BindingConfiguration>emptyList();
}
final List<BindingConfiguration> bindingDescriptions = new LinkedList<BindingConfiguration>();
for (final ServiceReferenceMetaData serviceRefMD : serviceRefsMD) {
final UnifiedServiceRefMetaData serviceRefUMDM = getServiceRef(unit, componentDescription, serviceRefMD);
final Module module = unit.getAttachment(Attachments.MODULE);
WebServiceManagedReferenceFactory factory = new WebServiceManagedReferenceFactory(serviceRefUMDM, module.getClassLoader());
final FixedInjectionSource valueSource = new FixedInjectionSource(factory, factory);
final BindingConfiguration bindingConfiguration = new BindingConfiguration(serviceRefUMDM.getServiceRefName(), valueSource);
bindingDescriptions.add(bindingConfiguration);
final String serviceRefTypeName = serviceRefUMDM.getServiceRefType();
final Class<?> serviceRefType = getClass(classLoader, serviceRefTypeName);
processInjectionTargets(resourceInjectionTarget, valueSource, classLoader, deploymentReflectionIndex, serviceRefMD, serviceRefType);
}
return bindingDescriptions;
}
Aggregations