Search in sources :

Example 1 with ConfigurationDeploymentDescriptorFile

use of com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile in project Payara by payara.

the class ConnectorArchivist method getConfigurationDDFiles.

/**
 * @return the list of the DeploymentDescriptorFile responsible for
 *         handling the configuration deployment descriptors
 */
public List<ConfigurationDeploymentDescriptorFile> getConfigurationDDFiles() {
    if (confDDFiles == null) {
        confDDFiles = new ArrayList<ConfigurationDeploymentDescriptorFile>();
        confDDFiles.add(new ConnectorRuntimeDDFile());
    }
    return confDDFiles;
}
Also used : ConnectorRuntimeDDFile(com.sun.enterprise.deployment.io.runtime.ConnectorRuntimeDDFile) ConfigurationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile)

Example 2 with ConfigurationDeploymentDescriptorFile

use of com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile in project Payara by payara.

the class DOLUtils method sortConfigurationDDFiles.

/**
 * process the list of the configuration files, and return the sorted
 *    // configuration file with precedence from high to low
 *    // this list does not take consideration of what runtime files are
 *    // present in the current archive
 */
private static List<ConfigurationDeploymentDescriptorFile> sortConfigurationDDFiles(List<ConfigurationDeploymentDescriptorFile> ddFiles, ArchiveType archiveType, ReadableArchive archive) {
    ConfigurationDeploymentDescriptorFile wlsConfDD = null;
    ConfigurationDeploymentDescriptorFile gfConfDD = null;
    ConfigurationDeploymentDescriptorFile sunConfDD = null;
    for (ConfigurationDeploymentDescriptorFile ddFile : ddFiles) {
        ddFile.setArchiveType(archiveType);
        String ddPath = ddFile.getDeploymentDescriptorPath();
        if (ddPath.indexOf(DescriptorConstants.WLS) != -1) {
            wlsConfDD = ddFile;
        } else if (ddPath.indexOf(DescriptorConstants.GF_PREFIX) != -1) {
            gfConfDD = ddFile;
        } else if (ddPath.indexOf(DescriptorConstants.S1AS_PREFIX) != -1) {
            sunConfDD = ddFile;
        }
    }
    List<ConfigurationDeploymentDescriptorFile> sortedConfDDFiles = new ArrayList<ConfigurationDeploymentDescriptorFile>();
    // if there is external runtime alternate deployment descriptor
    // specified, just use that
    File runtimeAltDDFile = archive.getArchiveMetaData(DeploymentProperties.RUNTIME_ALT_DD, File.class);
    if (runtimeAltDDFile != null && runtimeAltDDFile.exists() && runtimeAltDDFile.isFile()) {
        String runtimeAltDDPath = runtimeAltDDFile.getPath();
        validateRuntimeAltDDPath(runtimeAltDDPath);
        if (runtimeAltDDPath.indexOf(DescriptorConstants.GF_PREFIX) != -1 && gfConfDD != null) {
            sortedConfDDFiles.add(gfConfDD);
            return sortedConfDDFiles;
        }
    }
    if (Boolean.valueOf(System.getProperty(GFDD_OVER_WLSDD))) {
        // descriptors higher precedence
        if (gfConfDD != null) {
            sortedConfDDFiles.add(gfConfDD);
        }
        if (wlsConfDD != null) {
            sortedConfDDFiles.add(wlsConfDD);
        }
    } else if (Boolean.valueOf(System.getProperty(IGNORE_WLSDD))) {
        // WLS deployment descriptors
        if (gfConfDD != null) {
            sortedConfDDFiles.add(gfConfDD);
        }
    } else {
        // the default will be WLS DD has higher precedence
        if (wlsConfDD != null) {
            sortedConfDDFiles.add(wlsConfDD);
        }
        if (gfConfDD != null) {
            sortedConfDDFiles.add(gfConfDD);
        }
    }
    if (sunConfDD != null) {
        sortedConfDDFiles.add(sunConfDD);
    }
    return sortedConfDDFiles;
}
Also used : ConfigurationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile) ArrayList(java.util.ArrayList) ConfigurationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile) File(java.io.File)

Example 3 with ConfigurationDeploymentDescriptorFile

use of com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile in project Payara by payara.

the class DOLUtils method readAlternativeRuntimeDescriptor.

/**
 * read alternative runtime descriptor if there is an alternative runtime
 * DD packaged inside the archive
 * @param appArchive
 * @param embeddedArchive
 * @param archivist
 * @param descriptor
 * @param altDDPath
 * @throws java.io.IOException
 * @throws org.xml.sax.SAXParseException
 */
