Search in sources :

Example 16 with EEApplicationClasses

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

the class PassivationAnnotationParsingProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    for (DotName annotationName : PASSIVATION_ANNOTATIONS) {
        final List<AnnotationInstance> lifecycles = index.getAnnotations(annotationName);
        for (AnnotationInstance annotation : lifecycles) {
            processPassivation(eeModuleDescription, annotation.target(), annotationName, applicationClasses);
        }
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DotName(org.jboss.jandex.DotName) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Example 17 with EEApplicationClasses

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

the class HomeViewMergingProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    if (eeModuleDescription == null) {
        return;
    }
    final Collection<ComponentDescription> componentConfigurations = eeModuleDescription.getComponentDescriptions();
    final DeploymentReflectionIndex deploymentReflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    for (ComponentDescription componentConfiguration : componentConfigurations) {
        if (componentConfiguration instanceof SessionBeanComponentDescription) {
            try {
                processComponentConfig(deploymentUnit, applicationClasses, module, deploymentReflectionIndex, (SessionBeanComponentDescription) componentConfiguration);
            } catch (Exception e) {
                throw EjbLogger.ROOT_LOGGER.failToMergeData(componentConfiguration.getComponentName(), e);
            }
        }
    }
    if (appclient) {
        for (ComponentDescription componentDescription : deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS)) {
            if (componentDescription instanceof SessionBeanComponentDescription) {
                try {
                    processComponentConfig(deploymentUnit, applicationClasses, module, deploymentReflectionIndex, (SessionBeanComponentDescription) componentDescription);
                } catch (Exception e) {
                    throw EjbLogger.ROOT_LOGGER.failToMergeData(componentDescription.getComponentName(), e);
                }
            }
        }
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

Example 18 with EEApplicationClasses

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

the class JSFManagedBeanProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    if (index == null) {
        return;
    }
    if (module == null) {
        return;
    }
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        return;
    }
    final Set<String> managedBeanClasses = new HashSet<String>();
    handleAnnotations(index, managedBeanClasses);
    processXmlManagedBeans(deploymentUnit, managedBeanClasses);
    for (String managedBean : managedBeanClasses) {
        //fail due to missing managed beans
        try {
            final Class<?> componentClass = module.getClassLoader().loadClass(managedBean);
            componentClass.getConstructor();
        } catch (ClassNotFoundException e) {
            JSFLogger.ROOT_LOGGER.managedBeanLoadFail(managedBean);
            continue;
        } catch (NoSuchMethodException e) {
            JSFLogger.ROOT_LOGGER.managedBeanNoDefaultConstructor(managedBean);
            continue;
        }
        installManagedBeanComponent(managedBean, moduleDescription, deploymentUnit, applicationClassesDescription);
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) HashSet(java.util.HashSet)

Example 19 with EEApplicationClasses

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

the class EjbJarParsingDeploymentUnitProcessor method deploy.

/**
     * Finds an ejb-jar.xml (at WEB-INF of a .war or META-INF of a .jar) parses the file and creates
     * metadata out of it. The metadata is then attached to the deployment unit.
     *
     * @param deploymentPhase
     * @throws DeploymentUnitProcessingException
     *
     */
