Search in sources :

Example 6 with Container

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;
}
Also used : DeploymentContext(org.glassfish.api.deployment.DeploymentContext) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) Container(com.sun.ejb.Container) AbstractSingletonContainer(com.sun.ejb.containers.AbstractSingletonContainer) ApplicationContainer(org.glassfish.api.deployment.ApplicationContainer) OpsParams(org.glassfish.api.deployment.OpsParams) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Properties(java.util.Properties) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext)

Example 7 with Container

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;
}
Also used : Container(com.sun.ejb.Container) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor)

Aggregations

Container (com.sun.ejb.Container)7 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)4 AbstractSingletonContainer (com.sun.ejb.containers.AbstractSingletonContainer)3 ApplicationContainer (org.glassfish.api.deployment.ApplicationContainer)3 DeploymentContext (org.glassfish.api.deployment.DeploymentContext)3 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)3 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)3 EJBException (javax.ejb.EJBException)2 NoSuchEJBException (javax.ejb.NoSuchEJBException)2 ContainerFactory (com.sun.ejb.ContainerFactory)1 JDOFatalUserException (com.sun.jdo.api.persistence.support.JDOFatalUserException)1 PersistenceManagerFactoryImpl (com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerFactoryImpl)1 Iterator (java.util.Iterator)1 Properties (java.util.Properties)1 EJBLocalObject (javax.ejb.EJBLocalObject)1 EJBObject (javax.ejb.EJBObject)1 InitialContext (javax.naming.InitialContext)1 NamingException (javax.naming.NamingException)1 DataSource (javax.sql.DataSource)1 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)1