--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.iapi.services.monitor.ModuleFactory\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.iapi.services.monitor;\r
+\r
+import org.apache.derby.iapi.services.info.ProductVersionHolder;\r
+import org.apache.derby.iapi.error.StandardException;\r
+import org.apache.derby.iapi.services.stream.InfoStreams;\r
+import org.apache.derby.iapi.services.monitor.PersistentService;\r
+import org.apache.derby.iapi.services.loader.InstanceGetter;\r
+\r
+import java.util.Properties;\r
+import java.util.Locale;\r
+import java.io.InputStream;\r
+import java.io.IOException;\r
+ \r
+/**\r
+The monitor provides a central registry for all modules in the system,\r
+and manages loading, starting, and finding them.\r
+*/\r
+\r
+public interface ModuleFactory\r
+{\r
+\r
+ /**\r
+ * Find the module in the system with the given module protocol,\r
+ * protocolVersion and identifier.\r
+ \r
+ * @return The module instance if found, or null.\r
+ */\r
+ public Object findModule(Object service, String protocol, String identifier);\r
+\r
+ /**\r
+ Return the name of the service that the passed in module lives in.\r
+ */\r
+ public String getServiceName(Object serviceModule);\r
+\r
+ /**\r
+ Return the locale of the service that the passed in module lives in.\r
+ Will return null if no-locale has been defined.\r
+ */\r
+ public Locale getLocale(Object serviceModule);\r
+\r
+ /**\r
+ Translate a string of the form ll[_CC[_variant]] to a Locale.\r
+ This is in the Monitor because we want this translation to be\r
+ in only one place in the code.\r
+ */\r
+ public Locale getLocaleFromString(String localeDescription)\r
+ throws StandardException;\r
+\r
+\r
+ /**\r
+ Set the locale for the service *outside* of boot time.\r
+\r
+ @param userDefinedLocale A String in the form xx_YY, where xx is the\r
+ language code and YY is the country code.\r
+\r
+ @return The new Locale for the service\r
+\r
+ @exception StandardException Thrown on error\r
+ */\r
+ public Locale setLocale(Object serviceModule, String userDefinedLocale)\r
+ throws StandardException;\r
+\r
+ /**\r
+ Set the locale for the service at boot time. The passed-in\r
+ properties must be the one passed to the boot method.\r
+\r
+ @exception StandardException Derby error.\r
+ */\r
+ public Locale setLocale(Properties serviceProperties,\r
+ String userDefinedLocale)\r
+ throws StandardException;\r
+\r
+ /**\r
+ Return the PersistentService object for a service.\r
+ Will return null if the service does not exist.\r
+ */\r
+ public PersistentService getServiceType(Object serviceModule);\r
+\r
+ /**\r
+ * Return the PersistentService for a subsubprotocol.\r
+ *\r
+ * @return the PersistentService or null if it does not exist\r
+ *\r
+ * @exception StandardException\r
+ */\r
+ public PersistentService getServiceProvider(String subSubProtocol) throws StandardException;\r
+ \r
+ /**\r
+ * Return the application set of properties which correspond\r
+ * to the set of properties in the file derby.properties.\r
+ */\r
+ public Properties getApplicationProperties();\r
+\r
+ /**\r
+ Shut down the complete system that was started by this Monitor. Will\r
+ cause the stop() method to be called on each loaded module.\r
+ */\r
+ public void shutdown();\r
+\r
+ /**\r
+ Shut down a service that was started by this Monitor. Will\r
+ cause the stop() method to be called on each loaded module.\r
+ Requires that a context stack exist.\r
+ */\r
+ public void shutdown(Object service);\r
+\r
+\r
+ /**\r
+ Obtain a class that supports the given identifier.\r
+\r
+ @param identifier identifer to associate with class\r
+\r
+ @return a reference InstanceGetter\r
+\r
+ @exception StandardException See Monitor.classFromIdentifier\r
+ */\r
+ public InstanceGetter classFromIdentifier(int identifier)\r
+ throws StandardException;\r
+\r
+ /**\r
+ Obtain an new instance of a class that supports the given identifier.\r
+\r
+ @param identifier identifer to associate with class\r
+\r
+ @return a reference to a newly created object\r
+\r
+ @exception StandardException See Monitor.newInstanceFromIdentifier\r
+ \r
+ */\r
+ public Object newInstanceFromIdentifier(int identifier)\r
+ throws StandardException;\r
+\r
+ /**\r
+ Return the environment object that this system was booted in.\r
+ This is a free form object that is set by the method the\r
+ system is booted. For example when running in a Marimba system\r
+ it is set to the maribma application context. In most environments\r
+ it will be set to a java.io.File object representing the system home directory.\r
+ Code that call this method usualy have predefined knowledge of the type of the returned object, e.g.\r
+ Marimba store code knows that this will be set to a marimba application\r
+ context.\r
+ */\r
+ public Object getEnvironment();\r
+\r
+\r
+ /**\r
+ Return an array of the service identifiers that are running and\r
+ implement the passed in protocol (java interface class name).\r
+ This list is a snapshot of the current running systesm, once\r
+ the call returns the service may have been shutdown or\r
+ new ones added.\r
+\r
+ @return The list of service names, if no services exist that\r
+ implement the protocol an array with zero elements is returned.\r
+ */\r
+ public String[] getServiceList(String protocol);\r
+\r
+ /**\r
+ Start a persistent service.\r
+ <BR>\r
+ <B>Do not call directly - use Monitor.startPersistentService()</B>\r
+ \r
+ <P> The poperty set passed in is for boot options for the modules\r
+ required to start the service. It does not support defining different\r
+ or new modules implementations.\r
+ \r
+ @param serviceName Name of the service to be started\r
+ @param properties Property set made available to all modules booted\r
+ for this service, through their ModuleControl.boot method.\r
+\r
+ @return true if the service type is handled by the monitor, false if it isn't\r
+\r
+ @exception StandardException An attempt to start the service failed.\r
+\r
+ @see Monitor#startPersistentService\r
+ */\r
+ public boolean startPersistentService(String serviceName, Properties properties)\r
+ throws StandardException;\r
+\r
+ /**\r
+ Create a persistent service.\r
+ <BR>\r
+ <B>Do not call directly - use Monitor.startPersistentService()</B>\r
+\r
+ @exception StandardException An attempt to create the service failed.\r
+\r
+ @see Monitor#createPersistentService\r
+ */\r
+ public Object createPersistentService(String factoryInterface, String serviceName, Properties properties)\r
+ throws StandardException;\r
+ public void removePersistentService(String name)\r
+ throws StandardException;\r
+ \r
+ /**\r
+ Start a non-persistent service.\r
+ \r
+ <BR>\r
+ <B>Do not call directly - use Monitor.startNonPersistentService()</B>\r
+\r
+ @exception StandardException An attempt to start the service failed.\r
+\r
+ @see Monitor#startNonPersistentService\r
+ */\r
+ public Object startNonPersistentService(String factoryInterface, String serviceName, Properties properties)\r
+ throws StandardException;\r
+\r
+\r
+ /**\r
+ Find a service.\r
+\r
+ <BR>\r
+ <B>Do not call directly - use Monitor.findService()</B>\r
+\r
+ @return a refrence to a module represeting the service or null if the service does not exist.\r
+\r
+ @see Monitor#findService\r
+ */\r
+ public Object findService(String protocol, String identifier);\r
+\r
+\r
+ /**\r
+ Start a module.\r
+ \r
+ <BR>\r
+ <B>Do not call directly - use Monitor.startSystemModule() or Monitor.bootServiceModule()</B>\r
+\r
+ @exception StandardException An attempt to start the module failed.\r
+\r
+ @see Monitor#startSystemModule\r
+ @see Monitor#bootServiceModule\r
+ */\r
+ public Object startModule(boolean create, Object service, String protocol,\r
+ String identifier, Properties properties)\r
+ throws StandardException;\r
+\r
+\r
+ /** \r
+ Get the defined default system streams object.\r
+ */\r
+ public InfoStreams getSystemStreams();\r
+\r
+\r
+ /**\r
+ Start all services identified by derby.service.*\r
+ in the property set. If bootAll is true the services\r
+ that are persistent will be booted.\r
+ */\r
+ public void startServices(Properties properties, boolean bootAll);\r
+\r
+ /**\r
+ Return a property from the JVM's system set.\r
+ In a Java2 environment this will be executed as a privileged block\r
+ if and only if the property starts with 'derby.'.\r
+ If a SecurityException occurs, null is returned.\r
+ */\r
+ public String getJVMProperty(String key);\r
+\r
+ /**\r
+ Get a newly created background thread.\r
+ The thread is set to be a daemon but is not started.\r
+ */\r
+ public Thread getDaemonThread(Runnable task, String name, boolean setMinPriority);\r
+\r
+ /**\r
+ Set the priority of the current thread.\r
+ If the current thread was not returned by getDaemonThread() then no action is taken.\r
+ */\r
+ public void setThreadPriority(int priority);\r
+\r
+ public ProductVersionHolder getEngineVersion();\r
+\r
+ /**\r
+ * Get the UUID factory for the system. The UUID factory provides\r
+ * methods to create and recreate database unique identifiers.\r
+ */\r
+ public org.apache.derby.iapi.services.uuid.UUIDFactory getUUIDFactory();\r
+ \r
+ /**\r
+ * Get the Timer factory for the system. The Timer factory provides\r
+ * access to Timer objects for various purposes.\r
+ *\r
+ * @return the system's Timer factory.\r
+ */\r
+ public org.apache.derby.iapi.services.timer.TimerFactory getTimerFactory();\r
+}\r