use of org.glassfish.enterprise.iiop.api.RemoteReferenceFactory in project Payara by payara.
the class SafeProperties method createRemoteReferenceWithId.
/**
* Create an EJBObject reference from the instanceKey
* Called from EJBObjectOutputStream.SerializableRemoteRef
* during deserialization of a remote-ref
* @param instanceKey instanceKey of the ejbobject
* @param generatedRemoteBusinessIntf non-null, this is a remote business view and the param
* is the name of the generated remote business interface.
* Otherwise, this is for the RemoteHome view
*/
public java.rmi.Remote createRemoteReferenceWithId(byte[] instanceKey, String generatedRemoteBusinessIntf) {
final Thread currentThread = Thread.currentThread();
final ClassLoader previousClassLoader = currentThread.getContextClassLoader();
final ClassLoader myClassLoader = loader;
try {
if (System.getSecurityManager() == null) {
currentThread.setContextClassLoader(myClassLoader);
} else {
java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
public java.lang.Object run() {
currentThread.setContextClassLoader(myClassLoader);
return null;
}
});
}
java.rmi.Remote remoteRef = null;
if (generatedRemoteBusinessIntf == null) {
remoteRef = remoteHomeRefFactory.createRemoteReference(instanceKey);
} else {
RemoteReferenceFactory remoteBusinessRefFactory = remoteBusinessIntfInfo.get(generatedRemoteBusinessIntf).referenceFactory;
remoteRef = remoteBusinessRefFactory.createRemoteReference(instanceKey);
}
return remoteRef;
} finally {
if (System.getSecurityManager() == null) {
currentThread.setContextClassLoader(previousClassLoader);
} else {
java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
public java.lang.Object run() {
currentThread.setContextClassLoader(previousClassLoader);
return null;
}
});
}
}
}
use of org.glassfish.enterprise.iiop.api.RemoteReferenceFactory in project Payara by payara.
the class SafeProperties method doContainerCleanup.
/**
* Perform common container shutdown actions. NOTE that this should be done
* defensively so that we attempt to do as much cleanup as possible, even
* in the face of errors. This might be called after
* an unsuccessful deployment, in which case some of the services might
* not have been initialized.
*/
private void doContainerCleanup() {
if (baseContainerCleanupDone) {
return;
}
try {
if (isWebServiceEndpoint && (webServiceEndpoint != null)) {
String endpointAddress = webServiceEndpoint.getEndpointAddressUri();
if (wsejbEndpointRegistry != null) {
wsejbEndpointRegistry.unregisterEndpoint(endpointAddress);
}
}
// NOTE : Pipe cleanup that used to done here is now encapsulated within
// endpoint registry unregisterEndpoint operation
} catch (Exception e) {
_logger.log(Level.FINE, "Error unregistering ejb endpoint for " + ejbDescriptor.getName(), e);
}
if (hasAsynchronousInvocations) {
EjbAsyncInvocationManager asyncManager = ((EjbContainerUtilImpl) ejbContainerUtilImpl).getEjbAsyncInvocationManager();
asyncManager.cleanupContainerTasks(this);
}
final Thread currentThread = Thread.currentThread();
final ClassLoader previousClassLoader = currentThread.getContextClassLoader();
// Unpublish all portable and non-portable JNDI names
for (Map.Entry<String, JndiInfo> entry : jndiInfoMap.entrySet()) {
JndiInfo jndiInfo = entry.getValue();
try {
jndiInfo.unpublish(this.namingManager);
} catch (Exception e) {
_logger.log(Level.FINE, "Error while unbinding JNDI name " + jndiInfo.name + " for EJB : " + this.ejbDescriptor.getName(), e);
}
}
try {
if (System.getSecurityManager() == null) {
currentThread.setContextClassLoader(loader);
} else {
java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
public java.lang.Object run() {
currentThread.setContextClassLoader(loader);
return null;
}
});
}
if (isRemote) {
try {
if (hasRemoteHomeView) {
remoteHomeRefFactory.destroyReference(ejbHomeStub, ejbHome);
// Hints to release stub-related meta-data in ORB
remoteHomeRefFactory.cleanupClass(homeIntf);
remoteHomeRefFactory.cleanupClass(remoteIntf);
remoteHomeRefFactory.cleanupClass(ejbHome.getClass());
remoteHomeRefFactory.cleanupClass(ejbObjectProxyClass);
// destroy the factory itself
remoteHomeRefFactory.destroy();
}
if (hasRemoteBusinessView) {
// Home related cleanup
RemoteReferenceFactory remoteBusinessRefFactory = remoteBusinessIntfInfo.values().iterator().next().referenceFactory;
remoteBusinessRefFactory.destroyReference(ejbRemoteBusinessHomeStub, ejbRemoteBusinessHome);
remoteBusinessRefFactory.cleanupClass(remoteBusinessHomeIntf);
remoteBusinessRefFactory.cleanupClass(ejbRemoteBusinessHome.getClass());
// Cleanup for each remote business interface
for (RemoteBusinessIntfInfo next : remoteBusinessIntfInfo.values()) {
next.referenceFactory.cleanupClass(next.generatedRemoteIntf);
next.referenceFactory.cleanupClass(next.proxyClass);
// destroy the factory itself
next.referenceFactory.destroy();
}
}
} catch (Exception ex) {
_logger.log(Level.FINE, "Exception during undeploy", logParams);
_logger.log(Level.FINE, "", ex);
}
}
try {
ejbContainerUtilImpl.getComponentEnvManager().unbindFromComponentNamespace(ejbDescriptor);
} catch (javax.naming.NamingException namEx) {
_logger.log(Level.FINE, "Exception during undeploy", logParams);
_logger.log(Level.FINE, "", namEx);
}
ejbContainerUtilImpl.unregisterContainer(this);
unregisterProbeListeners();
} finally {
if (System.getSecurityManager() == null) {
currentThread.setContextClassLoader(previousClassLoader);
} else {
java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
public java.lang.Object run() {
currentThread.setContextClassLoader(previousClassLoader);
return null;
}
});
}
}
baseContainerCleanupDone = true;
_logger.log(Level.FINE, "**** [BaseContainer]: Successfully Undeployed " + ejbDescriptor.getName() + " ...");
}
Aggregations