use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class DescriptorArchivist method write.
/**
* writes an application deployment descriptors
* @param the application object
* @param the abstract archive
*/
public void write(Application application, ReadableArchive in, WritableArchive out) throws IOException {
if (application.isVirtual()) {
ModuleDescriptor aModule = (ModuleDescriptor) application.getModules().iterator().next();
Archivist moduleArchivist = archivistFactory.getArchivist(aModule.getModuleType());
write((BundleDescriptor) aModule.getDescriptor(), moduleArchivist, in, out);
} else {
// let's start by writing out all submodules deployment descriptors
for (ModuleDescriptor aModule : application.getModules()) {
Archivist moduleArchivist = archivistFactory.getArchivist(aModule.getModuleType());
WritableArchive moduleArchive = out.createSubArchive(aModule.getArchiveUri());
ReadableArchive moduleArchive2 = in.getSubArchive(aModule.getArchiveUri());
write((BundleDescriptor) aModule.getDescriptor(), moduleArchivist, moduleArchive2, moduleArchive);
}
// now let's write the application descriptor
ApplicationArchivist archivist = archivistProvider.get();
archivist.setDescriptor(application);
archivist.writeDeploymentDescriptors(in, out);
}
}
use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class DolProvider method processDOL.
private Application processDOL(DeploymentContext dc) throws IOException {
ReadableArchive sourceArchive = dc.getSource();
sourceArchive.setExtraData(Types.class, dc.getTransientAppMetaData(Types.class.getName(), Types.class));
sourceArchive.setExtraData(Parser.class, dc.getTransientAppMetaData(Parser.class.getName(), Parser.class));
Optional<ApplicationState> appState = hotDeployService.getApplicationState(dc);
appState.ifPresent(state -> sourceArchive.setExtraData(ApplicationState.class, state));
ClassLoader cl = dc.getClassLoader();
DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
sourceArchive.addArchiveMetaData(DeploymentProperties.APP_PROPS, dc.getAppProps());
sourceArchive.addArchiveMetaData(DeploymentProperties.COMMAND_PARAMS, params);
String name = params.name();
String archiveType = dc.getArchiveHandler().getArchiveType();
Archivist archivist = archivistFactory.getArchivist(archiveType, cl);
if (archivist == null) {
// an empty Application object
return Application.createApplication();
}
archivist.setAnnotationProcessingRequested(true);
String xmlValidationLevel = dasConfig.getDeployXmlValidation();
archivist.setXMLValidationLevel(xmlValidationLevel);
if (xmlValidationLevel.equals("none")) {
archivist.setXMLValidation(false);
}
archivist.setRuntimeXMLValidationLevel(xmlValidationLevel);
if (xmlValidationLevel.equals("none")) {
archivist.setRuntimeXMLValidation(false);
}
Collection<Sniffer> sniffers = dc.getTransientAppMetaData(DeploymentProperties.SNIFFERS, Collection.class);
archivist.setExtensionArchivists(archivistFactory.getExtensionsArchivists(sniffers, archivist.getModuleType()));
ApplicationHolder holder = dc.getModuleMetaData(ApplicationHolder.class);
File deploymentPlan = params.deploymentplan;
handleDeploymentPlan(deploymentPlan, archivist, sourceArchive, holder);
long start = System.currentTimeMillis();
Application application = appState.map(state -> state.getModuleMetaData(Application.class)).orElse(holder != null ? holder.app : null);
if (application != null) {
application.setAppName(name);
application.setClassLoader(cl);
application.setRoleMapper(null);
if (application.isVirtual()) {
ModuleDescriptor md = application.getStandaloneBundleDescriptor().getModuleDescriptor();
md.setModuleName(name);
if (appState.map(ApplicationState::isActive).orElse(false)) {
application.getStandaloneBundleDescriptor().setClassLoader(cl);
dc.addModuleMetaData(application.getStandaloneBundleDescriptor());
for (RootDeploymentDescriptor extension : application.getStandaloneBundleDescriptor().getExtensionsDescriptors()) {
extension.setClassLoader(cl);
dc.addModuleMetaData(extension);
}
}
}
try {
applicationFactory.openWith(application, sourceArchive, archivist);
} catch (SAXParseException e) {
throw new IOException(e);
}
} else {
// and it's a standalone module
try {
application = applicationFactory.openArchive(name, archivist, sourceArchive, true);
application.setAppName(name);
ModuleDescriptor md = application.getStandaloneBundleDescriptor().getModuleDescriptor();
md.setModuleName(name);
} catch (SAXParseException e) {
throw new IOException(e);
}
}
application.setRegistrationName(name);
sourceArchive.removeExtraData(Types.class);
sourceArchive.removeExtraData(Parser.class);
Logger.getAnonymousLogger().log(FINE, "DOL Loading time{0}", System.currentTimeMillis() - start);
return application;
}
use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class DolProvider method saveAppDescriptor.
protected void saveAppDescriptor(Application application, DeploymentContext context) throws IOException {
if (application != null) {
ReadableArchive archive = archiveFactory.openArchive(context.getSourceDir());
boolean isMkdirs = context.getScratchDir("xml").mkdirs();
if (isMkdirs) {
WritableArchive archive2 = archiveFactory.createArchive(context.getScratchDir("xml"));
descriptorArchivist.write(application, archive, archive2);
// copy the additional webservice elements etc
applicationArchivist.copyExtraElements(archive, archive2);
} else {
context.getLogger().log(Level.WARNING, "Error in creating directory " + context.getScratchDir("xml").getAbsolutePath());
}
}
}
use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class JavaEEDeployer method getModuleClassPath.
/**
* Returns the classpath associated with this module
* Can be used to compile generated cmp classes,
* rmi stubs etc.
*
* @return the classpath for this module
*/
protected String getModuleClassPath(DeploymentContext ctx) {
// get the base module classpath
// this includes the system classpath and deploy time lib libraries
StringBuilder classpath = new StringBuilder(ASClassLoaderUtil.getModuleClassPath(habitat, ctx));
try {
// add the module dir
classpath.append(ctx.getSourceDir().toPath().toString());
classpath.append(File.pathSeparator);
// add the stubs dir
classpath.append(ctx.getScratchDir("ejb").toPath().toString());
classpath.append(File.pathSeparator);
// add the ear lib libraries if it's ear
Application app = ctx.getModuleMetaData(Application.class);
if (!app.isVirtual()) {
ReadableArchive parentArchive = ctx.getSource().getParentArchive();
String compatProp = ctx.getAppProps().getProperty(DeploymentProperties.COMPATIBILITY);
List<URL> earLibURLs = ASClassLoaderUtil.getAppLibDirLibrariesAsList(new File(parentArchive.getURI()), app.getLibraryDirectory(), compatProp);
for (URL url : earLibURLs) {
classpath.append(Paths.get(url.toURI()).toString());
classpath.append(File.pathSeparator);
}
}
} catch (Exception e) {
// log a warning
}
return classpath.toString();
}
use of org.glassfish.api.deployment.archive.ReadableArchive in project Payara by payara.
the class OpenApiService method registerApp.
public void registerApp(String applicationId, DeploymentContext ctx) {
final WebBundleDescriptorImpl descriptor = ctx.getModuleMetaData(WebBundleDescriptorImpl.class);
final String contextRoot = descriptor.getContextRoot();
final ReadableArchive archive = ctx.getSource();
final ClassLoader classLoader = ctx.getClassLoader();
documents.put(applicationId, new OpenAPISupplier(applicationId, contextRoot, archive, classLoader));
cachedResult = null;
}
Aggregations