001 /**
002 *
003 * Copyright 2003-2004 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.geronimo.kernel.management;
019
020
021 /**
022 * A Java interface the meets the J2EE Management specification for a state manageable object.
023 *
024 * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $
025 */
026 public interface StateManageable {
027 /**
028 * Gets the state of this component as an int.
029 * The int return is required by the JSR77 specification.
030 *
031 * @return the current state of this component
032 * @see #getStateInstance to obtain the State instance
033 */
034 int getState();
035
036 /**
037 * Gets the state of this component as a State instance.
038 *
039 * @return the current state of this component
040 */
041 State getStateInstance();
042
043 /**
044 * Gets the start time of this component
045 *
046 * @return time in milliseonds since epoch that this component was started.
047 */
048 long getStartTime();
049
050
051 /**
052 * Transitions the component to the starting state. This method has access to the
053 * container.
054 * <p/>
055 * Normally a component uses this to cache data from other components. The other components will
056 * have been created at this stage, but not necessairly started and may not be ready to have methods
057 * invoked on them.
058 *
059 * @throws Exception if a problem occurs during the transition
060 * @throws IllegalStateException if this interceptor is not in the stopped or failed state
061 */
062 void start() throws Exception, IllegalStateException;
063
064 /**
065 * Transitions the component to the starting state. This method has access to the
066 * container.
067 * <p/>
068 * If this Component is a Container, then startRecursive is called on all child Components
069 * that are in the STOPPED or FAILED state.
070 * Normally a component uses this to cache data from other components. The other components will
071 * have been created at this stage, but not necessairly started and may not be ready to have methods
072 * invoked on them.
073 *
074 * @throws Exception if a problem occurs during the transition
075 * @throws IllegalStateException if this interceptor is not in the STOPPED or FAILED state
076 */
077 void startRecursive() throws Exception, IllegalStateException;
078
079 /**
080 * Transitions the component to the stopping state. This method has access to the
081 * container.
082 * <p/>
083 * If this is Component is a Container, then all its child components must be in the
084 * STOPPED or FAILED State.
085 * <p/>
086 * Normally a component uses this to drop references to data cached in the start method.
087 * The other components will not necessairly have been stopped at this stage and may not be ready
088 * to have methods invoked on them.
089 *
090 * @throws Exception if a problem occurs during the transition
091 * @throws IllegalStateException if this interceptor is not in the STOPPED or FAILED state
092 */
093 void stop() throws Exception, IllegalStateException;
094
095 }