@Override
public ContextHandle saveContext(ContextService contextService, Map<String, String> contextObjectProperties) {
// Capture the current thread context
ClassLoader contextClassloader = null;
AppServSecurityContext currentSecurityContext = null;
ComponentInvocation savedInvocation = null;
if (classloading) {
contextClassloader = Utility.getClassLoader();
}
if (security) {
currentSecurityContext = securityContext.getCurrentSecurityContext();
}
ComponentInvocation currentInvocation = invocationManager.getCurrentInvocation();
if (currentInvocation != null) {
savedInvocation = currentInvocation.clone();
savedInvocation.instance = currentInvocation.instance;
savedInvocation.setResourceTableKey(null);
if (!naming) {
savedInvocation.setJNDIEnvironment(null);
}