Search in sources :

Example 21 with Application

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

the class ApplicationArchivist method open.

/**
 * open a new application archive file, read all the deployment descriptors
 *
 * @param appArchive
 *            the file path for the J2EE Application archive
 */
@Override
public Application open(ReadableArchive appArchive) throws IOException, SAXParseException {
    setManifest(appArchive.getManifest());
    // read the standard deployment descriptors
    Application appDesc = readStandardDeploymentDescriptor(appArchive);
    return openWith(appDesc, appArchive);
}
Also used : Application(com.sun.enterprise.deployment.Application)

Example 22 with Application

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

the class ApplicationFactory method getApplicationName.

/**
 * @param jarFile the .ear file
 * @return the application name from an application .ear file
 */
public String getApplicationName(File jarFile) throws IOException {
    if (!jarFile.exists()) {
        throw new IOException(localStrings.getLocalString("enterprise.deployment.exceptionjarfiledoesn'texist", "{0} does not exist", new Object[] { jarFile }));
    }
    /*
        *Add finally clause containing explicit close of jar file.
        */
    JarFile jar = null;
    try {
        jar = new JarFile(jarFile);
        ApplicationDeploymentDescriptorFile node = new ApplicationDeploymentDescriptorFile();
        node.setXMLValidation(false);
        ZipEntry deploymentEntry = jar.getEntry(node.getDeploymentDescriptorPath());
        if (deploymentEntry != null) {
            try {
                Application application = (Application) node.read(jar.getInputStream(deploymentEntry));
                return application.getDisplayName();
            } catch (Exception pe) {
                logger.log(Level.WARNING, "Error occurred", pe);
            }
        }
    } finally {
        if (jar != null) {
            jar.close();
        }
    }
    return null;
}
Also used : ApplicationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ApplicationDeploymentDescriptorFile) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException) JarFile(java.util.jar.JarFile) Application(com.sun.enterprise.deployment.Application) IOException(java.io.IOException) SAXParseException(org.xml.sax.SAXParseException)

Example 23 with Application

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

the class ApplicationFactory method openArchive.

/**
 * Open a jar file and return an application object for the modules contained
 * in the archive. If the archive is a standalone module, this API will
 * create an empty application and add the standalone module to it
 *
 * @param appName           the application moduleID
 * @param archivist         to use to open the archive file
 * @param in                the input archive
 * @param handleRuntimeInfo set to true to read configuration deployment descriptors
 * @return the application object
 */
public Application openArchive(String appName, Archivist archivist, ReadableArchive in, boolean handleRuntimeInfo) throws IOException, SAXParseException {
    // we are not reading the runtime deployment descriptor now...
    archivist.setHandleRuntimeInfo(false);
    BundleDescriptor descriptor = archivist.open(in);
    Application application;
    if (descriptor instanceof Application) {
        application = (Application) descriptor;
        application.setAppName(appName);
        application.setRegistrationName(appName);
    } else {
        if (descriptor == null) {
            logger.log(Level.SEVERE, localStrings.getLocalString("enterprise.deployment.cannotreadDDs", "Cannot read the Deployment Descriptors for module {0}", new Object[] { in.getURI() }));
            return null;
        }
        ModuleDescriptor newModule = archivist.createModuleDescriptor(descriptor);
        newModule.setArchiveUri(in.getURI().getSchemeSpecificPart());
        application = Application.createVirtualApplication(appName, newModule);
    }
    // now read the runtime deployment descriptor
    if (handleRuntimeInfo) {
        // now read the runtime deployment descriptors from the original jar file
        archivist.setHandleRuntimeInfo(true);
        archivist.readRuntimeDeploymentDescriptor(in, (BundleDescriptor) descriptor);
    }
    // validate
    if (application != null) {
        application.setClassLoader(archivist.getClassLoader());
        application.visit((ApplicationVisitor) new ApplicationValidator());
    }
    return application;
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) ApplicationValidator(com.sun.enterprise.deployment.util.ApplicationValidator) Application(com.sun.enterprise.deployment.Application)

Example 24 with Application

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

the class ApplicationFactory method createApplicationFromStandardDD.

/**
 * This method creates an Application object from reading the
 * standard deployment descriptor.
 * @param archive the archive for the application
 */
public Application createApplicationFromStandardDD(ReadableArchive archive, String archiveType) throws IOException, SAXParseException {
    Archivist archivist = archivistFactory.getArchivist(archiveType, null);
    String xmlValidationLevel = dasConfig.getDeployXmlValidation();
    archivist.setXMLValidationLevel(xmlValidationLevel);
    if (xmlValidationLevel.equals("none")) {
        archivist.setXMLValidation(false);
    }
    BundleDescriptor desc = archivist.readStandardDeploymentDescriptor(archive);
    Application application = null;
    if (desc instanceof Application) {
        application = (Application) desc;
    } else {
        ModuleDescriptor newModule = archivist.createModuleDescriptor(desc);
        newModule.setArchiveUri(archive.getURI().getSchemeSpecificPart());
        String moduleName = newModule.getModuleName();
        application = Application.createVirtualApplication(moduleName, newModule);
    }
    return application;
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) Application(com.sun.enterprise.deployment.Application)

Example 25 with Application

use of com.sun.enterprise.deployment.Application 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)

Aggregations

Application (com.sun.enterprise.deployment.Application)66 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)17 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)10 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)10 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)10 IOException (java.io.IOException)9 File (java.io.File)8 ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)8 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)7 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)7 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)5 DeploymentException (org.glassfish.deployment.common.DeploymentException)5 SAXParseException (org.xml.sax.SAXParseException)5 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)4 ArrayList (java.util.ArrayList)4 WebappClassLoader (org.glassfish.web.loader.WebappClassLoader)4 OpsParams (org.glassfish.api.deployment.OpsParams)3 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)3 Applications (com.sun.enterprise.config.serverbeans.Applications)2 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)2