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);
}
}
}
}
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();
}
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);
}
}
}
}
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);
}
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));
}
}
Aggregations