KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > services > monitor > ModuleFactory


1 /*
2
3    Derby - Class org.apache.derby.iapi.services.monitor.ModuleFactory
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.services.monitor;
23
24 import org.apache.derby.iapi.services.info.ProductVersionHolder;
25 import org.apache.derby.iapi.error.StandardException;
26 import org.apache.derby.iapi.services.stream.InfoStreams;
27 import org.apache.derby.iapi.services.monitor.PersistentService;
28 import org.apache.derby.iapi.services.loader.InstanceGetter;
29
30 import java.util.Properties JavaDoc;
31 import java.util.Locale JavaDoc;
32 import java.io.InputStream JavaDoc;
33 import java.io.IOException JavaDoc;
34       
35 /**
36 The monitor provides a central registry for all modules in the system,
37 and manages loading, starting, and finding them.
38 */

39
40 public interface ModuleFactory
41 {
42
43     /**
44      * Find the module in the system with the given module protocol,
45      * protocolVersion and identifier.
46         
47      * @return The module instance if found, or null.
48      */

49     public Object JavaDoc findModule(Object JavaDoc service, String JavaDoc protocol, String JavaDoc identifier);
50
51     /**
52         Return the name of the service that the passed in module lives in.
53     */

54     public String JavaDoc getServiceName(Object JavaDoc serviceModule);
55
56     /**
57         Return the locale of the service that the passed in module lives in.
58         Will return null if no-locale has been defined.
59     */

60     public Locale JavaDoc getLocale(Object JavaDoc serviceModule);
61
62     /**
63         Translate a string of the form ll[_CC[_variant]] to a Locale.
64         This is in the Monitor because we want this translation to be
65         in only one place in the code.
66      */

67     public Locale JavaDoc getLocaleFromString(String JavaDoc localeDescription)
68                     throws StandardException;
69
70
71     /**
72         Set the locale for the service *outside* of boot time.
73
74         @param userDefinedLocale A String in the form xx_YY, where xx is the
75                                     language code and YY is the country code.
76
77         @return The new Locale for the service
78
79         @exception StandardException Thrown on error
80      */

81     public Locale JavaDoc setLocale(Object JavaDoc serviceModule, String JavaDoc userDefinedLocale)
82                         throws StandardException;
83
84     /**
85         Set the locale for the service at boot time. The passed-in
86         properties must be the one passed to the boot method.
87
88         @exception StandardException Cloudscape error.
89      */

90     public Locale JavaDoc setLocale(Properties JavaDoc serviceProperties,
91                             String JavaDoc userDefinedLocale)
92                         throws StandardException;
93
94     /**
95         Return the PersistentService object for a service.
96         Will return null if the service does not exist.
97     */

98     public PersistentService getServiceType(Object JavaDoc serviceModule);
99
100     /**
101      * Return the PersistentService for a subsubprotocol.
102      *
103      * @return the PersistentService or null if it does not exist
104      *
105      * @exception StandardException
106      */

107     public PersistentService getServiceProvider(String JavaDoc subSubProtocol) throws StandardException;
108     
109     public Properties JavaDoc getApplicationProperties();
110
111     /**
112         Shut down the complete system that was started by this Monitor. Will
113         cause the stop() method to be called on each loaded module.
114     */

115     public void shutdown();
116
117     /**
118         Shut down a service that was started by this Monitor. Will
119         cause the stop() method to be called on each loaded module.
120         Requires that a context stack exist.
121     */

122     public void shutdown(Object JavaDoc service);
123
124
125     /**
126         Obtain a class that supports the given identifier.
127
128         @param identifier identifer to associate with class
129
130         @return a reference InstanceGetter
131
132         @exception StandardException See Monitor.classFromIdentifier
133     */

134     public InstanceGetter classFromIdentifier(int identifier)
135         throws StandardException;
136
137     /**
138         Obtain an new instance of a class that supports the given identifier.
139
140         @param identifier identifer to associate with class
141
142         @return a reference to a newly created object
143
144         @exception StandardException See Monitor.newInstanceFromIdentifier
145     
146     */

147     public Object JavaDoc newInstanceFromIdentifier(int identifier)
148         throws StandardException;
149
150     /**
151         Return the environment object that this system was booted in.
152         This is a free form object that is set by the method the
153         system is booted. For example when running in a Marimba system
154         it is set to the maribma application context. In most environments
155         it will be set to a java.io.File object representing the system home directory.
156         Code that call this method usualy have predefined knowledge of the type of the returned object, e.g.
157         Marimba store code knows that this will be set to a marimba application
158         context.
159     */

160     public Object JavaDoc getEnvironment();
161
162
163     /**
164         Return an array of the service identifiers that are running and
165         implement the passed in protocol (java interface class name).
166         This list is a snapshot of the current running systesm, once
167         the call returns the service may have been shutdown or
168         new ones added.
169
170         @return The list of service names, if no services exist that
171         implement the protocol an array with zero elements is returned.
172     */

173     public String JavaDoc[] getServiceList(String JavaDoc protocol);
174
175     /**
176         Start a persistent service.
177         <BR>
178         <B>Do not call directly - use Monitor.startPersistentService()</B>
179         
180         <P> The poperty set passed in is for boot options for the modules
181         required to start the service. It does not support defining different
182         or new modules implementations.
183         
184         @param serviceName Name of the service to be started
185         @param properties Property set made available to all modules booted
186         for this service, through their ModuleControl.boot method.
187
188         @return true if the service type is handled by the monitor, false if it isn't
189
190         @exception StandardException An attempt to start the service failed.
191
192         @see Monitor#startPersistentService
193     */

194     public boolean startPersistentService(String JavaDoc serviceName, Properties JavaDoc properties)
195         throws StandardException;
196
197     /**
198         Create a persistent service.
199         <BR>
200         <B>Do not call directly - use Monitor.startPersistentService()</B>
201
202         @exception StandardException An attempt to create the service failed.
203
204         @see Monitor#createPersistentService
205     */

206     public Object JavaDoc createPersistentService(String JavaDoc factoryInterface, String JavaDoc serviceName, Properties JavaDoc properties)
207         throws StandardException;
208     public void removePersistentService(String JavaDoc name)
209         throws StandardException;
210    
211     /**
212         Start a non-persistent service.
213         
214         <BR>
215         <B>Do not call directly - use Monitor.startNonPersistentService()</B>
216
217         @exception StandardException An attempt to start the service failed.
218
219         @see Monitor#startNonPersistentService
220     */

221     public Object JavaDoc startNonPersistentService(String JavaDoc factoryInterface, String JavaDoc serviceName, Properties JavaDoc properties)
222         throws StandardException;
223
224
225     /**
226         Find a service.
227
228         <BR>
229         <B>Do not call directly - use Monitor.findService()</B>
230
231         @return a refrence to a module represeting the service or null if the service does not exist.
232
233         @see Monitor#findService
234     */

235     public Object JavaDoc findService(String JavaDoc protocol, String JavaDoc identifier);
236
237
238     /**
239         Start a module.
240         
241         <BR>
242         <B>Do not call directly - use Monitor.startSystemModule() or Monitor.bootServiceModule()</B>
243
244         @exception StandardException An attempt to start the module failed.
245
246         @see Monitor#startSystemModule
247         @see Monitor#bootServiceModule
248     */

249     public Object JavaDoc startModule(boolean create, Object JavaDoc service, String JavaDoc protocol,
250                                      String JavaDoc identifier, Properties JavaDoc properties)
251                                      throws StandardException;
252
253
254     /**
255         Get the defined default system streams object.
256     */

257     public InfoStreams getSystemStreams();
258
259
260     /**
261         Start all services identified by derby.service.*
262         in the property set. If bootAll is true the services
263         that are persistent will be booted.
264     */

265     public void startServices(Properties JavaDoc properties, boolean bootAll);
266
267     /**
268         Return a property from the JVM's system set.
269         In a Java2 environment this will be executed as a privileged block
270         if and only if the property starts with 'derby.'.
271         If a SecurityException occurs, null is returned.
272     */

273     public String JavaDoc getJVMProperty(String JavaDoc key);
274
275     /**
276         Get a newly created background thread.
277         The thread is set to be a daemon but is not started.
278     */

279     public Thread JavaDoc getDaemonThread(Runnable JavaDoc task, String JavaDoc name, boolean setMinPriority);
280
281     /**
282         Set the priority of the current thread.
283         If the current thread was not returned by getDaemonThread() then no action is taken.
284     */

285     public void setThreadPriority(int priority);
286
287     public ProductVersionHolder getEngineVersion();
288
289     /**
290      * Get the UUID factory for the system. The UUID factory provides
291      * methods to create and recreate database unique identifiers.
292      */

293     public org.apache.derby.iapi.services.uuid.UUIDFactory getUUIDFactory();
294         
295     /**
296      * Get the Timer factory for the system. The Timer factory provides
297      * access to Timer objects for various purposes.
298      *
299      * @return the system's Timer factory.
300      */

301     public org.apache.derby.iapi.services.timer.TimerFactory getTimerFactory();
302 }
303
Popular Tags