Search in sources :

Example 1 with RootDeploymentDescriptor

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

the class PersistenceUnitInfoImpl method getAbsolutePuRootWithinApplication.

/**
 * This method calculates the absolute path of the root of a PU.
 * Absolute path is not the path with regards to root of file system.
 * It is the path from the root of the Java EE application this
 * persistence unit belongs to.
 * Returned path always uses '/' as path separator.
 * @return the absolute path of the root of this persistence unit
 */
private String getAbsolutePuRootWithinApplication() {
    // TODO shift this into PersistenceUnitDescriptor to better encapsulate
    RootDeploymentDescriptor rootDD = persistenceUnitDescriptor.getParent().getParent();
    String puRoot = persistenceUnitDescriptor.getPuRoot();
    if (rootDD.isApplication()) {
        return puRoot;
    } else {
        ModuleDescriptor module = BundleDescriptor.class.cast(rootDD).getModuleDescriptor();
        if (module.isStandalone()) {
            return puRoot;
        } else {
            // The module is embedded in an ear (an ejb jar or war)
            final // Would point to the directory where module is expanded. For example myejb_jar
            String moduleLocation = DeploymentUtils.getRelativeEmbeddedModulePath(providerContainerContractInfo.getApplicationLocation(), module.getArchiveUri());
            // see we always '/'
            return moduleLocation + '/' + puRoot;
        }
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor)

Example 2 with RootDeploymentDescriptor

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

the class MailSessionDeployer method registerMailSessions.

public void registerMailSessions(com.sun.enterprise.deployment.Application application) {
    String appName = application.getAppName();
    Set<BundleDescriptor> bundles = application.getBundleDescriptors();
    for (BundleDescriptor bundle : bundles) {
        registerMailSessionDefinitions(appName, bundle);
        Collection<RootDeploymentDescriptor> dds = bundle.getExtensionsDescriptors();
        if (dds != null) {
            for (RootDeploymentDescriptor dd : dds) {
                registerMailSessionDefinitions(appName, dd);
            }
        }
    }
}
Also used : RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor)

Example 3 with RootDeploymentDescriptor

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

the class MailSessionDeployer method unRegisterMailSessions.

public void unRegisterMailSessions(com.sun.enterprise.deployment.Application application) {
    Set<BundleDescriptor> bundles = application.getBundleDescriptors();
    for (BundleDescriptor bundle : bundles) {
        unRegisterMailSessions(bundle);
        Collection<RootDeploymentDescriptor> dds = bundle.getExtensionsDescriptors();
        if (dds != null) {
            for (RootDeploymentDescriptor dd : dds) {
                unRegisterMailSessions(dd);
            }
        }
    }
}
Also used : RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor)

Example 4 with RootDeploymentDescriptor

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

the class ApplicationArchivist method readModulesDescriptors.

/**
 * read the modules deployment descriptor from this application object using the passed archive
 *
 * @param app
 *            application containing the list of modules.
 * @param appArchive
 *            containing the sub modules files.
 * @return true if everything went fine
 */
