use of org.jboss.modules.Module in project wildfly by wildfly.
the class WildFlyJobXmlResolver method forDeployment.
/**
* Creates the {@linkplain JobXmlResolver resolver} for the deployment inheriting any visible resolvers and job XML
* files from dependencies.
*
* @param deploymentUnit the deployment to process
*
* @return the resolve
*
* @throws DeploymentUnitProcessingException if an error occurs processing the deployment
*/
public static WildFlyJobXmlResolver forDeployment(final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
// If this deployment unit already has a resolver, just use it
if (deploymentUnit.hasAttachment(BatchAttachments.JOB_XML_RESOLVER)) {
return deploymentUnit.getAttachment(BatchAttachments.JOB_XML_RESOLVER);
}
// Get the module for it's class loader
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
final ClassLoader classLoader = module.getClassLoader();
WildFlyJobXmlResolver resolver;
// access to the EAR/lib directory so those resources need to be processed
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
// Create a new WildFlyJobXmlResolver without jobs from sub-deployments as they'll be processed later
final List<ResourceRoot> resources = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS).stream().filter(r -> !SubDeploymentMarker.isSubDeployment(r)).collect(Collectors.toList());
resolver = create(classLoader, resources);
deploymentUnit.putAttachment(BatchAttachments.JOB_XML_RESOLVER, resolver);
} else {
// Create a new resolver for this deployment
if (deploymentUnit.hasAttachment(Attachments.RESOURCE_ROOTS)) {
resolver = create(classLoader, deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS));
} else {
resolver = create(classLoader, Collections.singletonList(deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT)));
}
deploymentUnit.putAttachment(BatchAttachments.JOB_XML_RESOLVER, resolver);
// Process all accessible sub-deployments
final List<DeploymentUnit> accessibleDeployments = deploymentUnit.getAttachmentList(Attachments.ACCESSIBLE_SUB_DEPLOYMENTS);
for (DeploymentUnit subDeployment : accessibleDeployments) {
// Skip our self
if (deploymentUnit.equals(subDeployment)) {
continue;
}
if (subDeployment.hasAttachment(BatchAttachments.JOB_XML_RESOLVER)) {
final WildFlyJobXmlResolver toCopy = subDeployment.getAttachment(BatchAttachments.JOB_XML_RESOLVER);
WildFlyJobXmlResolver.merge(resolver, toCopy);
} else {
// We need to create a resolver for the sub-deployment and merge the two
final WildFlyJobXmlResolver toCopy = forDeployment(subDeployment);
subDeployment.putAttachment(BatchAttachments.JOB_XML_RESOLVER, toCopy);
WildFlyJobXmlResolver.merge(resolver, toCopy);
}
}
}
return resolver;
}
use of org.jboss.modules.Module in project wildfly by wildfly.
the class ApplicationClientManifestProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit)) {
return;
}
final ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
final Manifest manifest = root.getAttachment(Attachments.MANIFEST);
if (manifest != null) {
Attributes main = manifest.getMainAttributes();
if (main != null) {
String mainClass = main.getValue("Main-Class");
if (mainClass != null && !mainClass.isEmpty()) {
try {
final Class<?> clazz = module.getClassLoader().loadClass(mainClass);
deploymentUnit.putAttachment(AppClientAttachments.MAIN_CLASS, clazz);
final ApplicationClientComponentDescription description = new ApplicationClientComponentDescription(clazz.getName(), moduleDescription, deploymentUnit.getServiceName(), applicationClasses);
moduleDescription.addComponent(description);
deploymentUnit.putAttachment(AppClientAttachments.APPLICATION_CLIENT_COMPONENT, description);
final DeploymentDescriptorEnvironment environment = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.MODULE_DEPLOYMENT_DESCRIPTOR_ENVIRONMENT);
if (environment != null) {
DescriptorEnvironmentLifecycleMethodProcessor.handleMethods(environment, moduleDescription, mainClass);
}
} catch (ClassNotFoundException e) {
throw AppClientLogger.ROOT_LOGGER.cannotLoadAppClientMainClass(e);
}
}
}
}
}
use of org.jboss.modules.Module in project wildfly by wildfly.
the class TransactionAttributeMergingProcessor method handleAnnotations.
@Override
protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {
final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
processTransactionAttributeAnnotation(applicationClasses, deploymentReflectionIndex, componentClass, null, componentConfiguration);
processTransactionTimeoutAnnotation(applicationClasses, deploymentReflectionIndex, componentClass, null, componentConfiguration);
for (ViewDescription view : componentConfiguration.getViews()) {
try {
final Class<?> viewClass = module.getClassLoader().loadClass(view.getViewClassName());
EJBViewDescription ejbView = (EJBViewDescription) view;
processTransactionAttributeAnnotation(applicationClasses, deploymentReflectionIndex, viewClass, ejbView.getMethodIntf(), componentConfiguration);
processTransactionTimeoutAnnotation(applicationClasses, deploymentReflectionIndex, viewClass, ejbView.getMethodIntf(), componentConfiguration);
} catch (ClassNotFoundException e) {
throw EjbLogger.ROOT_LOGGER.failToLoadEjbViewClass(e);
}
}
}
use of org.jboss.modules.Module in project wildfly by wildfly.
the class IIOPMarkerProcessor method undeploy.
@Override
public void undeploy(final DeploymentUnit context) {
//clear data from the relevant caches
Module module = context.getAttachment(Attachments.MODULE);
if (module == null) {
return;
}
ExceptionAnalysis.clearCache(module.getClassLoader());
InterfaceAnalysis.clearCache(module.getClassLoader());
ValueAnalysis.clearCache(module.getClassLoader());
}
use of org.jboss.modules.Module in project wildfly by wildfly.
the class GlobalConfigurationBuilder method getValue.
@Override
public GlobalConfiguration getValue() {
org.infinispan.configuration.global.GlobalConfigurationBuilder builder = new org.infinispan.configuration.global.GlobalConfigurationBuilder();
TransportConfiguration transport = this.transport.getValue();
// This fails due to ISPN-4755 !!
// this.builder.transport().read(this.transport.getValue());
// Workaround this by copying relevant fields individually
builder.transport().transport(transport.transport()).distributedSyncTimeout(transport.distributedSyncTimeout()).clusterName(transport.clusterName()).machineId(transport.machineId()).rackId(transport.rackId()).siteId(transport.siteId());
Module module = this.module.getValue();
builder.serialization().classResolver(ModularClassResolver.getInstance(this.loader.getValue()));
builder.classLoader(module.getClassLoader());
int id = Ids.MAX_ID;
for (Externalizer<?> externalizer : module.loadService(Externalizer.class)) {
InfinispanLogger.ROOT_LOGGER.debugf("Cache container %s will use an externalizer for %s", this.name, externalizer.getTargetClass().getName());
builder.serialization().addAdvancedExternalizer(id++, new AdvancedExternalizerAdapter<>(externalizer));
}
builder.transport().transportThreadPool().read(this.pools.get(ThreadPoolResourceDefinition.TRANSPORT).getValue());
builder.transport().remoteCommandThreadPool().read(this.pools.get(ThreadPoolResourceDefinition.REMOTE_COMMAND).getValue());
builder.asyncThreadPool().read(this.pools.get(ThreadPoolResourceDefinition.ASYNC_OPERATIONS).getValue());
builder.expirationThreadPool().read(this.schedulers.get(ScheduledThreadPoolResourceDefinition.EXPIRATION).getValue());
builder.listenerThreadPool().read(this.pools.get(ThreadPoolResourceDefinition.LISTENER).getValue());
builder.stateTransferThreadPool().read(this.pools.get(ThreadPoolResourceDefinition.STATE_TRANSFER).getValue());
builder.persistenceThreadPool().read(this.pools.get(ThreadPoolResourceDefinition.PERSISTENCE).getValue());
builder.shutdown().hookBehavior(ShutdownHookBehavior.DONT_REGISTER);
builder.globalJmxStatistics().enabled(this.statisticsEnabled).cacheManagerName(this.name).mBeanServerLookup(new MBeanServerProvider((this.server != null) ? this.server.getValue() : null)).jmxDomain("org.wildfly.clustering.infinispan").allowDuplicateDomains(true);
builder.site().read(this.site.getValue());
return builder.build();
}
Aggregations