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);
}
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;
}
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;
}
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;
}
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);
}
Aggregations