// Both undeploy and shutdown scenarios are
// handled directly in EjbApplication.shutdown.
// But CMP drop tables should be handled here.
OpsParams params = dc.getCommandParameters(OpsParams.class);
if ( (params.origin.isUndeploy() || params.origin.isDeploy()) && isDas()) {
// If CMP beans are present, cmpDeployer should've been initialized in unload()
if (cmpDeployer != null) {
cmpDeployer.clean(dc);
}
Properties appProps = dc.getAppProps();
String uniqueAppId = appProps.getProperty(APP_UNIQUE_ID_PROP);
try {
if (getTimeoutStatusFromApplicationInfo(params.name()) && uniqueAppId != null) {
String target = ((params.origin.isDeploy())?
dc.getCommandParameters(DeployCommandParameters.class).target :
dc.getCommandParameters(UndeployCommandParameters.class).target);
if (DeploymentUtils.isDomainTarget(target)) {
List<String> targets = (List<String>)dc.getTransientAppMetaData(DeploymentProperties.PREVIOUS_TARGETS, List.class);
if (targets == null) {
targets = domain.getAllReferencedTargetsForApplication(params.name());
}
if (targets != null && targets.size() > 0) {
target = targets.get(0);
}
}
EJBTimerService timerService = EJBTimerService.getEJBTimerService(target, false);
if (_logger.isLoggable(Level.FINE)) {
_logger.log( Level.FINE, "EjbDeployer APP ID of a Timeout App? " + uniqueAppId);
_logger.log( Level.FINE, "EjbDeployer TimerService: " + timerService);
}
if(timerService == null) {
_logger.log( Level.WARNING, "EJB Timer Service is not available. Timers for application with id " +
uniqueAppId + " will not be deleted");
} else {
if (getKeepStateFromApplicationInfo(params.name())) {
_logger.log(Level.INFO,
"Timers will not be destroyed since keepstate is true for application {0}",
params.name());
} else {
timerService.destroyAllTimers(Long.parseLong(uniqueAppId));
}
}
}
} catch (Exception e) {
_logger.log( Level.WARNING, "Failed to delete timers for application with id " + uniqueAppId, e);
}
}
//Security related cleanup is to be done for the undeploy event
if( params.origin.isUndeploy()|| params.origin.isDeploy() || params.origin.isLoad()) {
//Removing EjbSecurityManager for undeploy case
String appName = params.name();
String[] contextIds =
ejbSecManagerFactory.getContextsForApp(appName, false);
if (contextIds != null) {
for (String contextId : contextIds) {
try {