Search in sources :

Example 1 with ModuleDescriptor

use of org.glassfish.deployment.common.ModuleDescriptor in project Payara by payara.

the class WebTest method getAbstractArchiveUri.

protected String getAbstractArchiveUri(WebBundleDescriptor desc) {
    String archBase = getVerifierContext().getAbstractArchive().getURI().toString();
    final ModuleDescriptor moduleDescriptor = desc.getModuleDescriptor();
    if (moduleDescriptor.isStandalone()) {
        // it must be a stand-alone module; no such physical dir exists
        return archBase;
    } else {
        return archBase + "/" + FileUtils.makeFriendlyFilename(moduleDescriptor.getArchiveUri());
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor)

Example 2 with ModuleDescriptor

use of org.glassfish.deployment.common.ModuleDescriptor in project Payara by payara.

the class WSClientTest method getAbstractArchiveUri.

protected String getAbstractArchiveUri(ServiceReferenceDescriptor desc) {
    String archBase = getVerifierContext().getAbstractArchive().getURI().toString();
    final ModuleDescriptor moduleDescriptor = desc.getBundleDescriptor().getModuleDescriptor();
    if (moduleDescriptor.isStandalone()) {
        // it must be a stand-alone module; no such physical dir exists
        return archBase;
    } else {
        return archBase + "/" + FileUtils.makeFriendlyFilename(moduleDescriptor.getArchiveUri());
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor)

Example 3 with ModuleDescriptor

use of org.glassfish.deployment.common.ModuleDescriptor in project Payara by payara.

the class FacesConfigDescriptor method readFacesConfigDocument.

private void readFacesConfigDocument(WebBundleDescriptor webd) throws Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    // TODO: Why are we turning off validation here?
    factory.setValidating(false);
    factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    ModuleDescriptor moduleDesc = webd.getModuleDescriptor();
    String archBase = context.getAbstractArchive().getURI().toString();
    String uri = null;
    if (moduleDesc.isStandalone()) {
        uri = archBase;
    } else {
        uri = archBase + File.separator + FileUtils.makeFriendlyFilename(moduleDesc.getArchiveUri());
    }
    FileArchive arch = new FileArchive();
    arch.open(URI.create(uri));
    InputStream is = arch.getEntry(facesConfigFileName);
    InputSource source = new InputSource(is);
    try {
        facesConfigDocument = builder.parse(source);
    } finally {
        try {
            if (is != null)
                is.close();
        } catch (Exception e) {
        }
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) InputSource(org.xml.sax.InputSource) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) InputStream(java.io.InputStream) FileArchive(com.sun.enterprise.deploy.shared.FileArchive)

Example 4 with ModuleDescriptor

use of org.glassfish.deployment.common.ModuleDescriptor in project Payara by payara.

the class TagLibFactory method createDocument.

/**
 * Helper method to create the document object from the tld files specified
 * by the location in web.xml of the war archive.
 *
 * @param location location of jsp tlds
 * @param webd has all the information about the web.xml of the war archive
 * @return document object created from tlds specified at the given location
 * @throws IOException
 * @throws SAXException
 */
private Document createDocument(String location, WebBundleDescriptor webd) throws IOException, SAXException {
    Document document = null;
    InputSource source = null;
    if (// NOI18N
    location.startsWith("/"))
        location = location.substring(1);
    else
        // NOI18N
        location = "WEB-INF/" + location;
    ModuleDescriptor moduleDesc = webd.getModuleDescriptor();
    String archBase = context.getAbstractArchive().getURI().getPath();
    String uri = null;
    if (moduleDesc.isStandalone()) {
        uri = archBase;
    } else {
        uri = archBase + File.separator + FileUtils.makeFriendlyFilename(moduleDesc.getArchiveUri());
    }
    FileArchive arch = new FileArchive();
    arch.open(uri);
    InputStream is = arch.getEntry(location);
    try {
        // is can be null if wrong location of tld is specified in web.xml
        if (is == null)
            throw new IOException(smh.getLocalString(// NOI18N
            getClass().getName() + ".exception1", // NOI18N
            "Wrong tld [ {0} ] specified in the web.xml of [ {1} ]", new Object[] { location, moduleDesc.getArchiveUri() }));
        source = new InputSource(is);
        document = builder.parse(source);
    } finally {
        try {
            if (is != null)
                is.close();
        } catch (Exception e) {
        }
    }
    return document;
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) InputSource(org.xml.sax.InputSource) InputStream(java.io.InputStream) FileArchive(com.sun.enterprise.deploy.shared.FileArchive) IOException(java.io.IOException) Document(org.w3c.dom.Document) IOException(java.io.IOException) SAXParseException(org.xml.sax.SAXParseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 5 with ModuleDescriptor

use of org.glassfish.deployment.common.ModuleDescriptor in project Payara by payara.

the class WebVerifier method getJspOutDir.

/**
 * If precompilejsp is set in the backend then return the jspOutput
 * directory set in the frameworkContext. Otherwise create a new unique
 * directory and return it.
 * @return the output directory where compiled JSPs will be put.
 */
private File getJspOutDir() {
    // verificationContext.getJspOutDir() will be non-null only when the
    // call is from deployment backend and precompilejsp is set
    File jspOutDir = verifierFrameworkContext.getJspOutDir();
    if (jspOutDir != null) {
        ModuleDescriptor moduleDescriptor = webd.getModuleDescriptor();
        if (moduleDescriptor.isStandalone())
            return jspOutDir;
        return new File(jspOutDir, FileUtils.makeFriendlyFilename(moduleDescriptor.getArchiveUri()));
    }
    SecureRandom random = new SecureRandom();
    String prefix = System.getProperty("java.io.tmpdir") + File.separator + ".jspc";
    do {
        float f = random.nextFloat();
        String outDirPath = new String(prefix + f);
        File out = new File(outDirPath);
        if (out.mkdirs())
            return out;
    } while (true);
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) SecureRandom(java.security.SecureRandom) File(java.io.File)

Aggregations

ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)44 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)13 Application (com.sun.enterprise.deployment.Application)8 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)7 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)6 RootDeploymentDescriptor (org.glassfish.deployment.common.RootDeploymentDescriptor)6 DOLUtils.setExtensionArchivistForSubArchivist (com.sun.enterprise.deployment.util.DOLUtils.setExtensionArchivistForSubArchivist)5 File (java.io.File)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)4 InputStream (java.io.InputStream)4 ApplicationDeploymentDescriptorFile (com.sun.enterprise.deployment.io.ApplicationDeploymentDescriptorFile)3 ConfigurationDeploymentDescriptorFile (com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile)3 DeploymentDescriptorFile (com.sun.enterprise.deployment.io.DeploymentDescriptorFile)3 FileArchive (com.sun.enterprise.deploy.shared.FileArchive)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 Enumeration (java.util.Enumeration)2 Vector (java.util.Vector)2