public boolean readModulesDescriptors(Application app, ReadableArchive appArchive) throws IOException, SAXParseException {
    List<ModuleDescriptor> nonexistentModules = new ArrayList<ModuleDescriptor>();
    List<ModuleDescriptor> sortedModules = sortModules(app);
    for (ModuleDescriptor aModule : sortedModules) {
        if (aModule.getArchiveUri().indexOf(" ") != -1) {
            throw new IllegalArgumentException(localStrings.getLocalString("enterprise.deployment.unsupporturi", "Unsupported module URI {0}, it contains space(s)", new Object[] { aModule.getArchiveUri() }));
        }
        if (getDefaultLogger().isLoggable(FINE)) {
            getDefaultLogger().fine("Opening sub-module " + aModule);
        }
        BundleDescriptor descriptor = null;
        Archivist newArchivist = archivistFactory.get().getArchivist(aModule.getModuleType());
        newArchivist.initializeContext(this);
        newArchivist.setRuntimeXMLValidation(this.getRuntimeXMLValidation());
        newArchivist.setRuntimeXMLValidationLevel(this.getRuntimeXMLValidationLevel());
        newArchivist.setAnnotationProcessingRequested(annotationProcessingRequested);
        ReadableArchive embeddedArchive = appArchive.getSubArchive(aModule.getArchiveUri());
        if (embeddedArchive == null) {
            throw new IllegalArgumentException(localStrings.getLocalString("enterprise.deployment.nosuchmodule", "Could not find sub module [{0}] as defined in application.xml", new Object[] { aModule.getArchiveUri() }));
        }
        embeddedArchive.setParentArchive(appArchive);
        setExtensionArchivistForSubArchivist(habitat, embeddedArchive, aModule, app, newArchivist);
        if (aModule.getAlternateDescriptor() != null) {
            // The module use alternate deployement descriptor, ignore the DDs in the archive.
            InputStream is = appArchive.getEntry(aModule.getAlternateDescriptor());
            DeploymentDescriptorFile ddFile = newArchivist.getStandardDDFile();
            ddFile.setXMLValidation(newArchivist.getXMLValidation());
            ddFile.setXMLValidationLevel(newArchivist.getXMLValidationLevel());
            if (appArchive.getURI() != null) {
                ddFile.setErrorReportingString(appArchive.getURI().getSchemeSpecificPart());
            }
            descriptor = (BundleDescriptor) ddFile.read(is);
            descriptor.setApplication(app);
            is.close();
            // TODO : JD need to be revisited for EAR files with Alternative descriptors, what does
            // it mean for sub components.
            Map<ExtensionsArchivist, RootDeploymentDescriptor> extensions = new HashMap<ExtensionsArchivist, RootDeploymentDescriptor>();
            List<ExtensionsArchivist> extensionsArchivists = newArchivist.getExtensionArchivists();
            if (extensionsArchivists != null) {
                for (ExtensionsArchivist extension : extensionsArchivists) {
                    Object rdd = extension.open(newArchivist, embeddedArchive, descriptor);
                    if (rdd instanceof RootDeploymentDescriptor) {
                        extensions.put(extension, (RootDeploymentDescriptor) rdd);
                    }
                }
            }
            newArchivist.postStandardDDsRead(descriptor, embeddedArchive, extensions);
            newArchivist.readAnnotations(embeddedArchive, descriptor, extensions);
            newArchivist.postAnnotationProcess(descriptor, embeddedArchive);
            newArchivist.postOpen(descriptor, embeddedArchive);
            // Now reads the runtime deployment descriptor...
            if (isHandlingRuntimeInfo()) {
                readAlternativeRuntimeDescriptor(appArchive, embeddedArchive, newArchivist, descriptor, aModule.getAlternateDescriptor());
                // Read extensions runtime deployment descriptors if any
                for (Map.Entry<ExtensionsArchivist, RootDeploymentDescriptor> extension : extensions.entrySet()) {
                    // After standard DD and annotations are processed we should have an extension descriptor now
                    if (extension.getValue() != null) {
                        extension.getKey().readRuntimeDeploymentDescriptor(newArchivist, embeddedArchive, extension.getValue());
                    }
                }
            }
        } else {
            // Open the subarchive to get the deployment descriptor...
            descriptor = newArchivist.open(embeddedArchive, app);
        }
        embeddedArchive.close();
        if (descriptor != null) {
            descriptor.getModuleDescriptor().setArchiveUri(aModule.getArchiveUri());
            aModule.setModuleName(descriptor.getModuleDescriptor().getModuleName());
            aModule.setDescriptor(descriptor);
            descriptor.setApplication(app);
            aModule.setManifest(newArchivist.getManifest());
            // For optional application.xml case, set the context root as module name for web modules
            if (!appArchive.exists("META-INF/application.xml")) {
                if (aModule.getModuleType().equals(DOLUtils.warType())) {
                    WebBundleDescriptor wbd = (WebBundleDescriptor) descriptor;
                    if (wbd.getContextRoot() != null && !wbd.getContextRoot().equals("")) {
                        aModule.setContextRoot(wbd.getContextRoot());
                    } else {
                        aModule.setContextRoot(aModule.getModuleName());
                    }
                }
            }
        } else {
            // Display a message only if we had a handle on the sub archive
            return false;
        }
    }
    // don't get processed further
    for (ModuleDescriptor nonexistentModule : nonexistentModules) {
        app.removeModule(nonexistentModule);
    }
    return true;
}
Also used : DOLUtils.setExtensionArchivistForSubArchivist(com.sun.enterprise.deployment.util.DOLUtils.setExtensionArchivistForSubArchivist) HashMap(java.util.HashMap) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) DeploymentDescriptorFile(com.sun.enterprise.deployment.io.DeploymentDescriptorFile) ApplicationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ApplicationDeploymentDescriptorFile) ConfigurationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile) ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with RootDeploymentDescriptor

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

the class AbstractBundleNode method setSpecVersion.

/**
 * Sets the specVersion for this descriptor depending on the docType
 */
protected void setSpecVersion() {
    if (docType == null)
        return;
    StringTokenizer st = new StringTokenizer(docType, "//");
    while (st.hasMoreElements()) {
        String tmp = st.nextToken();
        if (tmp.startsWith("DTD")) {
            // this is the string we are interested in
            StringTokenizer versionST = new StringTokenizer(tmp);
            while (versionST.hasMoreElements()) {
                String versionStr = versionST.nextToken();
                try {
                    Float.valueOf(versionStr);
                    RootDeploymentDescriptor rdd = (RootDeploymentDescriptor) getDescriptor();
                    rdd.setSpecVersion(versionStr);
                    return;
                } catch (NumberFormatException nfe) {
                // ignore, this is just the other info of the publicID
                }
            }
        }
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor)

Aggregations

RootDeploymentDescriptor (org.glassfish.deployment.common.RootDeploymentDescriptor)24 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)9 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)6 ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)6 HashMap (java.util.HashMap)3 Application (com.sun.enterprise.deployment.Application)2 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)2 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)2 PersistenceUnitDescriptor (com.sun.enterprise.deployment.PersistenceUnitDescriptor)2 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)2 PrincipalNameDescriptor (com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor)2 StringTokenizer (java.util.StringTokenizer)2 ArchiveType (org.glassfish.api.deployment.archive.ArchiveType)2 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)2 ArchiveFactory (com.sun.enterprise.deploy.shared.ArchiveFactory)1 DataSourceDefinitionDescriptor (com.sun.enterprise.deployment.DataSourceDefinitionDescriptor)1 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)1 PersistenceUnitsDescriptor (com.sun.enterprise.deployment.PersistenceUnitsDescriptor)1 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)1 EjbBundleContext (com.sun.enterprise.deployment.annotation.context.EjbBundleContext)1