use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.
the class PostStateCommand method execute.
@Override
public void execute(AdminCommandContext context) {
ActionReport report = context.getActionReport();
final Logger logger = context.getLogger();
try {
logger.log(Level.INFO, "PostState starting: " + this.getClass().getName());
final ExtendedDeploymentContext dc;
if (suppInfo == null) {
throw new IllegalStateException("Internal Error: suppInfo was not set. Insure that it is set properly.");
} else {
dc = suppInfo.deploymentContext();
}
if (dc == null) {
return;
}
final InterceptorNotifier notifier = new InterceptorNotifier(habitat, dc);
try {
notifier.ensureAfterReported(ExtendedDeploymentContext.Phase.REPLICATION);
logger.log(Level.INFO, "PostStateCommand: " + this.getClass().getName() + " finished successfully");
} catch (Exception e) {
report.failure(logger, e.getMessage());
logger.log(Level.SEVERE, "Error during inner PostState: " + this.getClass().getName(), e);
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Error duirng outer PostState: " + this.getClass().getName(), e);
} finally {
// null out to prevent class loader leaks as the suppInfo holds a reference to the Deployment Context
// which holds a reference to the WebAppClassloader and this instance can be cached
suppInfo = null;
accessChecks = null;
}
}
use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.
the class PostUndeployCommand method execute.
@Override
public void execute(AdminCommandContext context) {
final Logger logger = context.getLogger();
logger.log(Level.INFO, "PostUndeployCommand starting");
try {
ActionReport report = context.getActionReport();
final DeployCommandSupplementalInfo suppInfo = context.getActionReport().getResultType(DeployCommandSupplementalInfo.class);
/*
* If the user undeployed by specifying the target as "domain" then
* the undeploy command has already explicitly sent the undeploy command
* to the instances and has notified the after(replication) listeners.
* In that case, the suppInfo won't have been set in the deployment
* context.
*/
if (suppInfo == null) {
return;
}
final ExtendedDeploymentContext dc = suppInfo.deploymentContext();
final InterceptorNotifier notifier = new InterceptorNotifier(habitat, dc);
try {
notifier.ensureAfterReported(ExtendedDeploymentContext.Phase.REPLICATION);
logger.log(Level.INFO, "PostUndeployCommand done successfully");
} catch (Exception e) {
report.failure(logger, e.getMessage());
logger.log(Level.SEVERE, "Error in inner PostUndeployCommand", e);
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Error in outer PostUndeployCommand", e);
}
}
use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.
the class PermsArchiveDelegate method processModuleDeclaredAndEEPemirssions.
/**
* Get the declared permissions and EE permissions, then add them to the classloader
*
* @param type module type
* @param context deployment context
* @param classloader throws AccessControlException if caller has no privilege
*/
public static void processModuleDeclaredAndEEPemirssions(SMGlobalPolicyUtil.CommponentType type, DeploymentContext context, ClassLoader classloader) throws SecurityException {
if (System.getSecurityManager() != null) {
if (!(classloader instanceof DDPermissionsLoader))
return;
if (!(context instanceof ExtendedDeploymentContext))
return;
DDPermissionsLoader ddcl = (DDPermissionsLoader) classloader;
if (((ExtendedDeploymentContext) context).getParentContext() == null) {
PermissionCollection declPc = getDeclaredPermissions(type, context);
ddcl.addDeclaredPermissions(declPc);
}
PermissionCollection eePc = processEEPermissions(type, context);
ddcl.addEEPermissions(eePc);
}
}
use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.
the class EjbApplication method stop.
public boolean stop(ApplicationContext stopContext) {
DeploymentContext depc = (DeploymentContext) stopContext;
OpsParams params = depc.getCommandParameters(OpsParams.class);
boolean keepState = false;
// keepstate remains the default value (false).
if (params.origin.isUndeploy()) {
keepState = resolveKeepStateOptions(depc, false, ejbBundle);
if (keepState) {
Properties appProps = depc.getAppProps();
Object appId = appProps.get(EjbDeployer.APP_UNIQUE_ID_PROP);
Properties actionReportProps = null;
if (ejbBundle.getApplication().isVirtual()) {
actionReportProps = depc.getActionReport().getExtraProperties();
} else {
// the application is EAR
ExtendedDeploymentContext exdc = (ExtendedDeploymentContext) depc;
actionReportProps = exdc.getParentContext().getActionReport().getExtraProperties();
}
actionReportProps.put(EjbDeployer.APP_UNIQUE_ID_PROP, appId);
actionReportProps.put(EjbApplication.KEEP_STATE, String.valueOf(true));
_logger.log(Level.INFO, "keepstate options resolved to true, saving appId {0} for application {1}.", new Object[] { appId, params.name() });
}
}
// If true we're shutting down b/c of an undeploy or a fatal error during
// deployment. If false, it's a shutdown where the application will remain
// deployed.
boolean undeploy = (params.origin.isUndeploy() || params.origin.isDeploy());
// and Application. For failed deploy, keepstate is the default value (false).
if (undeploy) {
// store keepstate in ApplicationInfo to make it available to
// EjbDeployer.clean(). A different instance of DeploymentContext
// is passed to EjbDeployer.clean so we cannot use anything in DC (e.g.
// appProps, transientData) to store keepstate.
ApplicationRegistry appRegistry = services.getService(ApplicationRegistry.class);
ApplicationInfo appInfo = appRegistry.get(params.name());
appInfo.addTransientAppMetaData(KEEP_STATE, keepState);
// store keepState in Application to make it available to subsequent
// undeploy-related methods.
ejbBundle.getApplication().setKeepStateResolved(String.valueOf(keepState));
}
// First, shutdown any singletons that were initialized based
// on a particular ordering dependency.
// TODO Make sure this covers both eagerly and lazily initialized
// Singletons.
singletonLCM.doShutdown();
for (Container container : containers) {
if (undeploy) {
container.undeploy();
} else {
container.onShutdown();
}
if (container.getSecurityManager() != null) {
container.getSecurityManager().destroy();
}
}
containers.clear();
return true;
}
use of org.glassfish.internal.deployment.ExtendedDeploymentContext 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;
}
Aggregations