Search in sources :

Example 1 with RemoteReferenceFactory

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;
                }
            });
        }
    }
}
Also used : RemoteReferenceFactory(org.glassfish.enterprise.iiop.api.RemoteReferenceFactory) EJBLocalObject(javax.ejb.EJBLocalObject) EJBObject(javax.ejb.EJBObject)

Example 2 with RemoteReferenceFactory

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() + " ...");
}
Also used : RemoteReferenceFactory(org.glassfish.enterprise.iiop.api.RemoteReferenceFactory) NamingException(javax.naming.NamingException) TransactionRequiredLocalException(javax.ejb.TransactionRequiredLocalException) EJBAccessException(javax.ejb.EJBAccessException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EJBException(javax.ejb.EJBException) DeploymentException(org.glassfish.deployment.common.DeploymentException) AccessException(java.rmi.AccessException) AccessLocalException(javax.ejb.AccessLocalException) TransactionRolledbackLocalException(javax.ejb.TransactionRolledbackLocalException) SystemException(javax.transaction.SystemException) NoSuchEJBException(javax.ejb.NoSuchEJBException) NamingException(javax.naming.NamingException) RemoveException(javax.ejb.RemoveException) EJBTransactionRequiredException(javax.ejb.EJBTransactionRequiredException) EJBTransactionRolledbackException(javax.ejb.EJBTransactionRolledbackException) RemoteException(java.rmi.RemoteException) RollbackException(javax.transaction.RollbackException) FinderException(javax.ejb.FinderException) CreateException(javax.ejb.CreateException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException) EJBLocalObject(javax.ejb.EJBLocalObject) EJBObject(javax.ejb.EJBObject) Map(java.util.Map) MethodMap(com.sun.ejb.containers.util.MethodMap) HashMap(java.util.HashMap)

Aggregations

EJBLocalObject (javax.ejb.EJBLocalObject)2 EJBObject (javax.ejb.EJBObject)2 RemoteReferenceFactory (org.glassfish.enterprise.iiop.api.RemoteReferenceFactory)2 MethodMap (com.sun.ejb.containers.util.MethodMap)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 AccessException (java.rmi.AccessException)1 RemoteException (java.rmi.RemoteException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AccessLocalException (javax.ejb.AccessLocalException)1 CreateException (javax.ejb.CreateException)1 EJBAccessException (javax.ejb.EJBAccessException)1 EJBException (javax.ejb.EJBException)1 EJBTransactionRequiredException (javax.ejb.EJBTransactionRequiredException)1 EJBTransactionRolledbackException (javax.ejb.EJBTransactionRolledbackException)1 FinderException (javax.ejb.FinderException)1 NoSuchEJBException (javax.ejb.NoSuchEJBException)1 NoSuchObjectLocalException (javax.ejb.NoSuchObjectLocalException)1 RemoveException (javax.ejb.RemoveException)1 TransactionRequiredLocalException (javax.ejb.TransactionRequiredLocalException)1