Search in sources :

Example 6 with VirtualFile

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

the class ScannerTest method testNestedJarProtocol.

@Test
public void testNestedJarProtocol() throws Exception {
    File defaultPar = buildDefaultPar();
    File nestedEar = buildNestedEar(defaultPar);
    addPackageToClasspath(nestedEar);
    final VirtualFile nestedEarVirtualFile = VFS.getChild(nestedEar.getAbsolutePath());
    Closeable closeable = VFS.mountZip(nestedEarVirtualFile, nestedEarVirtualFile, tempFileProvider);
    try {
        VirtualFile parVirtualFile = nestedEarVirtualFile.getChild("defaultpar.par");
        Closeable closeable2 = VFS.mountZip(parVirtualFile, parVirtualFile, tempFileProvider);
        try {
            ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor(parVirtualFile.toURL());
            AbstractScannerImpl.ResultCollector resultCollector = new AbstractScannerImpl.ResultCollector(new StandardScanOptions());
            archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(new PersistenceUnitDescriptorAdapter(), true, resultCollector));
            validateResults(resultCollector, ApplicationServer.class, Version.class);
        } finally {
            closeable2.close();
        }
    } finally {
        closeable.close();
    }
    File nestedEarDir = buildNestedEarDir(defaultPar);
    final VirtualFile nestedEarDirVirtualFile = VFS.getChild(nestedEarDir.getAbsolutePath());
    try {
        VirtualFile parVirtualFile = nestedEarDirVirtualFile.getChild("defaultpar.par");
        closeable = VFS.mountZip(parVirtualFile, parVirtualFile, tempFileProvider);
        try {
            ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor(parVirtualFile.toURL());
            AbstractScannerImpl.ResultCollector resultCollector = new AbstractScannerImpl.ResultCollector(new StandardScanOptions());
            archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(new PersistenceUnitDescriptorAdapter(), true, resultCollector));
            validateResults(resultCollector, ApplicationServer.class, Version.class);
        } finally {
            closeable.close();
        }
    } finally {
        closeable.close();
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) AbstractScannerImpl(org.hibernate.jpa.boot.scan.spi.AbstractScannerImpl) Closeable(java.io.Closeable) ArchiveDescriptor(org.hibernate.jpa.boot.archive.spi.ArchiveDescriptor) VirtualFile(org.jboss.vfs.VirtualFile) File(java.io.File) StandardScanOptions(org.hibernate.jpa.boot.scan.internal.StandardScanOptions) Test(org.junit.Test)

Example 7 with VirtualFile

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

the class MessagingXmlParsingDeploymentUnitProcessor method messageDestinations.

private Set<VirtualFile> messageDestinations(final DeploymentUnit deploymentUnit) {
    final VirtualFile deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
    if (deploymentRoot == null || !deploymentRoot.exists()) {
        return Collections.emptySet();
    }
    final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH);
    if (deploymentRootName.endsWith("-jms.xml")) {
        return Collections.singleton(deploymentRoot);
    }
    final Set<VirtualFile> ret = new HashSet<VirtualFile>();
    for (String location : LOCATIONS) {
        final VirtualFile loc = deploymentRoot.getChild(location);
        if (loc.exists()) {
            for (final VirtualFile file : loc.getChildren()) {
                if (file.getName().endsWith("-jms.xml")) {
                    ret.add(file);
                }
            }
        }
    }
    return ret;
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) HashSet(java.util.HashSet)

Example 8 with VirtualFile

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

the class KernelDeploymentParsingProcessor method deploy.

/**
     * Process a deployment for jboss-beans.xml 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 {
    DeploymentUnit unit = phaseContext.getDeploymentUnit();
    if (unit.hasAttachment(Attachments.OSGI_MANIFEST))
        return;
    final VirtualFile deploymentRoot = unit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
    parseDescriptors(unit, deploymentRoot);
    final List<ResourceRoot> resourceRoots = unit.getAttachmentList(Attachments.RESOURCE_ROOTS);
    for (ResourceRoot root : resourceRoots) parseDescriptors(unit, root.getRoot());
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 9 with VirtualFile

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

the class PersistenceUnitParseProcessor method handleJarDeployment.

private void handleJarDeployment(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!isEarDeployment(deploymentUnit) && !isWarDeployment(deploymentUnit) && (!appClientContainerMode || DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit))) {
        // handle META-INF/persistence.xml
        // ordered list of PUs
        List<PersistenceUnitMetadataHolder> listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1);
        // handle META-INF/persistence.xml
        final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        VirtualFile persistence_xml = deploymentRoot.getRoot().getChild(META_INF_PERSISTENCE_XML);
        parse(persistence_xml, listPUHolders, deploymentUnit);
        PersistenceUnitMetadataHolder holder = normalize(listPUHolders);
        // save the persistent unit definitions
        // deploymentUnit.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder);
        deploymentRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder);
        markDU(holder, deploymentUnit);
        ROOT_LOGGER.tracef("parsed persistence unit definitions for jar %s", deploymentRoot.getRootName());
        incrementPersistenceUnitCount(deploymentUnit, holder.getPersistenceUnits().size());
        addApplicationDependenciesOnProvider(deploymentUnit, holder);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) PersistenceUnitMetadataHolder(org.jboss.as.jpa.config.PersistenceUnitMetadataHolder) ArrayList(java.util.ArrayList) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 10 with VirtualFile

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

the class PersistenceUnitParseProcessor method handleWarDeployment.

private void handleWarDeployment(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!appClientContainerMode && isWarDeployment(deploymentUnit)) {
        int puCount;
        // ordered list of PUs
        List<PersistenceUnitMetadataHolder> listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1);
        // handle WEB-INF/classes/META-INF/persistence.xml
        final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        VirtualFile persistence_xml = deploymentRoot.getRoot().getChild(WEB_PERSISTENCE_XML);
        parse(persistence_xml, listPUHolders, deploymentUnit);
        PersistenceUnitMetadataHolder holder = normalize(listPUHolders);
        deploymentRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder);
        addApplicationDependenciesOnProvider(deploymentUnit, holder);
        markDU(holder, deploymentUnit);
        puCount = holder.getPersistenceUnits().size();
        // look for persistence.xml in jar files in the META-INF/persistence.xml directory (these are not currently
        // handled as subdeployments)
        List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
        for (ResourceRoot resourceRoot : resourceRoots) {
            if (resourceRoot.getRoot().getName().toLowerCase(Locale.ENGLISH).endsWith(JAR_FILE_EXTENSION)) {
                listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1);
                persistence_xml = resourceRoot.getRoot().getChild(META_INF_PERSISTENCE_XML);
                parse(persistence_xml, listPUHolders, deploymentUnit);
                holder = normalize(listPUHolders);
                resourceRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder);
                addApplicationDependenciesOnProvider(deploymentUnit, holder);
                markDU(holder, deploymentUnit);
                puCount += holder.getPersistenceUnits().size();
            }
        }
        ROOT_LOGGER.tracef("parsed persistence unit definitions for war %s", deploymentRoot.getRootName());
        incrementPersistenceUnitCount(deploymentUnit, puCount);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) PersistenceUnitMetadataHolder(org.jboss.as.jpa.config.PersistenceUnitMetadataHolder) ArrayList(java.util.ArrayList) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

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