001: /*
002: * <copyright>
003: *
004: * Copyright 1997-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026:
027: package org.cougaar.util;
028:
029: /** GenericStateModel interface.
030: * This is the interface that defines state transitions for
031: * clusters, components and plugins.
032: *
033: *
034: */
035:
036: public interface GenericStateModel {
037:
038: /** UNINITIALIZED state - should never be returned by getModelState() **/
039: int UNINITIALIZED = -1;
040: /** initialized but not yet attached to an enclosing object **/
041: int UNLOADED = 1;
042: /** attached to a parent container **/
043: int LOADED = 2;
044: /** possibly doing work **/
045: int ACTIVE = 3;
046: /** forbidden from doing new work, but may be reactivated **/
047: int IDLE = 4;
048:
049: /** Initialize. Transition object from undefined to UNLOADED state.
050: * Treat initialize() as an extended constructor.
051: * @exception org.cougaar.util.StateModelException Cannot transition to UNLOADED because initial state wasn't UNITIALIZED.
052: **/
053:
054: void initialize() throws StateModelException;
055:
056: /**
057: * Object should transition to the LOADED state.
058: * After initialize and before load, an object in notified about its
059: * parents, services, etc. After load, it should be ready to run (but not
060: * actually running).
061: * @exception org.cougaar.util.StateModelException Cannot transition to LOADED because initial state wasn't UNLOADED.
062: **/
063:
064: void load() throws StateModelException;
065:
066: /** Called object should start any threads it requires.
067: * Called object should transition to the ACTIVE state.
068: * @exception org.cougaar.util.StateModelException Cannot transition to ACTIVE because initial state wasn't LOADED.
069: **/
070:
071: void start() throws StateModelException;
072:
073: /** Called object should pause operations in such a way that they may
074: * be cleanly resumed or the object can be unloaded.
075: * Called object should transition from the ACTIVE state to
076: * the IDLE state.
077: * @exception org.cougaar.util.StateModelException Cannot transition to IDLE because initial state wasn't ACTIVE.
078: **/
079:
080: void suspend() throws StateModelException;
081:
082: /** Called object should transition from the IDLE state back to
083: * the ACTIVE state.
084: * @exception org.cougaar.util.StateModelException Cannot transition to ACTIVE because initial state wasn't IDLE.
085: **/
086:
087: void resume() throws StateModelException;
088:
089: /** Called object should transition from the IDLE state
090: * to the LOADED state.
091: * @exception org.cougaar.util.StateModelException Cannot transition to LOADED because initial state wasn't IDLE.
092: **/
093:
094: void stop() throws StateModelException;
095:
096: /** Called object should transition from ACTIVE state
097: * to the LOADED state.
098: * @exception org.cougaar.util.StateModelException Cannot transition to LOADED because initial state wasn't ACTIVE.
099: **/
100:
101: void halt() throws StateModelException;
102:
103: /** Called object should perform any cleanup operations and transition
104: * to the UNLOADED state.
105: * @exception org.cougaar.util.StateModelException Cannot transition to UNLOADED because initial state wasn't LOADED.
106: **/
107:
108: void unload() throws StateModelException;
109:
110: /** Return the current state of the object: LOADED, UNLOADED,
111: * ACTIVE, or IDLE.
112: * @return object state
113: **/
114:
115: int getModelState();
116: }
|