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