use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class PipeHelper method getClientModuleID.
private static String getClientModuleID(ServiceReferenceDescriptor srd) {
String rvalue = "#default-client-context#";
if (srd != null) {
ModuleDescriptor md = null;
BundleDescriptor bd = (BundleDescriptor) srd.getBundleDescriptor();
if (bd != null) {
md = bd.getModuleDescriptor();
}
Application a = (bd == null) ? null : bd.getApplication();
if (a != null) {
if (a.isVirtual()) {
rvalue = a.getRegistrationName();
} else if (md != null) {
rvalue = FileUtils.makeFriendlyFilename(md.getArchiveUri());
}
} else if (md != null) {
rvalue = FileUtils.makeFriendlyFilename(md.getArchiveUri());
}
}
return rvalue;
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class BaseVerifier method createDocumentObject.
protected void createDocumentObject(Descriptor descriptor) throws IOException, ParserConfigurationException, SAXException {
InputStream is = null;
InputSource source = null;
String archBase = new File(context.getAbstractArchive().getURI()).getAbsolutePath();
String uri = null;
if (descriptor instanceof Application) {
uri = archBase;
} else {
BundleDescriptor bundleDesc = BundleDescriptor.class.cast(descriptor);
if (bundleDesc.getModuleDescriptor().isStandalone()) {
uri = archBase;
} else {
uri = archBase + File.separator + getArchiveUri();
}
}
String[] dd = getDDString();
for (int i = 0; i < dd.length; i++) {
try {
is = getInputStreamFromAbstractArchive(uri, dd[i]);
if (is != null) {
source = new InputSource(is);
createDOMObject(source, dd[i]);
is.close();
}
} finally {
try {
if (is != null) {
is.close();
}
} catch (Exception e) {
}
}
}
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class DescriptorFactory method createApplicationDescriptor.
/**
* Returns the parsed DOL object from archive
*
* @param archiveFile original archive file
* @param destRootDir root destination directory where the application
* should be expanded under in case of archive deployment
* @param parentCl parent classloader
*
* @return the parsed DOL object
*/
public ResultHolder createApplicationDescriptor(File archiveFile, File destRootDir, ClassLoader parentCl) throws IOException {
ReadableArchive archive = null;
Application application = null;
try {
Descriptor.setBoundsChecking(false);
archive = archiveFactory.openArchive(archiveFile);
ArchiveHandler archiveHandler = deployment.getArchiveHandler(archive);
ActionReport dummyReport = new HTMLActionReporter();
String appName = DeploymentUtils.getDefaultEEName(archiveFile.getName());
DeployCommandParameters params = new DeployCommandParameters();
params.name = appName;
ExtendedDeploymentContext context = new DeploymentContextImpl(dummyReport, archive, params, env);
context.setArchiveHandler(archiveHandler);
if (!archiveFile.isDirectory()) {
// expand archive
File destDir = new File(destRootDir, appName);
if (destDir.exists()) {
FileUtils.whack(destDir);
}
destDir.mkdirs();
archiveHandler.expand(archive, archiveFactory.createArchive(destDir), context);
archive.close();
archive = archiveFactory.openArchive(destDir);
context.setSource(archive);
}
// issue 14564
context.addTransientAppMetaData(ExtendedDeploymentContext.IS_TEMP_CLASSLOADER, Boolean.TRUE);
String archiveType = context.getArchiveHandler().getArchiveType();
ClassLoader cl = archiveHandler.getClassLoader(parentCl, context);
Archivist archivist = archivistFactory.getArchivist(archiveType, cl);
if (archivist == null) {
throw new IOException("Cannot determine the Java EE module type for " + archive.getURI());
}
archivist.setAnnotationProcessingRequested(true);
String xmlValidationLevel = dasConfig.getDeployXmlValidation();
archivist.setXMLValidationLevel(xmlValidationLevel);
if (xmlValidationLevel.equals("none")) {
archivist.setXMLValidation(false);
}
archivist.setRuntimeXMLValidation(false);
try {
application = applicationFactory.openArchive(appName, archivist, archive, true);
} catch (SAXParseException e) {
throw new IOException(e);
}
if (application != null) {
application.setClassLoader(cl);
application.visit((ApplicationVisitor) new ApplicationValidator());
}
} finally {
if (archive != null) {
archive.close();
}
// We need to reset it after descriptor building
Descriptor.setBoundsChecking(true);
}
ResultHolder result = new ResultHolder();
result.application = application;
result.archive = archive;
return result;
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class VirtualServer method createSystemDefaultWebModuleIfNecessary.
/**
* If a default web module has not yet been configured and added to this
* virtual server's list of web modules then return the configuration
* information needed in order to create a default web module for this
* virtual server.
*
* This method should be invoked only after all the standalone modules
* and the modules within j2ee-application elements have been added to
* this virtual server's list of modules (only then will one know whether
* the user has already configured a default web module or not).
* @param webArchivist
* @return
*/
public WebModuleConfig createSystemDefaultWebModuleIfNecessary(WebArchivist webArchivist) {
WebModuleConfig wmInfo = null;
// Add a default context only if one hasn't already been loaded
// and then too only if docroot is not null
//
String docroot = getAppBase();
if (getDefaultWebModuleID() == null && findChild("") == null && docroot != null) {
final WebBundleDescriptorImpl wbd = webArchivist.getDefaultWebXmlBundleDescriptor();
wmInfo = new WebModuleConfig();
wbd.setModuleID(Constants.DEFAULT_WEB_MODULE_NAME);
wbd.setContextRoot("");
wmInfo.setLocation(new File(docroot));
wmInfo.setDescriptor(wbd);
wmInfo.setParentLoader(serverContext.getCommonClassLoader());
if (wbd.getApplication() == null) {
Application application = Application.createApplication();
application.setVirtual(true);
application.setName(Constants.DEFAULT_WEB_MODULE_NAME);
wbd.setApplication(application);
}
WebappClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {
@Override
public WebappClassLoader run() {
return new WebappClassLoader(serverContext.getCommonClassLoader(), wbd.getApplication());
}
});
loader.start();
wmInfo.setAppClassLoader(loader);
}
return wmInfo;
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class VirtualServer method findWebModuleInJ2eeApp.
/**
* Finds and returns information about a web module embedded within a
* J2EE application, which is identified by a string of the form
* <code>a:b</code> or <code>a#b</code>, where <code>a</code> is the name
* of the J2EE application and <code>b</code> is the name of the embedded
* web module.
*
* @param appsBean
* @param id
* @return null if <code>id</code> does not identify a web module embedded
* within a J2EE application.
*/
protected WebModuleConfig findWebModuleInJ2eeApp(Applications appsBean, String id, ApplicationRegistry appRegistry) {
WebModuleConfig wmInfo = null;
// Check for ':' separator
int separatorIndex = id.indexOf(Constants.NAME_SEPARATOR);
if (separatorIndex == -1) {
// Check for '#' separator
separatorIndex = id.indexOf('#');
}
if (separatorIndex != -1) {
String appID = id.substring(0, separatorIndex);
String moduleID = id.substring(separatorIndex + 1);
com.sun.enterprise.config.serverbeans.Application appBean = appsBean.getModule(com.sun.enterprise.config.serverbeans.Application.class, appID);
if ((appBean != null) && Boolean.valueOf(appBean.getEnabled())) {
String location = appBean.getLocation();
String moduleDir = DeploymentUtils.getRelativeEmbeddedModulePath(location, moduleID);
ApplicationInfo appInfo = appRegistry.get(appID);
final Application app = appInfo != null ? appInfo.getMetaData(Application.class) : null;
if (appInfo == null) {
// XXX ApplicaionInfo is NULL after restart
Object[] params = { id, getID() };
_logger.log(Level.SEVERE, LogFacade.VS_DEFAULT_WEB_MODULE_DISABLED, params);
return wmInfo;
}
final WebBundleDescriptorImpl wbd = app.getModuleByTypeAndUri(WebBundleDescriptorImpl.class, moduleID);
String webUri = wbd.getModuleDescriptor().getArchiveUri();
String contextRoot = wbd.getModuleDescriptor().getContextRoot();
if (moduleID.equals(webUri)) {
StringBuilder dir = new StringBuilder(location);
dir.append(File.separator);
dir.append(moduleDir);
File docroot = new File(dir.toString());
wmInfo = new WebModuleConfig();
wbd.setName(moduleID);
wbd.setContextRoot(contextRoot);
wmInfo.setDescriptor(wbd);
wmInfo.setLocation(docroot);
wmInfo.setParentLoader(EmbeddedWebContainer.class.getClassLoader());
WebappClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {
@Override
public WebappClassLoader run() {
return new WebappClassLoader(EmbeddedWebContainer.class.getClassLoader(), app);
}
});
wmInfo.setAppClassLoader(cloader);
}
} else {
Object[] params = { id, getID() };
_logger.log(Level.SEVERE, LogFacade.VS_DEFAULT_WEB_MODULE_DISABLED, params);
}
}
return wmInfo;
}
Aggregations