Search in sources :

Example 1 with EEResourceReferenceProcessorRegistry

use of org.jboss.as.ee.component.deployers.EEResourceReferenceProcessorRegistry in project wildfly by wildfly.

the class BeanValidationResourceReferenceProcessorRegistryProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.getParent() == null) {
        final EEResourceReferenceProcessorRegistry eeResourceReferenceProcessorRegistry = deploymentUnit.getAttachment(Attachments.RESOURCE_REFERENCE_PROCESSOR_REGISTRY);
        if (eeResourceReferenceProcessorRegistry != null) {
            eeResourceReferenceProcessorRegistry.registerResourceReferenceProcessor(BeanValidationResourceReferenceProcessor.INSTANCE);
            eeResourceReferenceProcessorRegistry.registerResourceReferenceProcessor(BeanValidationFactoryResourceReferenceProcessor.INSTANCE);
        }
    }
}
Also used : DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) EEResourceReferenceProcessorRegistry(org.jboss.as.ee.component.deployers.EEResourceReferenceProcessorRegistry)

Example 2 with EEResourceReferenceProcessorRegistry

use of org.jboss.as.ee.component.deployers.EEResourceReferenceProcessorRegistry 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));
    }
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ManagedBeanComponentDescription(org.jboss.as.ee.managedbean.component.ManagedBeanComponentDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) ContextClassLoaderInterceptor(org.jboss.invocation.ContextClassLoaderInterceptor) ManagedBeanResourceReferenceProcessor(org.jboss.as.ee.managedbean.component.ManagedBeanResourceReferenceProcessor) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) EEResourceReferenceProcessorRegistry(org.jboss.as.ee.component.deployers.EEResourceReferenceProcessorRegistry) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) AnnotationValue(org.jboss.jandex.AnnotationValue) PropertyReplacer(org.jboss.metadata.property.PropertyReplacer) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo)

Example 3 with EEResourceReferenceProcessorRegistry

use of org.jboss.as.ee.component.deployers.EEResourceReferenceProcessorRegistry in project wildfly by wildfly.

the class WebServicesContextJndiSetupProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEResourceReferenceProcessorRegistry registry = deploymentUnit.getAttachment(Attachments.RESOURCE_REFERENCE_PROCESSOR_REGISTRY);
    if (registry != null) {
        // Add an EEResourceReferenceProcessor which handles @Resource references of type WebServiceContext.
        registry.registerResourceReferenceProcessor(new WebServiceContextResourceProcessor());
    }
}
Also used : DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) EEResourceReferenceProcessorRegistry(org.jboss.as.ee.component.deployers.EEResourceReferenceProcessorRegistry)

Example 4 with EEResourceReferenceProcessorRegistry

use of org.jboss.as.ee.component.deployers.EEResourceReferenceProcessorRegistry in project wildfly by wildfly.

the class EjbContextJndiBindingProcessor method deploy.

/**
 * {@inheritDoc} *
 */
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEResourceReferenceProcessorRegistry registry = deploymentUnit.getAttachment(Attachments.RESOURCE_REFERENCE_PROCESSOR_REGISTRY);
    // setup ejb context jndi handlers
    registry.registerResourceReferenceProcessor(new EjbContextResourceReferenceProcessor(EJBContext.class));
    registry.registerResourceReferenceProcessor(new EjbContextResourceReferenceProcessor(SessionContext.class));
    registry.registerResourceReferenceProcessor(new EjbContextResourceReferenceProcessor(EntityContext.class));
    registry.registerResourceReferenceProcessor(new EjbContextResourceReferenceProcessor(MessageDrivenContext.class));
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final Collection<ComponentDescription> componentConfigurations = eeModuleDescription.getComponentDescriptions();
    if (componentConfigurations == null || componentConfigurations.isEmpty()) {
        return;
    }
    for (ComponentDescription componentConfiguration : componentConfigurations) {
        final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
        if (index != null) {
            processComponentConfig(componentConfiguration);
        }
    }
}
Also used : EJBContext(javax.ejb.EJBContext) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EjbContextResourceReferenceProcessor(org.jboss.as.ejb3.context.EjbContextResourceReferenceProcessor) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) MessageDrivenContext(javax.ejb.MessageDrivenContext) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) SessionContext(javax.ejb.SessionContext) EntityContext(javax.ejb.EntityContext) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) EEResourceReferenceProcessorRegistry(org.jboss.as.ee.component.deployers.EEResourceReferenceProcessorRegistry)

Aggregations

EEResourceReferenceProcessorRegistry (org.jboss.as.ee.component.deployers.EEResourceReferenceProcessorRegistry)4 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)4 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)2 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)2 EJBContext (javax.ejb.EJBContext)1 EntityContext (javax.ejb.EntityContext)1 MessageDrivenContext (javax.ejb.MessageDrivenContext)1 SessionContext (javax.ejb.SessionContext)1 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)1 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)1 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)1 ViewConfigurator (org.jboss.as.ee.component.ViewConfigurator)1 ViewDescription (org.jboss.as.ee.component.ViewDescription)1 ManagedBeanComponentDescription (org.jboss.as.ee.managedbean.component.ManagedBeanComponentDescription)1 ManagedBeanResourceReferenceProcessor (org.jboss.as.ee.managedbean.component.ManagedBeanResourceReferenceProcessor)1 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)1 EjbContextResourceReferenceProcessor (org.jboss.as.ejb3.context.EjbContextResourceReferenceProcessor)1 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)1 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)1 ContextClassLoaderInterceptor (org.jboss.invocation.ContextClassLoaderInterceptor)1