Search in sources :

Example 16 with ModuleDescriptor

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

the class ApplicationArchivist method copyInto.

/**
 * Copy this archivist to a new abstract archive
 *
 * @param a
 *            the deployment descriptor for an application
 * @param source
 *            the source archive
 * @param target
 *            the target archive
 * @param overwriteManifest
 *            if true, the manifest in source archive overwrites the one in target
 */
public void copyInto(Application a, ReadableArchive source, WritableArchive target, boolean overwriteManifest) throws IOException {
    Vector entriesAdded = new Vector();
    for (ModuleDescriptor aModule : a.getModules()) {
        entriesAdded.add(aModule.getArchiveUri());
        ReadableArchive subSource = source.getSubArchive(aModule.getArchiveUri());
        WritableArchive subTarget = target.createSubArchive(aModule.getArchiveUri());
        Archivist newArchivist = archivistFactory.get().getArchivist(aModule.getModuleType());
        ReadableArchive subArchive = archiveFactory.openArchive(subTarget.getURI());
        subSource.setParentArchive(subArchive);
        newArchivist.copyInto(subSource, subTarget, overwriteManifest);
        target.closeEntry(subTarget);
        String subModulePath = subSource.getURI().getSchemeSpecificPart();
        String parentPath = source.getURI().getSchemeSpecificPart();
        if (subModulePath.startsWith(parentPath)) {
            subModulePath = subModulePath.substring(parentPath.length() + File.separator.length());
            for (Enumeration subEntries = subSource.entries(); subEntries.hasMoreElements(); ) {
                String anEntry = (String) subEntries.nextElement();
                entriesAdded.add(subModulePath + "/" + anEntry);
            }
        }
        subSource.close();
        subArchive.close();
    }
    super.copyInto(source, target, entriesAdded, overwriteManifest);
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) DOLUtils.setExtensionArchivistForSubArchivist(com.sun.enterprise.deployment.util.DOLUtils.setExtensionArchivistForSubArchivist) Enumeration(java.util.Enumeration) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) Vector(java.util.Vector) WritableArchive(org.glassfish.api.deployment.archive.WritableArchive)

Example 17 with ModuleDescriptor

use of org.glassfish.deployment.common.ModuleDescriptor 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 18 with ModuleDescriptor

use of org.glassfish.deployment.common.ModuleDescriptor 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 19 with ModuleDescriptor

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

the class ApplicationNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent parent node
 * @param application  to write
 * @return the DOM tree top node
 */
public Node writeDescriptor(Node parent, Application application) {
    Node appNode = super.writeDescriptor(parent, application);
    // initialize-in-order
    appendTextChild(appNode, ApplicationTagNames.INITIALIZE_IN_ORDER, String.valueOf(application.isInitializeInOrder()));
    // module
    ModuleNode moduleNode = new ModuleNode();
    for (ModuleDescriptor md : application.getModules()) {
        moduleNode.writeDescriptor(appNode, ApplicationTagNames.MODULE, md);
    }
    // library-directory
    if (application.getLibraryDirectoryRawValue() != null) {
        appendTextChild(appNode, ApplicationTagNames.LIBRARY_DIRECTORY, application.getLibraryDirectoryRawValue());
    }
    // env-entry*
    writeEnvEntryDescriptors(appNode, application.getEnvironmentProperties().iterator());
    // ejb-ref * and ejb-local-ref*
    writeEjbReferenceDescriptors(appNode, application.getEjbReferenceDescriptors().iterator());
    // service-ref*
    writeServiceReferenceDescriptors(appNode, application.getServiceReferenceDescriptors().iterator());
    // resource-ref*
    writeResourceRefDescriptors(appNode, application.getResourceReferenceDescriptors().iterator());
    // resource-env-ref*
    writeResourceEnvRefDescriptors(appNode, application.getResourceEnvReferenceDescriptors().iterator());
    // message-destination-ref*
    writeMessageDestinationRefDescriptors(appNode, application.getMessageDestinationReferenceDescriptors().iterator());
    // persistence-context-ref*
    writeEntityManagerReferenceDescriptors(appNode, application.getEntityManagerReferenceDescriptors().iterator());
    // persistence-unit-ref*
    writeEntityManagerFactoryReferenceDescriptors(appNode, application.getEntityManagerFactoryReferenceDescriptors().iterator());
    // message-destination*
    writeMessageDestinations(appNode, application.getMessageDestinations().iterator());
    // all descriptors (includes DSD, MSD, JMSCFD, JMSDD,AOD, CFD)*
    writeResourceDescriptors(appNode, application.getAllResourcesDescriptors().iterator());
    return appNode;
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) Node(org.w3c.dom.Node)

Example 20 with ModuleDescriptor

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

the class ModuleNode method setElementValue.

/**
 * receives notification of the value for a particular tag
 *
 * @param element the xml element
 * @param value it's associated value
 */
public void setElementValue(XMLElement element, String value) {
    ModuleDescriptor descriptor = (ModuleDescriptor) getDescriptor();
    if (element.getQName().equals(ApplicationTagNames.WEB_URI)) {
        descriptor.setModuleType(DOLUtils.warType());
        descriptor.setArchiveUri(value);
    } else if (element.getQName().equals(ApplicationTagNames.EJB)) {
        descriptor.setModuleType(DOLUtils.ejbType());
        descriptor.setArchiveUri(value);
    } else if (element.getQName().equals(ApplicationTagNames.CONNECTOR)) {
        descriptor.setModuleType(DOLUtils.rarType());
        descriptor.setArchiveUri(value);
    } else if (element.getQName().equals(ApplicationTagNames.APPLICATION_CLIENT)) {
        descriptor.setModuleType(DOLUtils.carType());
        descriptor.setArchiveUri(value);
    } else if (element.getQName().equals(ApplicationTagNames.WEB)) {
        descriptor.setModuleType(DOLUtils.warType());
    } else
        super.setElementValue(element, value);
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor)

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