FileDocCategorySizeDatePackage
J2EEDeployedObjectMdl.javaAPI DocGlassfish v2 API7795Fri May 04 22:24:16 BST 2007com.sun.enterprise.management.model

J2EEDeployedObjectMdl

public abstract class J2EEDeployedObjectMdl extends J2EEEventProviderMOMdl

Fields Summary
public static final int
STARTING_STATE
public static final int
RUNNING_STATE
public static final int
STOPPING_STATE
public static final int
STOPPED_STATE
public static final int
FAILED_STATE
private com.sun.enterprise.management.util.J2EEModuleCallBack
module
private int
state
private long
startTime
private long
sequenceNo
private String[]
eventTypes
Constructors Summary
J2EEDeployedObjectMdl(com.sun.enterprise.management.util.J2EEModuleCallBack m)


      
	super(m.getName(), m.getServerName(), false, false);
	module = m;
    
Methods Summary
public java.lang.StringgetdeploymentDescriptor()
The deploymentDescriptor string must contain the original XML deployment descriptor that was created for this module during the deployment process.

        return module.getDeploymentDescriptor();
    
public java.lang.String[]geteventTypes()

        return eventTypes;
    
public java.lang.Stringgetserver()
returns the OBJECT_NAME of the J2EEServer this module is deployed on.

        String qs = "name=" + getJ2EEServer() + ",j2eeType=J2EEServer";
        Set s = findNames(qs);
        ObjectName[] sa = (ObjectName[]) s.toArray(
            new ObjectName[s.size()]);
        if (sa.length > 0) {
            return sa[0].toString();
        }
        return "Failed to find the server ObjectName";
    
public longgetstartTime()

        return this.startTime;
    
public intgetstate()

        return this.state;
    
public voidsetstate(int st)

        this.state = st;
        this.stateChanged(eventTypes[st]);
    
public voidstart()


	if ((this.state == this.STARTING_STATE) ||
	    (this.state == this.RUNNING_STATE) ||
	    (this.state == this.STOPPING_STATE)) {
            throw new RuntimeException(
		  new Exception ("cannot start because the current state is " + this.state));
	}

        try{
            this.state = this.STARTING_STATE;
            this.stateChanged("j2ee.state.starting");
	    module.start(this);
            this.state = this.RUNNING_STATE;
            this.startTime = System.currentTimeMillis();
            this.stateChanged("j2ee.state.running");
        }catch(Exception ex){
            this.state = this.FAILED_STATE;
            this.stateChanged("j2ee.state.failed");
	    if(ex instanceof RuntimeException)
                throw (RuntimeException)ex;
            throw new RuntimeException(ex);
        }
    
public voidstartRecursive()

        start();
    
private voidstateChanged(java.lang.String state)

        /*
        Called when this MBean is not yet registered (see below).
        Since nothing should be listening to an MBean that is not yet registered, just
        skip the Notification.  If there were listeners, 'this' could be used as the
        source object; it needn't be an ObjectName.
        
        com.sun.enterprise.management.util.J2EEManagementObjectManager.setState(J2EEManagementObjectManager.java:1550)
        com.sun.enterprise.management.util.J2EEManagementObjectManager.setApplicationState(J2EEManagementObjectManager.java:1498)
        com.sun.enterprise.server.ApplicationLoader.setState(ApplicationLoader.java:395)
        com.sun.enterprise.server.AbstractManager.load(AbstractManager.java:211)
        com.sun.enterprise.server.ApplicationLifecycle.onStartup(ApplicationLifecycle.java:204)
        com.sun.enterprise.server.ApplicationServer.onStartup(ApplicationServer.java:326)
        com.sun.enterprise.server.ondemand.OnDemandServer.onStartup(OnDemandServer.java:112)
        com.sun.enterprise.server.PEMain.run(PEMain.java:326)
        com.sun.enterprise.server.PEMain.main(PEMain.java:260)
    */
        final ObjectName objectName    = getObjectName();
        if ( objectName != null )
        {
            Notification notification   = null;
            synchronized (this) // thread safety, visibility of 'sequenceNo'
            {
                notification = new Notification( state, objectName, sequenceNo);
                ++sequenceNo;
            }
            this.sendNotification( notification );
        }
    
public voidstop()


	if ((this.state == this.STOPPED_STATE) ||
	    (this.state == this.STOPPING_STATE)) {
            throw new RuntimeException(
		new Exception("cannot stop because the current state is " + this.state));
	}

        try{
            this.state = this.STOPPING_STATE;
            this.stateChanged("j2ee.state.stopping");
	    module.stop(this);
            this.state = this.STOPPED_STATE;
            this.stateChanged("j2ee.state.stopped");
        }catch(Exception ex){
            this.state = this.FAILED_STATE;
            this.stateChanged("j2ee.state.failed");
	    if(ex instanceof RuntimeException)
                throw (RuntimeException)ex;
            throw new RuntimeException(ex);
        }