use of com.sun.ejb.Container 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 com.sun.ejb.Container in project Payara by payara.
the class EjbContainerServicesImpl method getBusinessObject.
public <S> S getBusinessObject(Object ejbRef, java.lang.Class<S> businessInterface) {
EJBLocalObjectImpl localObjectImpl = getEJBLocalObject(ejbRef);
if (localObjectImpl == null) {
throw new IllegalStateException("Invalid ejb ref");
}
Container container = localObjectImpl.getContainer();
EjbDescriptor ejbDesc = container.getEjbDescriptor();
S businessObject = null;
if (businessInterface != null) {
String intfName = businessInterface.getName();
if (ejbDesc.getLocalBusinessClassNames().contains(intfName)) {
// Get proxy corresponding to this business interface.
businessObject = (S) localObjectImpl.getClientObject(intfName);
} else if (ejbDesc.isLocalBean()) {
// If this is a no-interface view session bean, the bean
// can be accessed through interfaces in its superclass as well
boolean isValidBusinessInterface = ejbDesc.getNoInterfaceLocalBeanClasses().contains(intfName);
if ((intfName.equals(ejbDesc.getEjbClassName())) || isValidBusinessInterface) {
businessObject = (S) localObjectImpl.getClientObject(ejbDesc.getEjbClassName());
}
}
}
if (businessObject == null) {
throw new IllegalStateException("Unable to convert ejbRef for ejb " + ejbDesc.getName() + " to a business object of type " + businessInterface);
}
return businessObject;
}
Aggregations