Search in sources :

Example 41 with Module

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;
}
Also used : JobXmlResolver(org.jberet.spi.JobXmlResolver) BatchLogger(org.wildfly.extension.batch.jberet._private.BatchLogger) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) DeploymentTypeMarker(org.jboss.as.ee.structure.DeploymentTypeMarker) SubDeploymentMarker(org.jboss.as.server.deployment.SubDeploymentMarker) ArrayList(java.util.ArrayList) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) XMLStreamException(javax.xml.stream.XMLStreamException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) VirtualFile(org.jboss.vfs.VirtualFile) XMLResolver(javax.xml.stream.XMLResolver) LinkedHashSet(java.util.LinkedHashSet) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) ServiceLoader(java.util.ServiceLoader) PrivilegedAction(java.security.PrivilegedAction) Collectors(java.util.stream.Collectors) List(java.util.List) WildFlySecurityManager(org.wildfly.security.manager.WildFlySecurityManager) Module(org.jboss.modules.Module) DeploymentType(org.jboss.as.ee.structure.DeploymentType) JobParser(org.jberet.job.model.JobParser) Attachments(org.jboss.as.server.deployment.Attachments) VirtualFileFilter(org.jboss.vfs.VirtualFileFilter) Job(org.jberet.job.model.Job) AccessController(java.security.AccessController) Collections(java.util.Collections) InputStream(java.io.InputStream) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 42 with Module

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);
                }
            }
        }
    }
}
Also used : ApplicationClientComponentDescription(org.jboss.as.appclient.component.ApplicationClientComponentDescription) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) Attributes(java.util.jar.Attributes) Module(org.jboss.modules.Module) Manifest(java.util.jar.Manifest) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 43 with Module

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);
        }
    }
}
Also used : EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) Module(org.jboss.modules.Module)

Example 44 with Module

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());
}
Also used : Module(org.jboss.modules.Module)

Example 45 with Module

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();
}
Also used : TransportConfiguration(org.infinispan.configuration.global.TransportConfiguration) Module(org.jboss.modules.Module) MBeanServerProvider(org.jboss.as.clustering.infinispan.MBeanServerProvider)

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