Search in sources :

Example 16 with Module

use of org.jboss.modules.Module in project wildfly by wildfly.

the class BusinessViewAnnotationProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) {
        return;
    }
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(EE_MODULE_DESCRIPTION);
    final Collection<ComponentDescription> componentDescriptions = eeModuleDescription.getComponentDescriptions();
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    if (module == null) {
        return;
    }
    final ClassLoader moduleClassLoader = module.getClassLoader();
    if (componentDescriptions != null) {
        for (ComponentDescription componentDescription : componentDescriptions) {
            if (componentDescription instanceof SessionBeanComponentDescription == false) {
                continue;
            }
            final Class<?> ejbClass = this.getEjbClass(componentDescription.getComponentClassName(), moduleClassLoader);
            try {
                this.processViewAnnotations(deploymentUnit, ejbClass, (SessionBeanComponentDescription) componentDescription);
            } catch (Exception e) {
                throw EjbLogger.ROOT_LOGGER.failedToProcessBusinessInterfaces(ejbClass, e);
            }
        }
    }
    if (appclient) {
        for (ComponentDescription componentDescription : deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS)) {
            if (componentDescription instanceof SessionBeanComponentDescription == false) {
                continue;
            }
            final Class<?> ejbClass = this.getEjbClass(componentDescription.getComponentClassName(), moduleClassLoader);
            try {
                this.processViewAnnotations(deploymentUnit, ejbClass, (SessionBeanComponentDescription) componentDescription);
            } catch (Exception e) {
                throw EjbLogger.ROOT_LOGGER.failedToProcessBusinessInterfaces(ejbClass, e);
            }
        }
    }
}
Also used : SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

Example 17 with Module

use of org.jboss.modules.Module in project wildfly by wildfly.

the class CacheDependenciesProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext context) {
    DeploymentUnit unit = context.getDeploymentUnit();
    final ServiceName name = unit.getServiceName();
    EEModuleDescription moduleDescription = unit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (moduleDescription == null) {
        return;
    }
    final CapabilityServiceSupport support = unit.getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
    final ServiceTarget target = context.getServiceTarget();
    @SuppressWarnings("rawtypes") Collection<ValueDependency<CacheFactoryBuilder>> cacheDependencies = moduleDescription.getComponentDescriptions().stream().filter(StatefulComponentDescription.class::isInstance).map(description -> new InjectedValueDependency<>(getCacheFactoryBuilderServiceName((StatefulComponentDescription) description), CacheFactoryBuilder.class)).distinct().collect(Collectors.toList());
    Service<Void> service = new AbstractService<Void>() {

        @Override
        public void start(StartContext context) {
            // Install dependencies for each distinct cache factory builder referenced by the deployment
            cacheDependencies.stream().map(Value::getValue).distinct().forEach(builder -> builder.installDeploymentUnitDependencies(support, target, name));
        }
    };
    ServiceBuilder<Void> builder = target.addService(name.append("cache-dependencies-installer"), service);
    cacheDependencies.forEach(dependency -> dependency.register(builder));
    builder.install();
    // Install versioned marshalling configuration
    InjectedValue<ModuleDeployment> deployment = new InjectedValue<>();
    Module module = unit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    target.addService(MarshallingConfigurationRepositoryValue.getServiceName(name), new ValueService<>(new MarshallingConfigurationRepositoryValue(deployment, new ImmediateValue<>(module)))).addDependency(name.append(ModuleDeployment.SERVICE_NAME), ModuleDeployment.class, deployment).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
Also used : InjectedValue(org.jboss.msc.value.InjectedValue) ServiceTarget(org.jboss.msc.service.ServiceTarget) MarshallingConfigurationRepositoryValue(org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryValue) AbstractService(org.jboss.msc.service.AbstractService) ValueDependency(org.wildfly.clustering.service.ValueDependency) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) ValueService(org.jboss.msc.service.ValueService) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) CacheFactoryBuilder(org.jboss.as.ejb3.cache.CacheFactoryBuilder) ImmediateValue(org.jboss.msc.value.ImmediateValue) ModuleDeployment(org.jboss.as.ejb3.deployment.ModuleDeployment) StartContext(org.jboss.msc.service.StartContext) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) Value(org.jboss.msc.value.Value) ImmediateValue(org.jboss.msc.value.ImmediateValue) MarshallingConfigurationRepositoryValue(org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryValue) InjectedValue(org.jboss.msc.value.InjectedValue) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 18 with Module

use of org.jboss.modules.Module in project wildfly by wildfly.

the class AbstractMergingProcessor 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);
    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);
    if (componentConfigurations == null || componentConfigurations.isEmpty()) {
        return;
    }
    for (ComponentDescription componentConfiguration : componentConfigurations) {
        if (typeParam.isAssignableFrom(componentConfiguration.getClass())) {
            try {
                processComponentConfig(deploymentUnit, applicationClasses, module, deploymentReflectionIndex, (T) componentConfiguration);
            } catch (Exception e) {
                throw EjbLogger.ROOT_LOGGER.failToMergeData(componentConfiguration.getComponentName(), e);
            }
        }
    }
}
Also used : EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) 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) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

Example 19 with Module

use of org.jboss.modules.Module in project wildfly by wildfly.

