KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > kernel > Kernel


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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 package org.apache.geronimo.kernel;
18
19 import java.util.Date JavaDoc;
20 import java.util.Set JavaDoc;
21 import java.util.Collections JavaDoc;
22 import javax.management.ObjectName JavaDoc;
23
24 import org.apache.geronimo.gbean.GBeanData;
25 import org.apache.geronimo.gbean.GBeanInfo;
26 import org.apache.geronimo.gbean.AbstractNameQuery;
27 import org.apache.geronimo.gbean.AbstractName;
28 import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
29 import org.apache.geronimo.kernel.proxy.ProxyManager;
30 import org.apache.geronimo.kernel.repository.Artifact;
31
32 /**
33  * @version $Rev:386515 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
34  */

35 public interface Kernel {
36     /**
37      * The JMX name used by a Kernel to register itself when it boots.
38      */

39     ObjectName JavaDoc KERNEL = ObjectNameUtil.getObjectName(":role=Kernel");
40     AbstractName KERNEL_NAME = new AbstractName(new Artifact("geronimo", "boot", "none", "car"), Collections.singletonMap("role", "kernel"), KERNEL);
41
42     /**
43      * Get the name of this kernel
44      *
45      * @return the name of this kernel
46      */

47     String JavaDoc getKernelName();
48
49     /**
50      * Gets the naming system used by this kernel.
51      * @return the naming system used by this kernel
52      */

53     Naming getNaming();
54
55     /**
56      * Gets the dependency manager kernel service
57      * @return the dependency manager or null if the kernel is not running
58      */

59     DependencyManager getDependencyManager();
60
61     /**
62      * Gets the lifecycle monitor kernel service
63      * @return the lifecycle monitor or null if the kernel is not running
64      */

65     LifecycleMonitor getLifecycleMonitor();
66
67     /**
68      * Gets the proxy manager kernel service
69      * @return the proxy manager or null if the kernel is not running
70      */

71     ProxyManager getProxyManager();
72
73     /**
74      * Load a specific GBean into this kernel.
75      * This is intended for applications that are embedding the kernel.
76      *
77      * @param gbeanData the GBean to load
78      * @param classLoader the class loader to use to load the gbean
79      * @throws org.apache.geronimo.kernel.GBeanAlreadyExistsException if the name is already used
80      * @throws org.apache.geronimo.kernel.InternalKernelException if there is a problem during registration
81      */

82     void loadGBean(GBeanData gbeanData, ClassLoader JavaDoc classLoader) throws GBeanAlreadyExistsException, InternalKernelException;
83
84     /**
85      * Is there a GBean registered with the kernel under the specified name?
86      * @param name the name to check
87      * @return true if there is a gbean registered under the specified name; false otherwise
88      */

89     boolean isLoaded(AbstractName name);
90     boolean isLoaded(String JavaDoc shortName);
91     boolean isLoaded(Class JavaDoc type);
92     boolean isLoaded(String JavaDoc shortName, Class JavaDoc type);
93
94     /**
95      * Gets the specified GBean instance.
96      *
97      * @param name the GBean instance to get
98      * @throws org.apache.geronimo.kernel.GBeanNotFoundException if the GBean could not be found
99      * @throws InternalKernelException if there is a general error
100      * @throws IllegalStateException If the gbean is disabled
101      */

102     Object JavaDoc getGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
103     Object JavaDoc getGBean(String JavaDoc shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
104     Object JavaDoc getGBean(Class JavaDoc type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
105     Object JavaDoc getGBean(String JavaDoc shortName, Class JavaDoc type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
106
107     /**
108      * Start a specific GBean.
109      *
110      * @param name the GBean to start
111      * @throws org.apache.geronimo.kernel.GBeanNotFoundException if the GBean could not be found
112      * @throws InternalKernelException if there GBean is not state manageable or if there is a general error
113      * @throws IllegalStateException If the gbean is disabled
114      */

115     void startGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
116     void startGBean(String JavaDoc shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
117     void startGBean(Class JavaDoc type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
118     void startGBean(String JavaDoc shortName, Class JavaDoc type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
119
120     /**
121      * Start a specific GBean and its children.
122      *
123      * @param name the GBean to start
124      * @throws GBeanNotFoundException if the GBean could not be found
125      * @throws InternalKernelException if there GBean is not state manageable or if there is a general error
126      * @throws IllegalStateException If the gbean is disabled
127      */

128     void startRecursiveGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
129     void startRecursiveGBean(String JavaDoc shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
130     void startRecursiveGBean(Class JavaDoc type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
131     void startRecursiveGBean(String JavaDoc shortName, Class JavaDoc type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
132
133     /**
134      * Is there a GBean registered with the kernel under the specified name and is it running?
135      * @param name the name to check
136      * @return true if there is a gbean registered under the specified name and is it running; false otherwise
137      */

138     boolean isRunning(AbstractName name);
139     boolean isRunning(String JavaDoc shortName);
140     boolean isRunning(Class JavaDoc type);
141     boolean isRunning(String JavaDoc shortName, Class JavaDoc type);
142
143     /**
144      * Stop a specific GBean.
145      *
146      * @param name the GBean to stop
147      * @throws GBeanNotFoundException if the GBean could not be found
148      * @throws InternalKernelException if there GBean is not state manageable or if there is a general error
149      * @throws IllegalStateException If the gbean is disabled
150      */

151     void stopGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
152     void stopGBean(String JavaDoc shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
153     void stopGBean(Class JavaDoc type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
154     void stopGBean(String JavaDoc shortName, Class JavaDoc type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
155
156     /**
157      * Unload a specific GBean.
158      * This is intended for applications that are embedding the kernel.
159      *
160      * @param name the name of the GBean to unregister
161      * @throws GBeanNotFoundException if the GBean could not be found
162      * @throws InternalKernelException if there GBean is a problem while unloading the GBean
163      */

164     void unloadGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
165     void unloadGBean(String JavaDoc shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
166     void unloadGBean(Class JavaDoc type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
167     void unloadGBean(String JavaDoc shortName, Class JavaDoc type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
168
169     /**
170      * Gets the state of the specified GBean.
171      * @param name the name of the GBean
172      * @return the state of the GBean
173      * @throws GBeanNotFoundException if the GBean could not be found
174      */

175     int getGBeanState(AbstractName name) throws GBeanNotFoundException;
176     int getGBeanState(String JavaDoc shortName) throws GBeanNotFoundException;
177     int getGBeanState(Class JavaDoc type) throws GBeanNotFoundException;
178     int getGBeanState(String JavaDoc shortName, Class JavaDoc type) throws GBeanNotFoundException;
179
180     /**
181      * Gets the time the specified GBean was started
182      * @param name the name of the GBean
183      * @return the start time of the GBean or 0 if not running
184      * @throws GBeanNotFoundException if the GBean could not be found
185      */

186     long getGBeanStartTime(AbstractName name) throws GBeanNotFoundException;
187     long getGBeanStartTime(String JavaDoc shortName) throws GBeanNotFoundException;
188     long getGBeanStartTime(Class JavaDoc type) throws GBeanNotFoundException;
189     long getGBeanStartTime(String JavaDoc shortName, Class JavaDoc type) throws GBeanNotFoundException;
190
191     /**
192      * Gets the ClassLoader used to register the specified GBean
193      * @param name the name of the gbean from which the class loader should be extracted
194      * @return the class loader associated with the specified GBean
195      * @throws GBeanNotFoundException if the specified GBean is not registered with the kernel
196      */

197     ClassLoader JavaDoc getClassLoaderFor(AbstractName name) throws GBeanNotFoundException;
198     ClassLoader JavaDoc getClassLoaderFor(String JavaDoc shortName) throws GBeanNotFoundException;
199     ClassLoader JavaDoc getClassLoaderFor(Class JavaDoc type) throws GBeanNotFoundException;
200     ClassLoader JavaDoc getClassLoaderFor(String JavaDoc shortName, Class JavaDoc type) throws GBeanNotFoundException;
201
202     /**
203      * Return the GBeanInfo for a registered GBean instance.
204      * @param name the name of the GBean whose info should be returned
205      * @return the info for that instance
206      * @throws GBeanNotFoundException if there is no instance with the supplied name
207      */

208     GBeanInfo getGBeanInfo(AbstractName name) throws GBeanNotFoundException;
209     GBeanInfo getGBeanInfo(String JavaDoc shortName) throws GBeanNotFoundException;
210     GBeanInfo getGBeanInfo(Class JavaDoc type) throws GBeanNotFoundException;
211     GBeanInfo getGBeanInfo(String JavaDoc shortName, Class JavaDoc type) throws GBeanNotFoundException;
212
213     /**
214      * Return the GBeanData for a GBean instance.
215      * @param name the name of the GBean whose info should be returned
216      * @return the info for that instance
217      * @throws GBeanNotFoundException if there is no instance with the supplied name
218      */

219     GBeanData getGBeanData(AbstractName name) throws GBeanNotFoundException, InternalKernelException;
220     GBeanData getGBeanData(String JavaDoc shortName) throws GBeanNotFoundException, InternalKernelException;
221     GBeanData getGBeanData(Class JavaDoc type) throws GBeanNotFoundException, InternalKernelException;
222     GBeanData getGBeanData(String JavaDoc shortName, Class JavaDoc type) throws GBeanNotFoundException, InternalKernelException;
223
224     /**
225      * Gets the AbstractNames of all GBeans matching the abstractNameQuery.
226      * @param abstractNameQuery the query to execute
227      * @return the AbstractNames of all matching GBeans
228      */

229     Set JavaDoc listGBeans(AbstractNameQuery abstractNameQuery);
230
231     /**
232      * Returns a Set of all GBeans matching the set of object name pattern
233      * @param abstractNameQueries the queries to execute
234      * @return a List of AbstractNameName of matching GBeans registered with this kernel
235      */

236     Set JavaDoc listGBeans(Set JavaDoc abstractNameQueries);
237
238     /**
239      * Gets the value of an attribute on the specified gbean
240      * @param name the name of the gbean from which the attribute will be retrieved
241      * @param attributeName the name of the attribute to fetch
242      * @return the value of the attribute
243      * @throws GBeanNotFoundException if there is not a gbean under the specified name
244      * @throws NoSuchAttributeException if the gbean does not contain the specified attribute
245      * @throws Exception if the gbean throws an exception from the getter
246      */

247     Object JavaDoc getAttribute(AbstractName name, String JavaDoc attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception JavaDoc;
248     Object JavaDoc getAttribute(String JavaDoc shortName, String JavaDoc attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception JavaDoc;
249     Object JavaDoc getAttribute(Class JavaDoc type, String JavaDoc attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception JavaDoc;
250     Object JavaDoc getAttribute(String JavaDoc shortName, Class JavaDoc type, String JavaDoc attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception JavaDoc;
251
252     /**
253      * Sets the value of an attribute on the specified gbean
254      * @param name the name of the gbean from in which the new attribute value will be set
255      * @param attributeName the name of the attribute to set
256      * @param attributeValue the new value of the attribute
257      * @throws GBeanNotFoundException if there is not a gbean under the specified name
258      * @throws NoSuchAttributeException if the gbean does not contain the specified attribute
259      * @throws Exception if the gbean throws an exception from the setter
260      */

261     void setAttribute(AbstractName name, String JavaDoc attributeName, Object JavaDoc attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception JavaDoc;
262     void setAttribute(String JavaDoc shortName, String JavaDoc attributeName, Object JavaDoc attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception JavaDoc;
263     void setAttribute(Class JavaDoc type, String JavaDoc attributeName, Object JavaDoc attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception JavaDoc;
264     void setAttribute(String JavaDoc shortName, Class JavaDoc type, String JavaDoc attributeName, Object JavaDoc attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception JavaDoc;
265
266     /**
267      * Invokes a no-argument method on the specified GBean
268      * @param name the name of the gbean from in which the new attribute value will be set
269      * @param methodName the name of the method to invoke
270      * @return the return value of the method or null if the specified method does not return a value
271      * @throws GBeanNotFoundException if there is not a gbean under the specified name
272      * @throws NoSuchOperationException if the gbean does not have the specified operation
273      * @throws InternalKernelException if an error occurs within the kernel itself
274      * @throws Exception if the method throws an exception
275      */

276     Object JavaDoc invoke(AbstractName name, String JavaDoc methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception JavaDoc;
277     Object JavaDoc invoke(String JavaDoc shortName, String JavaDoc methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception JavaDoc;
278     Object JavaDoc invoke(Class JavaDoc type, String JavaDoc methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception JavaDoc;
279     Object JavaDoc invoke(String JavaDoc shortName, Class JavaDoc type, String JavaDoc methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception JavaDoc;
280
281     /**
282      * Invokes a method on the specified GBean with the specified arguments
283      * @param name the name of the gbean from in which the new attribute value will be set
284      * @param methodName the name of the method to invoke
285      * @param args the arguments to pass to the method
286      * @param types the types of the arguments; the types are used to determine the signature of the mehod that should be invoked
287      * @return the return value of the method or null if the specified method does not return a value
288      * @throws GBeanNotFoundException if there is not a gbean under the specified name
289      * @throws NoSuchOperationException if the gbean does not have the specified operation
290      * @throws InternalKernelException if an error occurs within the kernel itself
291      * @throws Exception if the method throws an exception
292      */

293     Object JavaDoc invoke(AbstractName name, String JavaDoc methodName, Object JavaDoc[] args, String JavaDoc[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception JavaDoc;
294     Object JavaDoc invoke(String JavaDoc shortName, String JavaDoc methodName, Object JavaDoc[] args, String JavaDoc[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception JavaDoc;
295     Object JavaDoc invoke(Class JavaDoc type, String JavaDoc methodName, Object JavaDoc[] args, String JavaDoc[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception JavaDoc;
296     Object JavaDoc invoke(String JavaDoc shortName, Class JavaDoc type, String JavaDoc methodName, Object JavaDoc[] args, String JavaDoc[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception JavaDoc;
297
298     /**
299      * Assuming the argument represents a service running in the kernel,
300      * returns an AbstractName for it. If the argument is not a service or the
301      * kernel cannot produce an AbstractName for it, returns null.
302      */

303     AbstractName getAbstractNameFor(Object JavaDoc service);
304
305     /**
306      * Assuming the argument represents a service running in the kernel,
307      * returns the short name of the service. If the argument is not a service, returns null.
308      */

309     String JavaDoc getShortNameFor(Object JavaDoc service);
310
311     /**
312      * Brings the kernel online
313      * @throws Exception if the kernel can not boot
314      */

315     void boot() throws Exception JavaDoc;
316
317     /**
318      * Returns the time this kernel was last booted.
319      * @return the time this kernel was last booted; null if the kernel has not been
320      */

321     Date JavaDoc getBootTime();
322
323     /**
324      * Registers a runnable to execute when the kernel is shutdown
325      * @param hook a runnable to execute when the kernel is shutdown
326      */

327     void registerShutdownHook(Runnable JavaDoc hook);
328
329     /**
330      * Unregisters a runnable from the list to execute when the kernel is shutdown
331      * @param hook the runnable that should be removed
332      */

333     void unregisterShutdownHook(Runnable JavaDoc hook);
334
335     /**
336      * Stops the kernel
337      */

338     void shutdown();
339
340     /**
341      * Has the kernel been booted
342      * @return true if the kernel has been booted; false otherwise
343      */

344     boolean isRunning();
345
346     /**
347      * @deprecated Use AbstractName version instead
348      */

349     Object JavaDoc getGBean(ObjectName JavaDoc name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException JavaDoc;
350     /**
351      * @deprecated Use AbstractName version instead
352      */

353     int getGBeanState(ObjectName JavaDoc name) throws GBeanNotFoundException;
354     /**
355      * @deprecated Use AbstractName version instead
356      */

357     GBeanInfo getGBeanInfo(ObjectName JavaDoc name) throws GBeanNotFoundException;
358     /**
359      * Returns a Set with elements of type ObjectName
360      *
361      * @deprecated Use AbstractNameQuery version instead
362      */

363     Set JavaDoc listGBeans(ObjectName JavaDoc pattern);
364     /**
365      * @deprecated Use AbstractName version instead
366      */

367     Object JavaDoc getAttribute(ObjectName JavaDoc name, String JavaDoc attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception JavaDoc;
368     /**
369      * @deprecated Use AbstractName version instead
370      */

371     Object JavaDoc invoke(ObjectName JavaDoc name, String JavaDoc methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception JavaDoc;
372     /**
373      * @deprecated Use AbstractName version instead
374      */

375     Object JavaDoc invoke(ObjectName JavaDoc name, String JavaDoc methodName, Object JavaDoc[] args, String JavaDoc[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception JavaDoc;
376 }
377
Popular Tags