Search in sources :

Example 26 with ResourceRoot

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

the class ApplicationClientStructureProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    String deploymentUnitName = deploymentUnit.getName().toLowerCase(Locale.ENGLISH);
    if (deploymentUnitName.endsWith(".ear")) {
        final Map<VirtualFile, ResourceRoot> existing = new HashMap<VirtualFile, ResourceRoot>();
        for (final ResourceRoot additional : deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS)) {
            existing.put(additional.getRoot(), additional);
        }
        final ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        final VirtualFile appClientRoot = root.getRoot().getChild(deployment);
        if (appClientRoot.exists()) {
            if (existing.containsKey(appClientRoot)) {
                final ResourceRoot existingRoot = existing.get(appClientRoot);
                SubDeploymentMarker.mark(existingRoot);
                ModuleRootMarker.mark(existingRoot);
            } else {
                final Closeable closable = appClientRoot.isFile() ? mount(appClientRoot, false) : null;
                final MountHandle mountHandle = new MountHandle(closable);
                final ResourceRoot childResource = new ResourceRoot(appClientRoot, mountHandle);
                ModuleRootMarker.mark(childResource);
                SubDeploymentMarker.mark(childResource);
                deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, childResource);
            }
        } else {
            throw AppClientLogger.ROOT_LOGGER.cannotFindAppClient(deployment);
        }
    } else if (deploymentUnit.getParent() != null && deploymentUnitName.endsWith(".jar")) {
        final ResourceRoot parentRoot = deploymentUnit.getParent().getAttachment(Attachments.DEPLOYMENT_ROOT);
        final VirtualFile appClientRoot = parentRoot.getRoot().getChild(deployment);
        final ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        if (appClientRoot.equals(root.getRoot())) {
            DeploymentTypeMarker.setType(DeploymentType.APPLICATION_CLIENT, deploymentUnit);
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) HashMap(java.util.HashMap) MountHandle(org.jboss.as.server.deployment.module.MountHandle) Closeable(java.io.Closeable) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 27 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot 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 28 with ResourceRoot

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

the class ApplicationClientParsingDeploymentProcessor method parseAppClient.

private ApplicationClientMetaData parseAppClient(DeploymentUnit deploymentUnit, final PropertyReplacer propertyReplacer) throws DeploymentUnitProcessingException {
    final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    final VirtualFile alternateDescriptor = deploymentRoot.getAttachment(org.jboss.as.ee.structure.Attachments.ALTERNATE_CLIENT_DEPLOYMENT_DESCRIPTOR);
    // Locate the descriptor
    final VirtualFile descriptor;
    if (alternateDescriptor != null) {
        descriptor = alternateDescriptor;
    } else {
        descriptor = deploymentRoot.getRoot().getChild(APP_XML);
    }
    if (descriptor.exists()) {
        InputStream is = null;
        try {
            is = descriptor.openStream();
            ApplicationClientMetaData data = new ApplicationClientMetaDataParser().parse(getXMLStreamReader(is), propertyReplacer);
            return data;
        } catch (XMLStreamException e) {
            throw AppClientLogger.ROOT_LOGGER.failedToParseXml(e, descriptor, e.getLocation().getLineNumber(), e.getLocation().getColumnNumber());
        } catch (IOException e) {
            throw new DeploymentUnitProcessingException("Failed to parse " + descriptor, e);
        } finally {
            try {
                if (is != null) {
                    is.close();
                }
            } catch (IOException e) {
            // Ignore
            }
        }
    } else {
        return null;
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) XMLStreamException(javax.xml.stream.XMLStreamException) InputStream(java.io.InputStream) ApplicationClientMetaData(org.jboss.metadata.appclient.spec.ApplicationClientMetaData) IOException(java.io.IOException) ApplicationClientMetaDataParser(org.jboss.metadata.appclient.parser.spec.ApplicationClientMetaDataParser)

Example 29 with ResourceRoot

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

the class EjbDependsOnMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription description) throws DeploymentUnitProcessingException {
    final EEApplicationDescription applicationDescription = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_DESCRIPTION);
    final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
    if (description.getDescriptorData() instanceof SessionBean31MetaData) {
        SessionBean31MetaData metaData = (SessionBean31MetaData) description.getDescriptorData();
        if (metaData.getDependsOn() != null) {
            setupDependencies(description, applicationDescription, deploymentRoot, metaData.getDependsOn());
        }
    }
}
Also used : EEApplicationDescription(org.jboss.as.ee.component.EEApplicationDescription) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) SessionBean31MetaData(org.jboss.metadata.ejb.spec.SessionBean31MetaData)

Example 30 with ResourceRoot

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

the class RaStructureProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ResourceRoot resourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    if (resourceRoot == null) {
        return;
    }
    final VirtualFile deploymentRoot = resourceRoot.getRoot();
    if (deploymentRoot == null || !deploymentRoot.exists()) {
        return;
    }
    final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH);
    if (!deploymentRootName.endsWith(RAR_EXTENSION)) {
        return;
    }
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    moduleSpecification.setPublicModule(true);
    //this violates the spec, but everyone expects it to work
    ModuleRootMarker.mark(resourceRoot, true);
    Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS);
    try {
        final List<VirtualFile> childArchives = deploymentRoot.getChildren(CHILD_ARCHIVE_FILTER);
        for (final VirtualFile child : childArchives) {
            String relativeName = child.getPathNameRelativeTo(deploymentRoot);
            MountedDeploymentOverlay overlay = overlays.get(relativeName);
            Closeable closable = NO_OP_CLOSEABLE;
            if (overlay != null) {
                overlay.remountAsZip(false);
            } else if (child.isFile()) {
                closable = VFS.mountZip(child, child, TempFileProviderService.provider());
            }
            final MountHandle mountHandle = new MountHandle(closable);
            final ResourceRoot childResource = new ResourceRoot(child, mountHandle);
            ModuleRootMarker.mark(childResource);
            deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, childResource);
            resourceRoot.addToAttachmentList(Attachments.INDEX_IGNORE_PATHS, child.getPathNameRelativeTo(deploymentRoot));
        }
    } catch (IOException e) {
        throw ConnectorLogger.ROOT_LOGGER.failedToProcessRaChild(e, deploymentRoot);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) MountedDeploymentOverlay(org.jboss.as.server.deployment.MountedDeploymentOverlay) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) MountHandle(org.jboss.as.server.deployment.module.MountHandle) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) Closeable(java.io.Closeable) IOException(java.io.IOException) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)71 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)49 VirtualFile (org.jboss.vfs.VirtualFile)37 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)16 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)12 HashMap (java.util.HashMap)10 PersistenceUnitMetadataHolder (org.jboss.as.jpa.config.PersistenceUnitMetadataHolder)10 WarMetaData (org.jboss.as.web.common.WarMetaData)10 MountHandle (org.jboss.as.server.deployment.module.MountHandle)9 Index (org.jboss.jandex.Index)8 Closeable (java.io.Closeable)7 URL (java.net.URL)7 HashSet (java.util.HashSet)7 Module (org.jboss.modules.Module)7 InputStream (java.io.InputStream)6 EarMetaData (org.jboss.metadata.ear.spec.EarMetaData)6 ServiceName (org.jboss.msc.service.ServiceName)6 XMLStreamException (javax.xml.stream.XMLStreamException)5 EEApplicationDescription (org.jboss.as.ee.component.EEApplicationDescription)5