the class BeanValidationFactoryDeployer method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    if (module == null || moduleDescription == null) {
        return;
    }
    final LazyValidatorFactory factory = new LazyValidatorFactory(module.getClassLoader());
    deploymentUnit.putAttachment(BeanValidationAttachments.VALIDATOR_FACTORY, factory);
    bindFactoryToJndi(factory, deploymentUnit, phaseContext, moduleDescription);
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 20 with Module

use of org.jboss.modules.Module in project wildfly by wildfly.

the class BatchEnvironmentProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.hasAttachment(Attachments.MODULE)) {
        BatchLogger.LOGGER.tracef("Processing deployment '%s' for the batch environment.", deploymentUnit.getName());
        // Get the class loader
        final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
        final ClassLoader moduleClassLoader = module.getClassLoader();
        final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
        final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
        // Create the batch environment
        final WildFlyJobXmlResolver jobXmlResolver = WildFlyJobXmlResolver.forDeployment(deploymentUnit);
        final BatchEnvironmentService service = new BatchEnvironmentService(moduleClassLoader, jobXmlResolver, deploymentUnit.getName());
        // Set the value for the job-repository, this can't be a capability as the JDBC job repository cannot be constructed
        // until deployment time because the default JNDI data-source name is only known during DUP processing
        service.getJobRepositoryInjector().setValue(new ImmediateValue<>(JobRepositoryFactory.getInstance().getJobRepository(moduleDescription)));
        final ServiceBuilder<SecurityAwareBatchEnvironment> serviceBuilder = serviceTarget.addService(BatchServiceNames.batchEnvironmentServiceName(deploymentUnit), service);
        // Register the required services
        serviceBuilder.addDependency(support.getCapabilityServiceName(Capabilities.BATCH_CONFIGURATION_CAPABILITY.getName()), BatchConfiguration.class, service.getBatchConfigurationInjector());
        serviceBuilder.addDependency(TxnServices.JBOSS_TXN_TRANSACTION_MANAGER, TransactionManager.class, service.getTransactionManagerInjector());
        // Register the bean manager if this is a CDI deployment
        if (WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
            BatchLogger.LOGGER.tracef("Adding BeanManager service dependency for deployment %s", deploymentUnit.getName());
            serviceBuilder.addDependency(BatchServiceNames.beanManagerServiceName(deploymentUnit), BeanManager.class, service.getBeanManagerInjector());
        }
        if (rcPresent) {
            serviceBuilder.addDependency(RequestController.SERVICE_NAME, RequestController.class, service.getRequestControllerInjector());
        }
        // Install the batch environment service
        serviceBuilder.install();
        // Create the job operator service used interact with a deployments batch job
        final JobOperatorService jobOperatorService = new JobOperatorService(Boolean.FALSE, deploymentUnit.getName(), jobXmlResolver);
        // Install the JobOperatorService
        Services.addServerExecutorDependency(serviceTarget.addService(org.wildfly.extension.batch.jberet.BatchServiceNames.jobOperatorServiceName(deploymentUnit), jobOperatorService).addDependency(support.getCapabilityServiceName(Capabilities.BATCH_CONFIGURATION_CAPABILITY.getName()), BatchConfiguration.class, jobOperatorService.getBatchConfigurationInjector()).addDependency(SuspendController.SERVICE_NAME, SuspendController.class, jobOperatorService.getSuspendControllerInjector()).addDependency(org.wildfly.extension.batch.jberet.BatchServiceNames.batchEnvironmentServiceName(deploymentUnit), SecurityAwareBatchEnvironment.class, jobOperatorService.getBatchEnvironmentInjector()), jobOperatorService.getExecutorServiceInjector(), false).install();
        // Add the JobOperatorService to the deployment unit
        deploymentUnit.putAttachment(BatchAttachments.JOB_OPERATOR, jobOperatorService);
        // Add the JobOperator to the context selector
        selector.registerContext(moduleClassLoader, JobOperatorContext.create(jobOperatorService));
    }
}
Also used : JobOperatorService(org.wildfly.extension.batch.jberet.deployment.JobOperatorService) ServiceTarget(org.jboss.msc.service.ServiceTarget) SecurityAwareBatchEnvironment(org.wildfly.extension.batch.jberet.deployment.SecurityAwareBatchEnvironment) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) WildFlyJobXmlResolver(org.wildfly.extension.batch.jberet.deployment.WildFlyJobXmlResolver) BatchEnvironmentService(org.wildfly.extension.batch.jberet.deployment.BatchEnvironmentService) SuspendController(org.jboss.as.server.suspend.SuspendController) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

Module (org.jboss.modules.Module)100 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)58 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)28 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)27 ServiceName (org.jboss.msc.service.ServiceName)21 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)19 HashMap (java.util.HashMap)17 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)17 ServiceTarget (org.jboss.msc.service.ServiceTarget)17 HashSet (java.util.HashSet)16 ArrayList (java.util.ArrayList)13 ModuleLoadException (org.jboss.modules.ModuleLoadException)11 ModuleIdentifier (org.jboss.modules.ModuleIdentifier)10 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)9 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)8 Method (java.lang.reflect.Method)7 Map (java.util.Map)7 IOException (java.io.IOException)6 InterceptorDescription (org.jboss.as.ee.component.InterceptorDescription)6 ContextNames (org.jboss.as.naming.deployment.ContextNames)6