01: /*
02: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
03: *
04: * This file is part of Resin(R) Open Source
05: *
06: * Each copy or derived work must preserve the copyright notice and this
07: * notice unmodified.
08: *
09: * Resin Open Source is free software; you can redistribute it and/or modify
10: * it under the terms of the GNU General Public License as published by
11: * the Free Software Foundation; either version 2 of the License, or
12: * (at your option) any later version.
13: *
14: * Resin Open Source is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17: * of NON-INFRINGEMENT. See the GNU General Public License for more
18: * details.
19: *
20: * You should have received a copy of the GNU General Public License
21: * along with Resin Open Source; if not, write to the
22: * Free SoftwareFoundation, Inc.
23: * 59 Temple Place, Suite 330
24: * Boston, MA 02111-1307 USA
25: *
26: * @author Sam
27: */
28:
29: package com.caucho.management.j2ee;
30:
31: /**
32: * Base class interface for managed objects that have lifecycle state management.
33: *
34: * {@link #getState()} returns an integer representing the current state.
35: *
36: * <table>
37: * <tr><th>name<th>value<th>description<th>transition operations allowed
38: * <tr><td>STARTING<td>0<td>the managed object is starting<td>
39: * <tr><td>RUNNING <td>1<td>the managed object is running<td>{@link #stop()}
40: * <tr><td>STOPPING<td>2<td>the managed object is stopping<td>
41: * <tr><td>STOPPEDG<td>3<td>the managed object is stoped<td>{@link #start()}
42: * <tr><td>FAILED <td>4<td>an attempt to start or stop the managed object failed<td>{@link #start()}, {@link #stop()}
43: * </table>
44: */
45: public interface StateManageable {
46: public static final int STARTING = 0;
47: public static final int RUNNING = 1;
48: public static final int STOPPING = 2;
49: public static final int STOPPED = 3;
50: public static final int FAILED = 4;
51:
52: /**
53: * The time that the managed object was started and entered the {@link RUNNING}
54: * state. The value is the number of milliseconds since 00:00 January 1, 1970.
55: */
56: public long getStartTime();
57:
58: /**
59: * Returns the current state of the managed object.
60: *
61: */
62: public int getState();
63:
64: /**
65: * Start the managed object when it is in the {@link STOPPED} or {@link FAILED}
66: * state.
67: *
68: * If there are children of this managed object they are <i>not</i>
69: * started, see {@link #startRecursive()}.
70: *
71: * An {@link EventProvider} will issue a
72: * {@link NotificationTypes.J2EE_STATE_STARTING} notification, and then
73: * depending on the success of the start a
74: * {@link NotificationTypes.J2EE_STATE_RUNNING} or a
75: * {@link NotificationTypes.J2EE_STATE_FAILED} notification.
76: */
77: public void start();
78:
79: /**
80: * Starts the managed object (See {@link #start()}, and then recursively
81: * starts any children.
82: */
83: public void startRecursive();
84:
85: /**
86: * Stop the managed object when it is in the {@link RUNNING} or {@link FAILED}
87: * state.
88: *
89: * An {@link EventProvider} will issue a
90: * {@link NotificationTypes.J2EE_STATE_STARTING} notification, and then
91: * depending on the success of the start a
92: * {@link NotificationTypes.J2EE_STATE_RUNNING} or a
93: * {@link NotificationTypes.J2EE_STATE_FAILED} notification.
94: */
95: public void stop();
96:
97: }
|