Search in sources :

Example 56 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.

the class EjbJarDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
    if (!DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        return;
    }
    //cause this could come from a jboss-app.xml instead
    if (deploymentRoot.getRoot().getChild("META-INF/application.xml").exists()) {
        //if we have an application.xml we don't scan
        return;
    }
    // TODO: deal with application clients, we need the manifest information
    List<ResourceRoot> potentialSubDeployments = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
    for (ResourceRoot resourceRoot : potentialSubDeployments) {
        if (ModuleRootMarker.isModuleRoot(resourceRoot)) {
            // module roots cannot be ejb jars
            continue;
        }
        VirtualFile ejbJarFile = resourceRoot.getRoot().getChild("META-INF/ejb-jar.xml");
        if (ejbJarFile.exists()) {
            SubDeploymentMarker.mark(resourceRoot);
            ModuleRootMarker.mark(resourceRoot);
        } else {
            final Index index = resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX);
            if (index != null) {
                if (!index.getAnnotations(STATEFUL).isEmpty() || !index.getAnnotations(STATELESS).isEmpty() || !index.getAnnotations(MESSAGE_DRIVEN).isEmpty() || !index.getAnnotations(SINGLETON).isEmpty()) {
                    //this is an EJB deployment
                    //TODO: we need to mark EJB sub deployments so the sub deployers know they are EJB deployments
                    SubDeploymentMarker.mark(resourceRoot);
                    ModuleRootMarker.mark(resourceRoot);
                }
            }
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) Index(org.jboss.jandex.Index) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 57 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.

the class GlobalModuleDependencyProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final List<GlobalModule> globalMods = this.globalModules;
    for (final GlobalModule module : globalMods) {
        final ModuleDependency dependency = new ModuleDependency(Module.getBootModuleLoader(), module.getModuleIdentifier(), false, false, module.isServices(), false);
        if (module.isMetaInf()) {
            dependency.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(), true);
            dependency.addImportFilter(PathFilters.getMetaInfFilter(), true);
        }
        if (module.isAnnotations()) {
            deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES, module.getModuleIdentifier());
        }
        moduleSpecification.addSystemDependency(dependency);
    }
}
Also used : GlobalModule(org.jboss.as.ee.subsystem.GlobalModulesDefinition.GlobalModule) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 58 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.

the class EEJndiViewExtension method execute.

public void execute(final JndiViewExtensionContext context) throws OperationFailedException {
    final ModelNode applicationsNode = context.getResult().get("applications");
    final ServiceRegistry serviceRegistry = context.getOperationContext().getServiceRegistry(false);
    final Set<Resource.ResourceEntry> deploymentResource = context.getOperationContext().readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildren(DEPLOYMENT);
    for (final Resource.ResourceEntry entry : deploymentResource) {
        final ServiceController<?> deploymentUnitServiceController = serviceRegistry.getService(ServiceName.JBOSS.append("deployment", "unit", entry.getName()));
        if (deploymentUnitServiceController != null) {
            final ModelNode deploymentNode = applicationsNode.get(entry.getName());
            final DeploymentUnit deploymentUnit = DeploymentUnit.class.cast(deploymentUnitServiceController.getValue());
            final String appName = cleanName(deploymentUnit.getName());
            final ServiceName appContextName = ContextNames.contextServiceNameOfApplication(appName);
            final ServiceController<?> appContextController = serviceRegistry.getService(appContextName);
            if (appContextController != null) {
                final NamingStore appStore = NamingStore.class.cast(appContextController.getValue());
                try {
                    context.addEntries(deploymentNode.get("java:app"), new NamingContext(appStore, null));
                } catch (NamingException e) {
                    throw new OperationFailedException(e, new ModelNode().set(EeLogger.ROOT_LOGGER.failedToRead("java:app", appName)));
                }
            }
            if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
                final List<ResourceRoot> roots = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS);
                if (roots != null)
                    for (ResourceRoot root : roots) {
                        if (SubDeploymentMarker.isSubDeployment(root)) {
                            final ResourceRoot parentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
                            final String relativePath = root.getRoot().getPathNameRelativeTo(parentRoot.getRoot());
                            final ServiceName subDeploymentServiceName = Services.deploymentUnitName(deploymentUnit.getName(), relativePath);
                            final ServiceController<?> subDeploymentController = serviceRegistry.getService(subDeploymentServiceName);
                            if (subDeploymentController != null) {
                                final DeploymentUnit subDeploymentUnit = DeploymentUnit.class.cast(subDeploymentController.getValue());
                                handleModule(context, subDeploymentUnit, deploymentNode.get("modules"), serviceRegistry);
                            }
                        }
                    }
            } else {
                handleModule(context, deploymentUnit, deploymentNode.get("modules"), serviceRegistry);
            }
        }
    }
}
Also used : NamingStore(org.jboss.as.naming.NamingStore) Resource(org.jboss.as.controller.registry.Resource) OperationFailedException(org.jboss.as.controller.OperationFailedException) NamingContext(org.jboss.as.naming.NamingContext) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ServiceName(org.jboss.msc.service.ServiceName) NamingException(javax.naming.NamingException) ServiceController(org.jboss.msc.service.ServiceController) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 59 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.

