use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class ManagedBeanAnnotationProcessor method deploy.
/**
* Check the deployment annotation index for all classes with the @ManagedBean annotation. For each class with the
* annotation, collect all the required information to create a managed bean instance, and attach it to the context.
*
* @param phaseContext the deployment unit context
* @throws DeploymentUnitProcessingException
*
*/
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEResourceReferenceProcessorRegistry registry = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.RESOURCE_REFERENCE_PROCESSOR_REGISTRY);
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
final PropertyReplacer replacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
if (compositeIndex == null) {
return;
}
final List<AnnotationInstance> instances = compositeIndex.getAnnotations(MANAGED_BEAN_ANNOTATION_NAME);
if (instances == null || instances.isEmpty()) {
return;
}
for (AnnotationInstance instance : instances) {
AnnotationTarget target = instance.target();
if (!(target instanceof ClassInfo)) {
throw EeLogger.ROOT_LOGGER.classOnlyAnnotation("@ManagedBean", target);
}
final ClassInfo classInfo = (ClassInfo) target;
// skip if it's not a valid managed bean class
if (!assertManagedBeanClassValidity(classInfo)) {
continue;
}
final String beanClassName = classInfo.name().toString();
// Get the managed bean name from the annotation
final AnnotationValue nameValue = instance.value();
final String beanName = (nameValue == null || nameValue.asString().isEmpty()) ? beanClassName : replacer.replaceProperties(nameValue.asString());
final ManagedBeanComponentDescription componentDescription = new ManagedBeanComponentDescription(beanName, beanClassName, moduleDescription, deploymentUnit.getServiceName());
// Add the view
ViewDescription viewDescription = new ViewDescription(componentDescription, beanClassName);
viewDescription.getConfigurators().addFirst(new ViewConfigurator() {
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
// Add MB association interceptors
configuration.addClientPostConstructInterceptor(ManagedBeanCreateInterceptor.FACTORY, InterceptorOrder.ClientPostConstruct.INSTANCE_CREATE);
final ClassLoader classLoader = componentConfiguration.getModuleClassLoader();
configuration.addViewInterceptor(AccessCheckingInterceptor.getFactory(), InterceptorOrder.View.CHECKING_INTERCEPTOR);
configuration.addViewInterceptor(new ImmediateInterceptorFactory(new ContextClassLoaderInterceptor(classLoader)), InterceptorOrder.View.TCCL_INTERCEPTOR);
}
});
viewDescription.getBindingNames().addAll(Arrays.asList("java:module/" + beanName, "java:app/" + moduleDescription.getModuleName() + "/" + beanName));
componentDescription.getViews().add(viewDescription);
moduleDescription.addComponent(componentDescription);
// register an EEResourceReferenceProcessor which can process @Resource references to this managed bean.
registry.registerResourceReferenceProcessor(new ManagedBeanResourceReferenceProcessor(beanClassName));
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class InstanceNameBindingProcessor 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 ServiceTarget serviceTarget = phaseContext.getServiceTarget();
//if this is a war we need to bind to the modules comp namespace
if (DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit) || DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit)) {
final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getApplicationName(), moduleDescription.getModuleName());
bindServices(deploymentUnit, serviceTarget, moduleContextServiceName);
}
for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
if (component.getNamingMode() == ComponentNamingMode.CREATE) {
final ServiceName compContextServiceName = ContextNames.contextServiceNameOfComponent(moduleDescription.getApplicationName(), moduleDescription.getModuleName(), component.getComponentName());
bindServices(deploymentUnit, serviceTarget, compContextServiceName);
}
}
}
use of org.jboss.as.ee.component.EEModuleDescription 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.EEModuleDescription in project wildfly by wildfly.
the class ComponentAggregationProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ComponentRegistry componentRegistry = new ComponentRegistry(phaseContext.getServiceRegistry());
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(EE_MODULE_DESCRIPTION);
if (moduleDescription == null) {
return;
}
phaseContext.getServiceTarget().addService(ComponentRegistry.serviceName(deploymentUnit), new ValueService<>(new ImmediateValue<Object>(componentRegistry))).addDependency(moduleDescription.getDefaultClassIntrospectorServiceName(), EEClassIntrospector.class, componentRegistry.getClassIntrospectorInjectedValue()).install();
deploymentUnit.putAttachment(COMPONENT_REGISTRY, componentRegistry);
if (deploymentUnit.getAttachment(Attachments.DEPLOYMENT_TYPE) == DeploymentType.EAR) {
final EEApplicationDescription applicationDescription = new EEApplicationDescription();
deploymentUnit.putAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_DESCRIPTION, applicationDescription);
for (final Map.Entry<String, String> messageDestination : moduleDescription.getMessageDestinations().entrySet()) {
applicationDescription.addMessageDestination(messageDestination.getKey(), messageDestination.getValue(), deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT).getRoot());
}
/*
* We are an EAR, so we must inspect all of our subdeployments and aggregate all their component views
* into a single index, so that inter-module resolution will work.
*/
// Add the application description
final List<DeploymentUnit> subdeployments = deploymentUnit.getAttachmentList(SUB_DEPLOYMENTS);
for (final DeploymentUnit subdeployment : subdeployments) {
final EEModuleDescription subDeploymentModuleDescription = subdeployment.getAttachment(EE_MODULE_DESCRIPTION);
final ResourceRoot deploymentRoot = subdeployment.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
if (subDeploymentModuleDescription == null) {
// Not an EE deployment.
continue;
}
for (final ComponentDescription componentDescription : subDeploymentModuleDescription.getComponentDescriptions()) {
applicationDescription.addComponent(componentDescription, deploymentRoot.getRoot());
}
for (final Map.Entry<String, String> messageDestination : subDeploymentModuleDescription.getMessageDestinations().entrySet()) {
applicationDescription.addMessageDestination(messageDestination.getKey(), messageDestination.getValue(), deploymentRoot.getRoot());
}
for (final ComponentDescription componentDescription : subdeployment.getAttachmentList(org.jboss.as.ee.component.Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS)) {
applicationDescription.addComponent(componentDescription, deploymentRoot.getRoot());
}
subdeployment.putAttachment(EE_APPLICATION_DESCRIPTION, applicationDescription);
}
} else if (deploymentUnit.getParent() == null) {
final EEApplicationDescription applicationDescription = new EEApplicationDescription();
deploymentUnit.putAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_DESCRIPTION, applicationDescription);
/*
* We are a top-level EE deployment, or a non-EE deployment. Our "aggregate" index is just a copy of
* our local EE module index.
*/
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
for (final ComponentDescription componentDescription : moduleDescription.getComponentDescriptions()) {
applicationDescription.addComponent(componentDescription, deploymentRoot.getRoot());
}
for (final Map.Entry<String, String> messageDestination : moduleDescription.getMessageDestinations().entrySet()) {
applicationDescription.addMessageDestination(messageDestination.getKey(), messageDestination.getValue(), deploymentRoot.getRoot());
}
for (final ComponentDescription componentDescription : deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS)) {
applicationDescription.addComponent(componentDescription, deploymentRoot.getRoot());
}
}
}
use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.
the class EEConcurrentContextProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
return;
}
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
if (eeModuleDescription == null) {
return;
}
processModuleDescription(eeModuleDescription, deploymentUnit, phaseContext);
final Collection<ComponentDescription> componentDescriptions = eeModuleDescription.getComponentDescriptions();
if (componentDescriptions == null) {
return;
}
for (ComponentDescription componentDescription : componentDescriptions) {
if (componentDescription.getNamingMode() == ComponentNamingMode.NONE) {
// skip components without namespace
continue;
}
processComponentDescription(componentDescription);
}
}
Aggregations