Search in sources :

Example 36 with VirtualFile

use of org.jboss.vfs.VirtualFile 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)

Example 37 with VirtualFile

use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.

the class StructureDriverProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
    for (ResourceRoot resourceRoot : resourceRoots) {
        final VirtualFile deploymentRoot = resourceRoot.getRoot();
        if (deploymentRoot.getChild("META-INF/services/java.sql.Driver").exists()) {
            DEPLOYER_JDBC_LOGGER.debugf("SQL driver detected: %s", deploymentUnit.getName());
            break;
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 38 with VirtualFile

use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.

the class IronJacamarDeploymentParsingProcessor method deploy.

/**
     * Process a deployment for iron-jacamar.xml files. Will parse the xml file
     * and attach metadata discovered during processing.
     *
     * @param phaseContext the deployment unit context
     * @throws DeploymentUnitProcessingException
     */
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ResourceRoot resourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    final VirtualFile deploymentRoot = resourceRoot.getRoot();
    final boolean resolveProperties = Util.shouldResolveJBoss(deploymentUnit);
    IronJacamarXmlDescriptor xmlDescriptor = process(deploymentRoot, resolveProperties);
    if (xmlDescriptor != null) {
        deploymentUnit.putAttachment(IronJacamarXmlDescriptor.ATTACHMENT_KEY, xmlDescriptor);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) IronJacamarXmlDescriptor(org.jboss.as.connector.metadata.xmldescriptors.IronJacamarXmlDescriptor) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 39 with VirtualFile

use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.

the class RaDeploymentParsingProcessor method deploy.

/**
     * Process a deployment for standard ra deployment files. Will parse the xml
     * file and attach a configuration discovered during processing.
     *
     * @param phaseContext the deployment unit context
     * @throws DeploymentUnitProcessingException
     *
     */
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    final boolean resolveProperties = Util.shouldResolveSpec(deploymentUnit);
    final VirtualFile file = deploymentRoot.getRoot();
    if (file == null || !file.exists())
        return;
    final String deploymentRootName = file.getName().toLowerCase(Locale.ENGLISH);
    if (!deploymentRootName.endsWith(".rar")) {
        return;
    }
    final VirtualFile alternateDescriptor = deploymentRoot.getAttachment(org.jboss.as.ee.structure.Attachments.ALTERNATE_CONNECTOR_DEPLOYMENT_DESCRIPTOR);
    String prefix = "";
    if (deploymentUnit.getParent() != null) {
        prefix = deploymentUnit.getParent().getName() + "#";
    }
    String deploymentName = prefix + file.getName();
    ConnectorXmlDescriptor xmlDescriptor = process(resolveProperties, file, alternateDescriptor, deploymentName);
    phaseContext.getDeploymentUnit().putAttachment(ConnectorXmlDescriptor.ATTACHMENT_KEY, xmlDescriptor);
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ConnectorXmlDescriptor(org.jboss.as.connector.metadata.xmldescriptors.ConnectorXmlDescriptor) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 40 with VirtualFile

use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.

the class JSFManagedBeanProcessor method getConfigurationFiles.

public Set<VirtualFile> getConfigurationFiles(DeploymentUnit deploymentUnit) {
    final Set<VirtualFile> ret = new HashSet<VirtualFile>();
    final List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
    for (final ResourceRoot resourceRoot : resourceRoots) {
        final VirtualFile webInfFacesConfig = resourceRoot.getRoot().getChild(WEB_INF_FACES_CONFIG);
        if (webInfFacesConfig.exists()) {
            ret.add(webInfFacesConfig);
        }
        //look for files that end in .faces-config.xml
        final VirtualFile metaInf = resourceRoot.getRoot().getChild("META-INF");
        if (metaInf.exists() && metaInf.isDirectory()) {
            for (final VirtualFile file : metaInf.getChildren()) {
                if (file.getName().equals("faces-config.xml") || file.getName().endsWith(".faces-config.xml")) {
                    ret.add(file);
                }
            }
        }
    }
    String configFiles = null;
    //now look for files in the javax.faces.CONFIG_FILES context param
    final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    if (warMetaData != null) {
        final WebMetaData webMetaData = warMetaData.getWebMetaData();
        if (webMetaData != null) {
            final List<ParamValueMetaData> contextParams = webMetaData.getContextParams();
            if (contextParams != null) {
                for (final ParamValueMetaData param : contextParams) {
                    if (param.getParamName().equals(CONFIG_FILES)) {
                        configFiles = param.getParamValue();
                        break;
                    }
                }
            }
        }
    }
    if (configFiles != null) {
        final String[] files = configFiles.split(",");
        final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        if (deploymentRoot != null) {
            for (final String file : files) {
                final VirtualFile configFile = deploymentRoot.getRoot().getChild(file);
                if (configFile.exists()) {
                    ret.add(configFile);
                }
            }
        }
    }
    return ret;
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ParamValueMetaData(org.jboss.metadata.javaee.spec.ParamValueMetaData) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) WarMetaData(org.jboss.as.web.common.WarMetaData) WebMetaData(org.jboss.metadata.web.spec.WebMetaData) HashSet(java.util.HashSet)

Aggregations

VirtualFile (org.jboss.vfs.VirtualFile)93 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)36 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)29 InputStream (java.io.InputStream)28 IOException (java.io.IOException)23 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)22 Test (org.junit.Test)18 File (java.io.File)16 Closeable (java.io.Closeable)12 URI (java.net.URI)10 HashSet (java.util.HashSet)10 XMLStreamReader (javax.xml.stream.XMLStreamReader)10 Index (org.jboss.jandex.Index)10 SuffixMatchFilter (org.jboss.vfs.util.SuffixMatchFilter)10 ArrayList (java.util.ArrayList)9 XMLStreamException (javax.xml.stream.XMLStreamException)9 WarMetaData (org.jboss.as.web.common.WarMetaData)9 Indexer (org.jboss.jandex.Indexer)8 AnnotationRepository (org.jboss.jca.common.spi.annotations.repository.AnnotationRepository)8 XMLInputFactory (javax.xml.stream.XMLInputFactory)7