use of org.jboss.modules.Module in project wildfly by wildfly.
the class DevelopmentModeProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
if (!WeldDeploymentMarker.isWeldDeployment(deploymentUnit)) {
// skip non weld deployments
return;
}
// probe module is available
if (!Reflections.isAccessible(PROBE_FILTER_CLASS_NAME, module.getClassLoader())) {
return;
}
final WeldConfiguration configuration = Utils.getRootDeploymentUnit(deploymentUnit).getAttachment(WeldConfiguration.ATTACHMENT_KEY);
// if development mode disabled then check war CONTEXT_PARAM_DEV_MODE and if available then register ProbeFilter and ProbeExtension
if (!configuration.isDevelopmentMode()) {
if (deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY) == null) {
return;
}
if (DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
final JBossWebMetaData webMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY).getMergedJBossWebMetaData();
if (webMetaData == null) {
return;
}
if (webMetaData.getContextParams() == null) {
return;
}
final boolean devModeContextParam = webMetaData.getContextParams().stream().anyMatch(param -> CONTEXT_PARAM_DEV_MODE.equals(param.getParamName()) && Boolean.valueOf(param.getParamValue()));
if (!devModeContextParam) {
return;
}
registerProbeFilter(deploymentUnit, webMetaData);
WeldPortableExtensions.getPortableExtensions(deploymentUnit).tryRegisterExtension(loadClass(PROBE_EXTENSION_CLASS_NAME, module.getClassLoader()), deploymentUnit);
}
// if development mode enabled then for WAR register ProbeFilter and register ProbeExtension for every deployment
} else {
if (DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
if (deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY) == null) {
return;
}
final JBossWebMetaData webMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY).getMergedJBossWebMetaData();
if (webMetaData == null) {
return;
}
registerProbeFilter(deploymentUnit, webMetaData);
}
WeldPortableExtensions.getPortableExtensions(deploymentUnit).tryRegisterExtension(loadClass(PROBE_EXTENSION_CLASS_NAME, module.getClassLoader()), deploymentUnit);
}
}
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());
}
Aggregations