the class JaxrsScanningProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!JaxrsDeploymentMarker.isJaxrsDeployment(deploymentUnit)) {
        return;
    }
    final DeploymentUnit parent = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
    final Map<ModuleIdentifier, ResteasyDeploymentData> deploymentData;
    if (deploymentUnit.getParent() == null) {
        deploymentData = Collections.synchronizedMap(new HashMap<ModuleIdentifier, ResteasyDeploymentData>());
        deploymentUnit.putAttachment(JaxrsAttachments.ADDITIONAL_RESTEASY_DEPLOYMENT_DATA, deploymentData);
    } else {
        deploymentData = parent.getAttachment(JaxrsAttachments.ADDITIONAL_RESTEASY_DEPLOYMENT_DATA);
    }
    final ModuleIdentifier moduleIdentifier = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);
    ResteasyDeploymentData resteasyDeploymentData = new ResteasyDeploymentData();
    final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    try {
        if (warMetaData == null) {
            resteasyDeploymentData.setScanAll(true);
            scan(deploymentUnit, module.getClassLoader(), resteasyDeploymentData);
            deploymentData.put(moduleIdentifier, resteasyDeploymentData);
        } else {
            scanWebDeployment(deploymentUnit, warMetaData.getMergedJBossWebMetaData(), module.getClassLoader(), resteasyDeploymentData);
            scan(deploymentUnit, module.getClassLoader(), resteasyDeploymentData);
        }
        deploymentUnit.putAttachment(JaxrsAttachments.RESTEASY_DEPLOYMENT_DATA, resteasyDeploymentData);
        List<String> rootRestClasses = new ArrayList<>(resteasyDeploymentData.getScannedResourceClasses());
        Collections.sort(rootRestClasses);
        for (String cls : rootRestClasses) {
            addManagement(deploymentUnit, cls);
        }
    } catch (ModuleLoadException e) {
        throw new DeploymentUnitProcessingException(e);
    }
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) HashMap(java.util.HashMap) WarMetaData(org.jboss.as.web.common.WarMetaData) ArrayList(java.util.ArrayList) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 60 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.

the class JaxrsSpringProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.getParent() != null) {
        return;
    }
    final List<DeploymentUnit> deploymentUnits = new ArrayList<DeploymentUnit>();
    deploymentUnits.add(deploymentUnit);
    deploymentUnits.addAll(deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS));
    boolean found = false;
    for (DeploymentUnit unit : deploymentUnits) {
        WarMetaData warMetaData = unit.getAttachment(WarMetaData.ATTACHMENT_KEY);
        if (warMetaData == null) {
            continue;
        }
        JBossWebMetaData md = warMetaData.getMergedJBossWebMetaData();
        if (md == null) {
            continue;
        }
        if (md.getContextParams() != null) {
            boolean skip = false;
            for (ParamValueMetaData prop : md.getContextParams()) {
                if (prop.getParamName().equals(ENABLE_PROPERTY)) {
                    boolean explicitEnable = Boolean.parseBoolean(prop.getParamValue());
                    if (explicitEnable) {
                        found = true;
                    } else {
                        skip = true;
                    }
                    break;
                } else if (prop.getParamName().equals(DISABLE_PROPERTY) && "true".equals(prop.getParamValue())) {
                    skip = true;
                    JaxrsLogger.JAXRS_LOGGER.disablePropertyDeprecated();
                    break;
                }
            }
            if (skip) {
                continue;
            }
        }
        if (md.getListeners() != null) {
            for (ListenerMetaData listener : md.getListeners()) {
                if (SPRING_LISTENER.equals(listener.getListenerClass())) {
                    found = true;
                    break;
                }
            }
        }
        if (md.getServlets() != null) {
            for (JBossServletMetaData servlet : md.getServlets()) {
                if (SPRING_SERVLET.equals(servlet.getServletClass())) {
                    found = true;
                    break;
                }
            }
        }
        if (found) {
            try {
                // actual close is done by the MSC service above
                MountHandle mh = new MountHandle(null);
                ResourceRoot resourceRoot = new ResourceRoot(getResteasySpringVirtualFile(), mh);
                ModuleRootMarker.mark(resourceRoot);
                deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, resourceRoot);
            } catch (Exception e) {
                throw new DeploymentUnitProcessingException(e);
            }
            return;
        }
    }
}
Also used : ParamValueMetaData(org.jboss.metadata.javaee.spec.ParamValueMetaData) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) MountHandle(org.jboss.as.server.deployment.module.MountHandle) JBossServletMetaData(org.jboss.metadata.web.jboss.JBossServletMetaData) ArrayList(java.util.ArrayList) WarMetaData(org.jboss.as.web.common.WarMetaData) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) StartException(org.jboss.msc.service.StartException) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ListenerMetaData(org.jboss.metadata.web.spec.ListenerMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)271 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)77 Module (org.jboss.modules.Module)58 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)49 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)44 ServiceName (org.jboss.msc.service.ServiceName)44 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)43 ArrayList (java.util.ArrayList)33 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)32 VirtualFile (org.jboss.vfs.VirtualFile)30 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)29 WarMetaData (org.jboss.as.web.common.WarMetaData)25 ServiceTarget (org.jboss.msc.service.ServiceTarget)25 HashMap (java.util.HashMap)24 HashSet (java.util.HashSet)24 ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)24 ModuleLoader (org.jboss.modules.ModuleLoader)24 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)20 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)19 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)17