KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > api > control > LifeCycleController


1 /***
2  * Fractal API
3  * Copyright (C) 2001-2002 France Telecom, INRIA
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: fractal@objectweb.org
20  *
21  * Authors: Eric Bruneton, Thierry Coupaye, Pascal Dechamboux, Romain Lenglet,
22  * Philippe Merle, Jean-Bernard Stefani.
23  */

24
25 package org.objectweb.fractal.api.control;
26
27 /**
28  * A component interface to control the lifecycle of the component to which it
29  * belongs. The lifecycle of a component is supposed to be an automaton, whose
30  * states represent execution states of the component. This interface
31  * corresponds to an automaton with two states called {@link #STARTED
32  * STARTED} and {@link #STOPPED STOPPED}, where all the 4 four
33  * possible transitions are allowed. It is however possible to define completely
34  * different lifecycle controller Java interfaces to use completely different
35  * automatons, or to define sub interfaces of this interface to define
36  * automatons based on this one, but with more states and more transitions. <p>
37  *
38  * <b>Note:</b> the sub-interfaces of this interface should use the conventions
39  * used in this interface, which are the following. The interface contains one
40  * method per state in the lifecycle automaton. Each of these methods changes
41  * the current state to the state corresponding to its name, if there is a
42  * transition from the current state to this state. The interface also contains
43  * one field per state. The names and values of these fields correspond to the
44  * names of the methods.
45  */

46
47 public interface LifeCycleController {
48
49   /**
50    * The state of a component just after {@link #startFc startFc} has been
51    * executed.
52    */

53
54   String JavaDoc STARTED = "STARTED";
55
56   /**
57    * The state of a component just after {@link #stopFc stopFc} has been
58    * executed. This state is also the initial state of a component, i.e., the
59    * state of a component just after it has been created.
60    */

61
62   String JavaDoc STOPPED = "STOPPED";
63
64   /**
65    * Returns the execution state of the component to which this interface
66    * belongs.
67    *
68    * @return the execution state of the component to which this interface
69    * belongs.
70    */

71
72   String JavaDoc getFcState ();
73
74   /**
75    * Starts the component to which this interface belongs.
76    *
77    * @throws IllegalLifeCycleException if the transition from the current state
78    * to the {@link #STARTED STARTED} state is not a valid transition of the
79    * life cycle automaton.
80    */

81
82   void startFc () throws IllegalLifeCycleException;
83
84   /**
85    * Stops the component to which this interface belongs. The result of a method
86    * call on a stopped component is undefined, except on its control interfaces
87    * (these calls are executed normally).
88    *
89    * @throws IllegalLifeCycleException if the transition from the current state
90    * to the {@link #STOPPED STOPPED} state is not a valid transition of the
91    * life cycle automaton.
92    */

93
94   void stopFc () throws IllegalLifeCycleException;
95 }
96
Popular Tags