@Override
public void deploy(DeploymentPhaseContext deploymentPhase) throws DeploymentUnitProcessingException {
    // get hold of the deployment unit.
    final DeploymentUnit deploymentUnit = deploymentPhase.getDeploymentUnit();
    // get the root of the deployment unit
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final EjbJarMetaData ejbJarMetaData;
    final EjbJarMetaData specMetaData = parseEjbJarXml(deploymentUnit);
    final EjbJarMetaData jbossMetaData = parseJBossEjb3Xml(deploymentUnit);
    if (specMetaData == null) {
        if (jbossMetaData == null)
            return;
        ejbJarMetaData = jbossMetaData;
    } else if (jbossMetaData == null) {
        ejbJarMetaData = specMetaData;
    } else {
        ejbJarMetaData = jbossMetaData.createMerged(specMetaData);
    }
    // Mark it as an EJB deployment
    EjbDeploymentMarker.mark(deploymentUnit);
    if (!deploymentUnit.hasAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION)) {
        final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        final EjbJarDescription ejbModuleDescription = new EjbJarDescription(moduleDescription, applicationClassesDescription, deploymentUnit.getName().endsWith(".war"));
        deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION, ejbModuleDescription);
    }
    // attach the EjbJarMetaData to the deployment unit
    deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA, ejbJarMetaData);
    // if the jboss-ejb3.xml has a distinct-name configured then attach it to the deployment unit
    if (jbossMetaData != null && jbossMetaData.getDistinctName() != null) {
        deploymentUnit.putAttachment(org.jboss.as.ee.structure.Attachments.DISTINCT_NAME, jbossMetaData.getDistinctName());
    }
    if (ejbJarMetaData.getModuleName() != null) {
        eeModuleDescription.setModuleName(ejbJarMetaData.getModuleName());
    }
    if (ejbJarMetaData.isMetadataComplete()) {
        MetadataCompleteMarker.setMetadataComplete(deploymentUnit, true);
    }
    if (!ejbJarMetaData.isEJB3x()) {
        //EJB spec 20.5.1, we do not process annotations for older deployments
        MetadataCompleteMarker.setMetadataComplete(deploymentUnit, true);
    }
    if (ejbJarMetaData.getEnterpriseBeans() != null) {
        //check for entity beans
        StringBuilder beans = new StringBuilder();
        boolean error = false;
        for (AbstractEnterpriseBeanMetaData bean : ejbJarMetaData.getEnterpriseBeans()) {
            if (bean.getEjbType() == EjbType.ENTITY) {
                if (!error) {
                    error = true;
                } else {
                    beans.append(", ");
                }
                beans.append(bean.getEjbName());
            }
        }
        if (error) {
            throw EjbLogger.ROOT_LOGGER.entityBeansAreNotSupported(beans.toString());
        }
    }
}
Also used : AbstractEnterpriseBeanMetaData(org.jboss.metadata.ejb.spec.AbstractEnterpriseBeanMetaData) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 20 with EEApplicationClasses

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

the class MessageDrivenComponentDescription method createConfiguration.

@Override
public ComponentConfiguration createConfiguration(final ClassReflectionIndex classIndex, final ClassLoader moduleClassLoader, final ModuleLoader moduleLoader) {
    final ComponentConfiguration mdbComponentConfiguration = new ComponentConfiguration(this, classIndex, moduleClassLoader, moduleLoader);
    // setup the component create service
    final Class<?> messageListenerInterface;
    try {
        messageListenerInterface = Class.forName(getMessageListenerInterfaceName(), true, moduleClassLoader);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
    mdbComponentConfiguration.setComponentCreateServiceFactory(new MessageDrivenComponentCreateServiceFactory(messageListenerInterface));
    // setup the configurator to inject the PoolConfig in the MessageDrivenComponentCreateService
    final MessageDrivenComponentDescription mdbComponentDescription = (MessageDrivenComponentDescription) mdbComponentConfiguration.getComponentDescription();
    mdbComponentConfiguration.getCreateDependencies().add(new PoolInjectingConfigurator(mdbComponentDescription));
    // setup the configurator to inject the resource adapter
    mdbComponentConfiguration.getCreateDependencies().add(new ResourceAdapterInjectingConfiguration());
    mdbComponentConfiguration.getCreateDependencies().add(new DependencyConfigurator<MessageDrivenComponentCreateService>() {

        @Override
        public void configureDependency(final ServiceBuilder<?> serviceBuilder, final MessageDrivenComponentCreateService mdbComponentCreateService) throws DeploymentUnitProcessingException {
            serviceBuilder.addDependency(EJBUtilities.SERVICE_NAME, EJBUtilities.class, mdbComponentCreateService.getEJBUtilitiesInjector());
            serviceBuilder.addDependency(SuspendController.SERVICE_NAME, SuspendController.class, mdbComponentCreateService.getSuspendControllerInjectedValue());
        }
    });
    // add the bmt interceptor
    if (TransactionManagementType.BEAN.equals(this.getTransactionManagementType())) {
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                // add the bmt interceptor factory
                configuration.addComponentInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR, false);
            }
        });
    } else {
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
                InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit()));
                configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), true), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR);
                configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), true), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR);
                configuration.addTimeoutViewInterceptor(TimerCMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR);
            }
        });
    }
    return mdbComponentConfiguration;
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) EJBUtilities(org.jboss.as.ejb3.component.EJBUtilities) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) SuspendController(org.jboss.as.server.suspend.SuspendController)

Aggregations

EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)24 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)19 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)18 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)9 Module (org.jboss.modules.Module)9 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)7 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)6 HashMap (java.util.HashMap)5 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)5 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)5 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)4 InterceptorClassDescription (org.jboss.as.ee.component.interceptors.InterceptorClassDescription)4 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)4 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)3 InterceptorDescription (org.jboss.as.ee.component.InterceptorDescription)3 ComponentTypeIdentityInterceptorFactory (org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory)3 AnnotationInstance (org.jboss.jandex.AnnotationInstance)3