Search in sources :

Example 1 with Archive

use of org.glassfish.api.deployment.archive.Archive in project Payara by payara.

the class EarPersistenceArchivist method open.

/**
 * Reads persistence.xml from spec defined pu roots of an ear.
 * Spec defined pu roots are - (1)Non component jars in root of ear (2)jars in lib of ear
 */
@Override
public Object open(Archivist main, ReadableArchive earArchive, final RootDeploymentDescriptor descriptor) throws IOException, SAXParseException {
    if (deplLogger.isLoggable(Level.FINE)) {
        deplLogger.logp(Level.FINE, "EarArchivist", "readPersistenceDeploymentDescriptors", "archive = {0}", earArchive.getURI());
    }
    Map<String, ReadableArchive> probablePersitenceArchives = new HashMap<String, ReadableArchive>();
    try {
        if (!(descriptor instanceof Application)) {
            return null;
        }
        final Application app = Application.class.cast(descriptor);
        // TODO: need to compute includeRoot, not hard-code it, in the next invocation. The flag should be set to true if operating in v2 compatibility mode false otherwise.
        // Check with Hong how to get hold of the flag here?
        EARBasedPersistenceHelper.addLibraryAndTopLevelCandidates(earArchive, app, true, /* includeRoot */
        probablePersitenceArchives);
        for (Map.Entry<String, ReadableArchive> pathToArchiveEntry : probablePersitenceArchives.entrySet()) {
            readPersistenceDeploymentDescriptor(main, pathToArchiveEntry.getValue(), pathToArchiveEntry.getKey(), descriptor);
        }
    } finally {
        for (Archive subArchive : probablePersitenceArchives.values()) {
            subArchive.close();
        }
    }
    return null;
}
Also used : ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) Archive(org.glassfish.api.deployment.archive.Archive) HashMap(java.util.HashMap) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) Application(com.sun.enterprise.deployment.Application) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with Archive

use of org.glassfish.api.deployment.archive.Archive in project Payara by payara.

the class WarPersistenceArchivist method open.

@Override
public Object open(Archivist main, ReadableArchive warArchive, RootDeploymentDescriptor descriptor) throws IOException, SAXParseException {
    final String CLASSES_DIR = "WEB-INF/classes/";
    if (deplLogger.isLoggable(Level.FINE)) {
        deplLogger.logp(Level.FINE, "WarPersistenceArchivist", "readPersistenceDeploymentDescriptors", "archive = {0}", warArchive.getURI());
    }
    Map<String, ReadableArchive> probablePersitenceArchives = new HashMap<String, ReadableArchive>();
    try {
        SubArchivePURootScanner warLibScanner = new SubArchivePURootScanner() {

            @Override
            String getPathOfSubArchiveToScan() {
                return "WEB-INF/lib";
            }
        };
        probablePersitenceArchives = getProbablePersistenceRoots(warArchive, warLibScanner);
        final String pathOfPersistenceXMLInsideClassesDir = CLASSES_DIR + DescriptorConstants.PERSISTENCE_DD_ENTRY;
        InputStream is = warArchive.getEntry(pathOfPersistenceXMLInsideClassesDir);
        if (is != null) {
            is.close();
            probablePersitenceArchives.put(CLASSES_DIR, warArchive.getSubArchive(CLASSES_DIR));
        }
        for (Map.Entry<String, ReadableArchive> pathToArchiveEntry : probablePersitenceArchives.entrySet()) {
            readPersistenceDeploymentDescriptor(main, pathToArchiveEntry.getValue(), pathToArchiveEntry.getKey(), descriptor);
        }
    } finally {
        for (Archive probablePersitenceArchive : probablePersitenceArchives.values()) {
            probablePersitenceArchive.close();
        }
    }
    return null;
}
Also used : Archive(org.glassfish.api.deployment.archive.Archive) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) HashMap(java.util.HashMap) InputStream(java.io.InputStream) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with Archive

use of org.glassfish.api.deployment.archive.Archive in project Payara by payara.

the class IconImageTypeTest method testIconURIExistence.

private void testIconURIExistence() {
    Collection<String> allURIs = new ArrayList<String>(smallIconUris);
    allURIs.addAll(largeIconUris);
    for (String uri : allURIs) {
        Archive moduleArchive = getVerifierContext().getModuleArchive();
        boolean passed = false;
        for (Enumeration entries = moduleArchive.entries(); entries.hasMoreElements(); ) {
            if (uri.equals(entries.nextElement())) {
                passed = true;
                break;
            }
        }
        if (!passed) {
            addErrorDetails(result, compName);
            result.failed(smh.getLocalString(getClass().getName() + ".failedExistence", "Error: icon image URI [ {0} ] is not packaged inside [ {1} ].", new Object[] { uri, getVerifierContext().getModuleArchive().getURI() }));
        }
    }
}
Also used : Archive(org.glassfish.api.deployment.archive.Archive) Enumeration(java.util.Enumeration) ArrayList(java.util.ArrayList)

Aggregations

Archive (org.glassfish.api.deployment.archive.Archive)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)2 Application (com.sun.enterprise.deployment.Application)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Enumeration (java.util.Enumeration)1