KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > julia > control > lifecycle > LifeCycleCoordinator


1 /***
2  * Julia: France Telecom's implementation of the Fractal API
3  * Copyright (C) 2001-2002 France Telecom R&D
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: Eric.Bruneton@rd.francetelecom.com
20  *
21  * Author: Eric Bruneton
22  */

23
24 package org.objectweb.fractal.julia.control.lifecycle;
25
26 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
27 import org.objectweb.fractal.api.control.LifeCycleController;
28
29 /**
30  * An extended {@link LifeCycleController} interface. This interface is
31  * used to stop several components simultaneously, in order to avoid the
32  * deadlocks that can occur when several components are stopped one by one
33  * (for example, if a component C is stopped after a component S, and if a
34  * thread T is executing a method m1 in C which calls a method m2 in S, then T
35  * can be blocked in m2 just after S is stopped but before C is stopped, in
36  * which case C can not be stopped, and a deadlock occurs).
37  */

38
39 public interface LifeCycleCoordinator extends LifeCycleController {
40
41   /**
42    * Sets the state of this component, <i>but not of its sub components</i>, to
43    * {@link #STARTED STARTED}. Because of component sharing, the {@link
44    * #startFc startFc} method cannot be implemented by just calling
45    * itself recursively on the sub components of this componets (otherwise some
46    * sub components may be started several times). Hence this method.
47    *
48    * @return <tt>true</tt> if the execution state has changed, or <tt>false</tt>
49    * if it had already the {@link #STARTED STARTED} value.
50    * @throws IllegalLifeCycleException if a problem occurs.
51    */

52
53   boolean setFcStarted () throws IllegalLifeCycleException;
54
55   /**
56    * Sets the state of this component, <i>but not of its sub components</i>, to
57    * "<tt>STOPPING</tt>". After this method has been called, and while the
58    * {@link #setFcStopped setFcStopped} has not been called, this component must
59    * notify the given coordinator when it becomes inactive, and when it is about
60    * to become active, with the {@link #fcInactivated fcInactivated} and {@link
61    * #fcActivated fcActivated} methods.
62    * <br>
63    * Note: the "<tt>STOPPING</tt>" state is an internal state that is not
64    * visible from the outside. Indeed, in this state, the {@link #getFcState
65    * getFcState} method should return {@link #STARTED STARTED}, as the component
66    * is not yet stopped.
67    *
68    * @param coordinator the coordinator that must be notified when this
69    * component becomes inactive, and when it is about to become active.
70    * @throws IllegalLifeCycleException if a problem occurs.
71    */

72
73   void setFcStopping (LifeCycleCoordinator coordinator)
74     throws IllegalLifeCycleException;
75
76   /**
77    * Sets the state of this component, <i>but not of its sub components</i>, to
78    * {@link #STOPPED STOPPED}. Because of component sharing, the {@link
79    * #stopFc stopFc} method cannot be implemented by just calling
80    * itself recursively on the sub components of this componets (otherwise some
81    * sub components may be stopped several times). Hence this method.
82    *
83    * @return <tt>true</tt> if the execution state has changed, or <tt>false</tt>
84    * if it had already the {@link #STOPPED STOPPED} value.
85    * @throws IllegalLifeCycleException if a problem occurs.
86    */

87
88   boolean setFcStopped () throws IllegalLifeCycleException;
89
90   /**
91    * Notifies this component that the given component is about to become active.
92    * This method must be called by a component when the following conditions are
93    * met:
94    * <ul>
95    * <li>the component is stopping, i.e., its {@link #setFcStopping
96    * setFcStopping} method has been called.</li>
97    * <li>the component is not yet stopped, i.e., its {@link #setFcStopped
98    * setFcStopped} method has not been called yet.</li>
99    * <li>the component is currently inactive, but a new activity is about to
100    * start in this component.</li>
101    * </ul>
102    *
103    * @param component the {@link LifeCycleCoordinator} interface of a component
104    * that is about to become active.
105    * @return <tt>true</tt> if the given component can become active, or
106    * <tt>false</tt> if the new activity must be delayed until the component
107    * is restarted.
108    */

109
110   boolean fcActivated (LifeCycleCoordinator component);
111
112   /**
113    * Notifies this component that the given component has become inactive.
114    * This method must be called by a component when the following conditions are
115    * met:
116    * <ul>
117    * <li>the component is stopping, i.e., its {@link #setFcStopping
118    * setFcStopping} method has been called.</li>
119    * <li>the component is not yet stopped, i.e., its {@link #setFcStopped
120    * setFcStopped} method has not been called yet.</li>
121    * <li>the component has become inactive.</li>
122    * </ul>
123    *
124    * @param component the {@link LifeCycleCoordinator} interface of a component
125    * that has become inactive.
126    */

127
128   void fcInactivated (LifeCycleCoordinator component);
129 }
130
Popular Tags