Search in sources :

Example 71 with VirtualFile

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

the class ScannerTest method testJarProtocol.

@Test
public void testJarProtocol() throws Exception {
    File war = buildWar();
    addPackageToClasspath(war);
    final VirtualFile warVirtualFile = VFS.getChild(war.getAbsolutePath());
    Closeable closeable = VFS.mountZip(warVirtualFile, warVirtualFile, tempFileProvider);
    try {
        ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor(warVirtualFile.toURL());
        AbstractScannerImpl.ResultCollector resultCollector = new AbstractScannerImpl.ResultCollector(new StandardScanOptions());
        archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(new PersistenceUnitDescriptorAdapter(), true, resultCollector));
        validateResults(resultCollector, org.hibernate.jpa.test.pack.war.ApplicationServer.class, org.hibernate.jpa.test.pack.war.Version.class);
    } 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 72 with VirtualFile

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

the class IronJacamarDeploymentParsingProcessor method process.

public static IronJacamarXmlDescriptor process(VirtualFile deploymentRoot, boolean resolveProperties) throws DeploymentUnitProcessingException {
    IronJacamarXmlDescriptor xmlDescriptor = null;
    if (deploymentRoot == null || !deploymentRoot.exists())
        return null;
    final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH);
    VirtualFile serviceXmlFile = null;
    if (deploymentRootName.endsWith(".rar")) {
        serviceXmlFile = deploymentRoot.getChild("/META-INF/ironjacamar.xml");
    }
    if (serviceXmlFile == null || !serviceXmlFile.exists())
        return null;
    InputStream xmlStream = null;
    Activation result = null;
    try {
        xmlStream = serviceXmlFile.openStream();
        IronJacamarParser ironJacamarParser = new IronJacamarParser();
        ironJacamarParser.setSystemPropertiesResolved(resolveProperties);
        result = ironJacamarParser.parse(xmlStream);
        if (result != null) {
            xmlDescriptor = new IronJacamarXmlDescriptor(result);
        } else
            throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(serviceXmlFile);
    } catch (Exception e) {
        throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(e, serviceXmlFile);
    } finally {
        VFSUtils.safeClose(xmlStream);
    }
    return xmlDescriptor;
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) IronJacamarParser(org.jboss.as.connector.metadata.ironjacamar.IronJacamarParser) InputStream(java.io.InputStream) Activation(org.jboss.jca.common.api.metadata.resourceadapter.Activation) IronJacamarXmlDescriptor(org.jboss.as.connector.metadata.xmldescriptors.IronJacamarXmlDescriptor) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

Example 73 with VirtualFile

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

the class RaDeploymentParsingProcessor method process.

public static ConnectorXmlDescriptor process(boolean resolveProperties, VirtualFile file, VirtualFile alternateDescriptor, String deploymentName) throws DeploymentUnitProcessingException {
    // Locate the descriptor
    final VirtualFile serviceXmlFile;
    if (alternateDescriptor != null) {
        serviceXmlFile = alternateDescriptor;
    } else {
        serviceXmlFile = file.getChild("/META-INF/ra.xml");
    }
    InputStream xmlStream = null;
    Connector result = null;
    try {
        if (serviceXmlFile != null && serviceXmlFile.exists()) {
            xmlStream = serviceXmlFile.openStream();
            RaParser raParser = new RaParser();
            raParser.setSystemPropertiesResolved(resolveProperties);
            result = raParser.parse(xmlStream);
            if (result == null)
                throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(serviceXmlFile);
        }
        File root = file.getPhysicalFile();
        URL url = root.toURI().toURL();
        return new ConnectorXmlDescriptor(result, root, url, deploymentName);
    } catch (Exception e) {
        throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(e, serviceXmlFile);
    } finally {
        VFSUtils.safeClose(xmlStream);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) Connector(org.jboss.jca.common.api.metadata.spec.Connector) RaParser(org.jboss.jca.common.metadata.spec.RaParser) InputStream(java.io.InputStream) ConnectorXmlDescriptor(org.jboss.as.connector.metadata.xmldescriptors.ConnectorXmlDescriptor) File(java.io.File) VirtualFile(org.jboss.vfs.VirtualFile) URL(java.net.URL) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

Example 74 with VirtualFile

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

the class DsXmlDeploymentParsingProcessor 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();
    boolean resolveProperties = Util.shouldResolveJBoss(deploymentUnit);
    final PropertyResolver propertyResolver = deploymentUnit.getAttachment(org.jboss.as.ee.metadata.property.Attachments.FINAL_PROPERTY_RESOLVER);
    final PropertyReplacer propertyReplacer = deploymentUnit.getAttachment(org.jboss.as.ee.metadata.property.Attachments.FINAL_PROPERTY_REPLACER);
    final Set<VirtualFile> files = dataSources(deploymentUnit);
    boolean loggedDeprication = false;
    for (VirtualFile f : files) {
        InputStream xmlStream = null;
        try {
            xmlStream = new FileInputStream(f.getPhysicalFile());
            DsXmlParser parser = new DsXmlParser(propertyResolver, propertyReplacer);
            parser.setSystemPropertiesResolved(resolveProperties);
            DataSources dataSources = parser.parse(xmlStream);
            if (dataSources != null) {
                if (!loggedDeprication) {
                    loggedDeprication = true;
                    ConnectorLogger.ROOT_LOGGER.deprecated();
                }
                for (DataSource ds : dataSources.getDataSource()) {
                    if (ds.getDriver() == null) {
                        throw ConnectorLogger.ROOT_LOGGER.FailedDeployDriverNotSpecified(ds.getJndiName());
                    }
                }
                deploymentUnit.addToAttachmentList(DATA_SOURCES_ATTACHMENT_KEY, dataSources);
            }
        } catch (Exception e) {
            throw new DeploymentUnitProcessingException(e.getMessage(), e);
        } finally {
            VFSUtils.safeClose(xmlStream);
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) PropertyResolver(org.jboss.metadata.property.PropertyResolver) FileInputStream(java.io.FileInputStream) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) DataSource(org.jboss.jca.common.api.metadata.ds.DataSource) DataSources(org.jboss.jca.common.api.metadata.ds.DataSources) DsXmlParser(org.jboss.as.connector.deployers.ds.DsXmlParser) PropertyReplacer(org.jboss.metadata.property.PropertyReplacer) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 75 with VirtualFile

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

the class RaNativeProcessor method process.

public static void process(VirtualFile deploymentRoot) throws DeploymentUnitProcessingException {
    if (deploymentRoot == null || !deploymentRoot.exists())
        return;
    final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH);
    if (!deploymentRootName.endsWith(".rar")) {
        return;
    }
    try {
        List<VirtualFile> libs = deploymentRoot.getChildrenRecursively(new LibraryFilter());
        if (libs != null && libs.size() > 0) {
            for (VirtualFile vf : libs) {
                String fileName = vf.getName().toLowerCase(Locale.ENGLISH);
                ROOT_LOGGER.tracef("Processing library: %s", fileName);
                try {
                    File f = vf.getPhysicalFile();
                    System.load(f.getAbsolutePath());
                    ROOT_LOGGER.debugf("Loaded library: %s", f.getAbsolutePath());
                } catch (Throwable t) {
                    ROOT_LOGGER.debugf("Unable to load library: %s", fileName);
                }
            }
        }
    } catch (Exception e) {
        throw ConnectorLogger.ROOT_LOGGER.failedToLoadNativeLibraries(e);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) VirtualFile(org.jboss.vfs.VirtualFile) File(java.io.File) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

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