Search in sources :

Example 6 with ModuleMetaData

use of org.jboss.metadata.ear.spec.ModuleMetaData in project wildfly by wildfly.

the class ApplicationClientDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        List<ResourceRoot> potentialSubDeployments = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
        for (ResourceRoot resourceRoot : potentialSubDeployments) {
            if (ModuleRootMarker.isModuleRoot(resourceRoot)) {
                // module roots cannot be ejb jars
                continue;
            }
            VirtualFile appclientClientXml = resourceRoot.getRoot().getChild(META_INF_APPLICATION_CLIENT_XML);
            if (appclientClientXml.exists()) {
                SubDeploymentMarker.mark(resourceRoot);
                ModuleRootMarker.mark(resourceRoot);
            } else {
                final Manifest manifest = resourceRoot.getAttachment(Attachments.MANIFEST);
                if (manifest != null) {
                    Attributes main = manifest.getMainAttributes();
                    if (main != null) {
                        String mainClass = main.getValue("Main-Class");
                        if (mainClass != null && !mainClass.isEmpty()) {
                            SubDeploymentMarker.mark(resourceRoot);
                            ModuleRootMarker.mark(resourceRoot);
                        }
                    }
                }
            }
        }
    } else if (deploymentUnit.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
        final ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        final ModuleMetaData md = root.getAttachment(org.jboss.as.ee.structure.Attachments.MODULE_META_DATA);
        if (md != null) {
            if (md.getType() == ModuleMetaData.ModuleType.Client) {
                DeploymentTypeMarker.setType(DeploymentType.APPLICATION_CLIENT, deploymentUnit);
            }
        } else {
            VirtualFile appclientClientXml = root.getRoot().getChild(META_INF_APPLICATION_CLIENT_XML);
            if (appclientClientXml.exists()) {
                DeploymentTypeMarker.setType(DeploymentType.APPLICATION_CLIENT, deploymentUnit);
            } else {
                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()) {
                            DeploymentTypeMarker.setType(DeploymentType.APPLICATION_CLIENT, deploymentUnit);
                        }
                    }
                }
            }
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) Attributes(java.util.jar.Attributes) Manifest(java.util.jar.Manifest) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) ModuleMetaData(org.jboss.metadata.ear.spec.ModuleMetaData)

Aggregations

DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)6 ModuleMetaData (org.jboss.metadata.ear.spec.ModuleMetaData)6 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)5 EarMetaData (org.jboss.metadata.ear.spec.EarMetaData)4 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 WebModuleMetaData (org.jboss.metadata.ear.spec.WebModuleMetaData)2 VirtualFile (org.jboss.vfs.VirtualFile)2 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Attributes (java.util.jar.Attributes)1 Manifest (java.util.jar.Manifest)1 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)1 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)1 PersistenceUnitMetadataHolder (org.jboss.as.jpa.config.PersistenceUnitMetadataHolder)1 PersistenceUnitsInApplication (org.jboss.as.jpa.config.PersistenceUnitsInApplication)1 MountedDeploymentOverlay (org.jboss.as.server.deployment.MountedDeploymentOverlay)1 MountHandle (org.jboss.as.server.deployment.module.MountHandle)1 WarMetaData (org.jboss.as.web.common.WarMetaData)1