Search in sources :

Example 36 with ReadableArchive

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

the class Archivist method copyInto.

/**
 * Copy this archivist to a new abstract archive
 *
 * @param target the new archive to use to copy our contents into
 * @throws java.io.IOException
 */
public void copyInto(WritableArchive target) throws IOException {
    ReadableArchive source = archiveFactory.openArchive(new File(path));
    copyInto(source, target);
}
Also used : ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) DeploymentDescriptorFile(com.sun.enterprise.deployment.io.DeploymentDescriptorFile) JarFile(java.util.jar.JarFile) ConfigurationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile)

Example 37 with ReadableArchive

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

the class Archivist method write.

/**
 * saves the archive
 *
 * @param outPath the file to use
 */
public void write(String outPath) throws IOException {
    ReadableArchive in = archiveFactory.openArchive(new File(path));
    write(in, outPath);
    in.close();
}
Also used : ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) DeploymentDescriptorFile(com.sun.enterprise.deployment.io.DeploymentDescriptorFile) JarFile(java.util.jar.JarFile) ConfigurationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile)

Example 38 with ReadableArchive

use of org.glassfish.api.deployment.archive.ReadableArchive 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<>();
    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 39 with ReadableArchive

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

the class OpenAPISupplier method filterLibTypes.

private Set<Type> filterLibTypes(OpenApiConfiguration config, Types hk2Types, ReadableArchive archive) {
    Set<Type> types = new HashSet<>();
    if (config != null && config.getScanLib()) {
        Enumeration<String> subArchiveItr = archive.entries();
        while (subArchiveItr.hasMoreElements()) {
            String subArchiveName = subArchiveItr.nextElement();
            if (subArchiveName.startsWith("WEB-INF/lib/") && subArchiveName.endsWith(".jar")) {
                try {
                    ReadableArchive subArchive = archive.getSubArchive(subArchiveName);
                    types.addAll(Collections.list(subArchive.entries()).stream().filter(clazz -> clazz.endsWith(".class")).map(clazz -> clazz.replace("/", ".").replace(".class", "")).map(clazz -> hk2Types.getBy(clazz)).filter(Objects::nonNull).collect(toSet()));
                } catch (IOException ex) {
                    throw new IllegalStateException(ex);
                }
            }
        }
    }
    return types;
}
Also used : StructuredDeploymentTracing(org.glassfish.internal.deployment.analysis.StructuredDeploymentTracing) OpenApiConfiguration(fish.payara.microprofile.openapi.impl.config.OpenApiConfiguration) ConfigPropertyProcessor(fish.payara.microprofile.openapi.impl.processor.ConfigPropertyProcessor) Enumeration(java.util.Enumeration) Globals(org.glassfish.internal.api.Globals) URL(java.net.URL) ApplicationProcessor(fish.payara.microprofile.openapi.impl.processor.ApplicationProcessor) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) InetAddress(java.net.InetAddress) HashSet(java.util.HashSet) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) ServerEnvironment(org.glassfish.api.admin.ServerEnvironment) FileProcessor(fish.payara.microprofile.openapi.impl.processor.FileProcessor) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener) Collectors.toSet(java.util.stream.Collectors.toSet) Types(org.glassfish.hk2.classmodel.reflect.Types) MalformedURLException(java.net.MalformedURLException) ApplicationLifecycle(com.sun.enterprise.v3.server.ApplicationLifecycle) Set(java.util.Set) IOException(java.io.IOException) OpenAPIImpl(fish.payara.microprofile.openapi.impl.model.OpenAPIImpl) Logger(java.util.logging.Logger) UnknownHostException(java.net.UnknownHostException) Parser(org.glassfish.hk2.classmodel.reflect.Parser) Objects(java.util.Objects) OpenAPI(org.eclipse.microprofile.openapi.models.OpenAPI) ServerContext(org.glassfish.internal.api.ServerContext) List(java.util.List) FilterProcessor(fish.payara.microprofile.openapi.impl.processor.FilterProcessor) GrizzlyService(com.sun.enterprise.v3.services.impl.GrizzlyService) MultiException(org.glassfish.hk2.api.MultiException) BaseProcessor(fish.payara.microprofile.openapi.impl.processor.BaseProcessor) ModelReaderProcessor(fish.payara.microprofile.openapi.impl.processor.ModelReaderProcessor) Collections(java.util.Collections) Type(org.glassfish.hk2.classmodel.reflect.Type) Type(org.glassfish.hk2.classmodel.reflect.Type) Objects(java.util.Objects) IOException(java.io.IOException) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) HashSet(java.util.HashSet)

Example 40 with ReadableArchive

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

the class ConnectorsUtil method getApplicationName.

public static String getApplicationName(DeploymentContext context) {
    String applicationName = null;
    ReadableArchive parentArchive = context.getSource().getParentArchive();
    if (parentArchive != null) {
        applicationName = parentArchive.getName();
    } else {
        applicationName = context.getSource().getName();
    }
    return applicationName;
}
Also used : ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive)

Aggregations

ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)97 IOException (java.io.IOException)46 File (java.io.File)28 URI (java.net.URI)18 ActionReport (org.glassfish.api.ActionReport)17 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)14 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)12 WritableArchive (org.glassfish.api.deployment.archive.WritableArchive)12 Application (com.sun.enterprise.deployment.Application)10 JarFile (java.util.jar.JarFile)10 ArchiveHandler (org.glassfish.api.deployment.archive.ArchiveHandler)10 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)10 ArrayList (java.util.ArrayList)9 ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)9 ConfigurationDeploymentDescriptorFile (com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile)8 Logger (java.util.logging.Logger)8 DeploymentDescriptorFile (com.sun.enterprise.deployment.io.DeploymentDescriptorFile)7 Manifest (java.util.jar.Manifest)7 HashSet (java.util.HashSet)6 HashMap (java.util.HashMap)5