FileDocCategorySizeDatePackage
StartStopCallback.javaAPI DocGlassfish v2 API9306Fri May 04 22:24:36 BST 2007com.sun.enterprise.management.util

StartStopCallback

public class StartStopCallback extends Object
J2EEModuleCallBack will invoke corresponding methods in this class. Instantiates the mBean of corresponding module or application and invokes the start or stop method appropriately.
version
1.0 26mar2003
author
Sreenivas Munnangi

Fields Summary
private static boolean
debug
Constructors Summary
Methods Summary
private booleanstandAlone(J2EEDeployedObjectMdl modObject)


        try {
            ObjectName objName = new ObjectName(modObject.getobjectName());
            String appName = objName.getKeyProperty("J2EEApplication");

            if ((appName == null) || (appName.length() < 1) ||
                    (appName.equals("null")) || (appName.equals("NULL")) ||
                    (appName.equals(""))) {
                return true;
            }
        } catch (Exception e) {
            throw new MBeanException(e);
        }

        return false;
    
private voidstartApplication(java.lang.String appID, java.lang.String serverName)


        try {
            ManagedJ2EEApplication mApp = new ManagedJ2EEApplication(serverName,
                    appID);
            mApp.start();
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
private voidstartEJBModule(java.lang.String moduleID, java.lang.String serverName)

        try {
            ManagedStandaloneJ2EEEjbJarModule msejbModule = new ManagedStandaloneJ2EEEjbJarModule(serverName,
                    moduleID);
            msejbModule.start();
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voidstartModule(J2EEDeployedObjectMdl modObject)
Invokes appropriate start method based on j2ee type. If trying to start a module which is part of an application then it will throw exception.


                                  
       
          

        if (debug) {
            return;
        }

        String moduleID = modObject.getname();
        String j2eeType = modObject.getj2eeType();
        String serverName = modObject.getJ2EEServer();

        // check if trying to start a module which is part of the application
        if ((!j2eeType.equals(ManagementObjectManager.J2EE_TYPE_APPLICATION)) &&
                (!standAlone(modObject))) {
            throw new MBeanException( 
                  new Exception(
                  "cannot start individual module, start the application itself"));
        }

        if (j2eeType.equals(ManagementObjectManager.J2EE_TYPE_EJB_MODULE)) {
            startEJBModule(moduleID, serverName);
        } else if (j2eeType.equals(ManagementObjectManager.J2EE_TYPE_WEB_MODULE)) {
            startWEBModule(moduleID, serverName);
        } else if (j2eeType.equals(ManagementObjectManager.J2EE_TYPE_RAR_MODULE)) {
            startRARModule(moduleID, serverName);
        } else if (j2eeType.equals(ManagementObjectManager.J2EE_TYPE_ACC_MODULE)) {
            return;
        } else if (j2eeType.equals(ManagementObjectManager.J2EE_TYPE_APPLICATION)) {
            startApplication(moduleID, serverName);
        }
    
private voidstartRARModule(java.lang.String moduleID, java.lang.String serverName)


        try {
            ManagedStandaloneConnectorModule mscModule = new ManagedStandaloneConnectorModule(serverName,
                    moduleID);
            mscModule.start();
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
private voidstartWEBModule(java.lang.String moduleID, java.lang.String serverName)


        try {
            ManagedStandaloneJ2EEWebModule mswebModule = new ManagedStandaloneJ2EEWebModule(serverName,
                    moduleID);
            mswebModule.start();
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
private voidstopApplication(java.lang.String appID, java.lang.String serverName)


        try {
            ManagedJ2EEApplication mApp = new ManagedJ2EEApplication(serverName,
                    appID);
            mApp.stop();
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
private voidstopEJBModule(java.lang.String moduleID, java.lang.String serverName)


        try {
            ManagedStandaloneJ2EEEjbJarModule msejbModule = new ManagedStandaloneJ2EEEjbJarModule(serverName,
                    moduleID);
            msejbModule.stop();
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voidstopModule(J2EEDeployedObjectMdl modObject)
Invokes appropriate stop method based on j2ee type. If trying to stop a module which is part of an application then it will throw exception.


        if (debug) {
            return;
        }

        String moduleID = modObject.getname();
        String j2eeType = modObject.getj2eeType();
        String serverName = modObject.getJ2EEServer();

        // check if trying to stop a module which is part of the application
        if ((!j2eeType.equals(ManagementObjectManager.J2EE_TYPE_APPLICATION)) &&
                (!standAlone(modObject))) {
            throw new MBeanException(
                new Exception(
                "cannot stop individual module, stop the application itself"));
        }

        if (j2eeType.equals(ManagementObjectManager.J2EE_TYPE_EJB_MODULE)) {
            stopEJBModule(moduleID, serverName);
        } else if (j2eeType.equals(ManagementObjectManager.J2EE_TYPE_WEB_MODULE)) {
            stopWEBModule(moduleID, serverName);
        } else if (j2eeType.equals(ManagementObjectManager.J2EE_TYPE_RAR_MODULE)) {
            stopRARModule(moduleID, serverName);
        } else if (j2eeType.equals(ManagementObjectManager.J2EE_TYPE_ACC_MODULE)) {
            return;
        } else if (j2eeType.equals(ManagementObjectManager.J2EE_TYPE_APPLICATION)) {
            stopApplication(moduleID, serverName);
        }
    
private voidstopRARModule(java.lang.String moduleID, java.lang.String serverName)


        try {
            ManagedStandaloneConnectorModule mscModule = new ManagedStandaloneConnectorModule(serverName,
                    moduleID);
            mscModule.stop();
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
private voidstopWEBModule(java.lang.String moduleID, java.lang.String serverName)


        try {
            ManagedStandaloneJ2EEWebModule mswebModule = new ManagedStandaloneJ2EEWebModule(serverName,
                    moduleID);
            mswebModule.stop();
        } catch (Exception e) {
            throw new MBeanException(e);
        }