public static void readAlternativeRuntimeDescriptor(ReadableArchive appArchive, ReadableArchive embeddedArchive, Archivist archivist, BundleDescriptor descriptor, String altDDPath) throws IOException, SAXParseException {
    String altRuntimeDDPath = null;
    ConfigurationDeploymentDescriptorFile confDD = null;
    @SuppressWarnings("unchecked") List<ConfigurationDeploymentDescriptorFile> archivistConfDDFiles = archivist.getConfigurationDDFiles();
    for (ConfigurationDeploymentDescriptorFile ddFile : sortConfigurationDDFiles(archivistConfDDFiles, archivist.getModuleType(), embeddedArchive)) {
        String ddPath = ddFile.getDeploymentDescriptorPath();
        if (ddPath.indexOf(DescriptorConstants.WLS) != -1 && appArchive.exists(DescriptorConstants.WLS + altDDPath)) {
            // TODO: need to revisit this for WLS alt-dd pattern
            confDD = ddFile;
            altRuntimeDDPath = DescriptorConstants.WLS + altDDPath;
        } else if (ddPath.indexOf(DescriptorConstants.GF_PREFIX) != -1 && appArchive.exists(DescriptorConstants.GF_PREFIX + altDDPath)) {
            confDD = ddFile;
            altRuntimeDDPath = DescriptorConstants.GF_PREFIX + altDDPath;
        } else if (ddPath.indexOf(DescriptorConstants.S1AS_PREFIX) != -1 && appArchive.exists(DescriptorConstants.S1AS_PREFIX + altDDPath)) {
            confDD = ddFile;
            altRuntimeDDPath = DescriptorConstants.S1AS_PREFIX + altDDPath;
        }
    }
    if (confDD != null && altRuntimeDDPath != null) {
        // found an alternative runtime DD file
        InputStream is = appArchive.getEntry(altRuntimeDDPath);
        confDD.setXMLValidation(archivist.getRuntimeXMLValidation());
        confDD.setXMLValidationLevel(archivist.getRuntimeXMLValidationLevel());
        if (appArchive.getURI() != null) {
            confDD.setErrorReportingString(appArchive.getURI().getSchemeSpecificPart());
        }
        confDD.read(descriptor, is);
        is.close();
        archivist.postRuntimeDDsRead(descriptor, embeddedArchive);
    } else {
        archivist.readRuntimeDeploymentDescriptor(embeddedArchive, descriptor);
    }
}
Also used : ConfigurationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream)

Example 4 with ConfigurationDeploymentDescriptorFile

use of com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile in project Payara by payara.

the class DOLUtils method readRuntimeDeploymentDescriptor.

/**
 * Read the runtime deployment descriptors (can contained in one or
 * many file) set the corresponding information in the passed descriptor.
 * By default, the runtime deployment descriptors are all contained in
 * the xml file characterized with the path returned by
 *
 * @param confDDFiles the sorted configuration files for this archive
 * @param archive the archive
 * @param descriptor the initialized deployment descriptor
 * @param main the main archivist
 * @param warnIfMultipleDDs whether to log warnings if both the GlassFish and the legacy Sun descriptors are present
 */
public static void readRuntimeDeploymentDescriptor(List<ConfigurationDeploymentDescriptorFile> confDDFiles, ReadableArchive archive, RootDeploymentDescriptor descriptor, Archivist main, final boolean warnIfMultipleDDs) throws IOException, SAXParseException {
    if (confDDFiles == null || confDDFiles.isEmpty()) {
        return;
    }
    ConfigurationDeploymentDescriptorFile confDD = confDDFiles.get(0);
    InputStream is = null;
    try {
        File runtimeAltDDFile = archive.getArchiveMetaData(DeploymentProperties.RUNTIME_ALT_DD, File.class);
        if (runtimeAltDDFile != null && runtimeAltDDFile.exists() && runtimeAltDDFile.isFile()) {
            is = new FileInputStream(runtimeAltDDFile);
        } else {
            is = archive.getEntry(confDD.getDeploymentDescriptorPath());
        }
        if (is == null) {
            return;
        }
        for (int i = 1; i < confDDFiles.size(); i++) {
            if (warnIfMultipleDDs) {
                deplLogger.log(Level.WARNING, COUNTERPART_CONFIGDD_EXISTS, new Object[] { confDDFiles.get(i).getDeploymentDescriptorPath(), archive.getURI().getSchemeSpecificPart(), confDD.getDeploymentDescriptorPath() });
            }
        }
        confDD.setErrorReportingString(archive.getURI().getSchemeSpecificPart());
        if (confDD.isValidating()) {
            confDD.setXMLValidation(main.getRuntimeXMLValidation());
            confDD.setXMLValidationLevel(main.getRuntimeXMLValidationLevel());
        } else {
            confDD.setXMLValidation(false);
        }
        confDD.read(descriptor, is);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException ioe) {
            }
        }
    }
}
Also used : ConfigurationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) ConfigurationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 5 with ConfigurationDeploymentDescriptorFile

use of com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile in project Payara by payara.

the class Archivist method writeRuntimeDeploymentDescriptors.

/**
 * writes the runtime deployment descriptors to an abstract archive
 *
 * @param in the input archive
 * @param out output archive
 */
public void writeRuntimeDeploymentDescriptors(ReadableArchive in, WritableArchive out) throws IOException {
    T desc = getDescriptor();
    // when source archive contains runtime deployment descriptor
    // files, write those out
    // otherwise write all possible runtime deployment descriptor
    // files out (revisit this to see what is the desired behavior
    // here, write out all, or write out the highest precedence one,
    // or not write out)
    List<ConfigurationDeploymentDescriptorFile> confDDFilesToWrite = getSortedConfigurationDDFiles(in);
    if (confDDFilesToWrite.isEmpty()) {
        confDDFilesToWrite = getConfigurationDDFiles();
    }
    for (ConfigurationDeploymentDescriptorFile ddFile : confDDFilesToWrite) {
        ddFile.setArchiveType(getModuleType());
        OutputStream os = out.putNextEntry(ddFile.getDeploymentDescriptorPath());
        ddFile.write(desc, os);
        out.closeEntry();
    }
}
Also used : ConfigurationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile)

Aggregations

ConfigurationDeploymentDescriptorFile (com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile)11 File (java.io.File)3 ArrayList (java.util.ArrayList)3 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 AppClientRuntimeDDFile (com.sun.enterprise.deployment.io.runtime.AppClientRuntimeDDFile)1 ConnectorRuntimeDDFile (com.sun.enterprise.deployment.io.runtime.ConnectorRuntimeDDFile)1 GFAppClientRuntimeDDFile (com.sun.enterprise.deployment.io.runtime.GFAppClientRuntimeDDFile)1 WLSWebServicesDeploymentDescriptorFile (com.sun.enterprise.deployment.io.runtime.WLSWebServicesDeploymentDescriptorFile)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1