View Javadoc

1   /**
2    *
3    * Copyright 2003-2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  
18  package org.apache.geronimo.kernel.management;
19  
20  
21  /**
22   * A Java interface the meets the J2EE Management specification for a state manageable object.
23   *
24   * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $
25   */
26  public interface StateManageable {
27      /**
28       * Gets the state of this component as an int.
29       * The int return is required by the JSR77 specification.
30       *
31       * @return the current state of this component
32       * @see #getStateInstance to obtain the State instance
33       */
34      int getState();
35  
36      /**
37       * Gets the state of this component as a State instance.
38       *
39       * @return the current state of this component
40       */
41      State getStateInstance();
42  
43      /**
44       * Gets the start time of this component
45       *
46       * @return time in milliseonds since epoch that this component was started.
47       */
48      long getStartTime();
49  
50  
51      /**
52       * Transitions the component to the starting state.  This method has access to the
53       * container.
54       * <p/>
55       * Normally a component uses this to cache data from other components. The other components will
56       * have been created at this stage, but not necessairly started and may not be ready to have methods
57       * invoked on them.
58       *
59       * @throws Exception if a problem occurs during the transition
60       * @throws IllegalStateException if this interceptor is not in the stopped or failed state
61       */
62      void start() throws Exception, IllegalStateException;
63  
64      /**
65       * Transitions the component to the starting state.  This method has access to the
66       * container.
67       * <p/>
68       * If this Component is a Container, then startRecursive is called on all child Components
69       * that are in the STOPPED or FAILED state.
70       * Normally a component uses this to cache data from other components. The other components will
71       * have been created at this stage, but not necessairly started and may not be ready to have methods
72       * invoked on them.
73       *
74       * @throws Exception if a problem occurs during the transition
75       * @throws IllegalStateException if this interceptor is not in the STOPPED or FAILED state
76       */
77      void startRecursive() throws Exception, IllegalStateException;
78  
79      /**
80       * Transitions the component to the stopping state.  This method has access to the
81       * container.
82       * <p/>
83       * If this is Component is a Container, then all its child components must be in the
84       * STOPPED or FAILED State.
85       * <p/>
86       * Normally a component uses this to drop references to data cached in the start method.
87       * The other components will not necessairly have been stopped at this stage and may not be ready
88       * to have methods invoked on them.
89       *
90       * @throws Exception if a problem occurs during the transition
91       * @throws IllegalStateException if this interceptor is not in the STOPPED or FAILED state
92       */
93      void stop() throws Exception, IllegalStateException;
94  
95  }