KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > ServiceLifeCycle


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 Fossil E-Commerce, http://www.fossilec.com/
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.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: ServiceLifeCycle.java 292 2006-05-02 07:30:43Z ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals;
23
24
25 /**
26  * This interface must be implemented by internal platform services to provide
27  * initialization, start, stop and shutdown life cycle processing. These methods
28  * comprise the life cycle contract between platform services and the management
29  * functionalities.
30  *
31  * @version $Rev: 292 $ $Date: 2006-05-02 07:30:43Z $
32  * @since Petals 1.0
33  * @author <a HREF="mailto:rmarins@fossilec.com">Rafael Marins</a>
34  * TODO check if it is necessary to keep this class
35  */

36 public interface ServiceLifeCycle {
37
38     /**
39      * Value returned by {@link ServiceLifeCycle#getCurrentState()} for a
40      * shutdown system service.
41      */

42     public static final java.lang.String JavaDoc SHUTDOWN = "Shutdown";
43
44     /**
45      * Value returned by {@link ServiceLifeCycle#getCurrentState()} for a
46      * started system service.
47      */

48     public static final java.lang.String JavaDoc STARTED = "Started";
49
50     /**
51      * Value returned by {@link ServiceLifeCycle#getCurrentState()} for a
52      * stopped platform service.
53      */

54     public static final java.lang.String JavaDoc STOPPED = "Stopped";
55
56     /**
57      * Value returned by {@link ServiceLifeCycle#getCurrentState()} for a
58      * platform service in an unknown state.
59      */

60     public static final java.lang.String JavaDoc UNKNOWN = "Unknown";
61
62     /**
63      * Get the current state of this managed platform service.
64      *
65      * @return the current state of this managed service (must be one of
66      * the string constants defined by this interface)
67      */

68     public java.lang.String JavaDoc getCurrentState();
69
70     /**
71      * Initialize the platform service. This performs initialization required by
72      * the service but does not make it ready to get working. This method is
73      * called once for each life cycle of the platform service.
74      * <p>
75      * The current service state becomes {@link ServiceLifeCycle#STOPPED}
76      * just after this method invocation.
77      *
78      * @param context
79      * the system service's context, providing access to service's
80      * data provided by Petals environemnt.
81      * @throws PetalsException
82      */

83     public void init(ServiceContext context) throws PetalsException;
84
85     /**
86      * Shut down the platform service. This performs clean-up, releasing all
87      * run-time resources used by the service. Once this method has been
88      * called, {@link ServiceLifeCycle#init(ServiceContext)} must be called
89      * before the service can be started again with a call to
90      * {@link ServiceLifeCycle#start()}.
91      *
92      * @throws PetalsException
93      * if the system service fails to shut down
94      */

95     public void shutDown() throws PetalsException;
96
97     /**
98      * Start the platform service. This makes the service ready to use by other
99      * services. This method is called after
100      * {@link ServiceLifeCycle#init(ServiceContext)}, both when the service is
101      * being started for the first time and when the service is being restarted
102      * after a previous call to {@link ServiceLifeCycle#shutDown()}. If
103      * {@link ServiceLifeCycle#stop()} was called previously but
104      * {@link ServiceLifeCycle#shutDown()} was not,
105      * {@link ServiceLifeCycle#start()} can be called again without another call
106      * to {@link ServiceLifeCycle#init(ServiceContext)}.
107      *
108      * @throws PetalsException
109      * if the system service fails to start
110      */

111     public void start() throws PetalsException;
112
113     /**
114      * Stop the platform service. This makes the service stop accepting calls
115      * for processing. After a call to this method,
116      * {@link ServiceLifeCycle#start()} may be called again without first
117      * calling {@link ServiceLifeCycle#init(ServiceContext)}.
118      *
119      * @throws PetalsException
120      * if the system services fails to stop
121      */

122     public void stop() throws PetalsException;
123
124 }
125
Popular Tags