org.apache.derby.iapi.services.monitor
Interface ModuleFactory

All Known Implementing Classes:
BaseMonitor

public interface ModuleFactory

The monitor provides a central registry for all modules in the system, and manages loading, starting, and finding them.


Method Summary
 InstanceGetter classFromIdentifier(int identifier)
          Obtain a class that supports the given identifier.
 java.lang.Object createPersistentService(java.lang.String factoryInterface, java.lang.String serviceName, java.util.Properties properties)
          Create a persistent service.
 java.lang.Object findModule(java.lang.Object service, java.lang.String protocol, java.lang.String identifier)
          Find the module in the system with the given module protocol, protocolVersion and identifier.
 java.lang.Object findService(java.lang.String protocol, java.lang.String identifier)
          Find a service.
 java.util.Properties getApplicationProperties()
           
 java.lang.Thread getDaemonThread(java.lang.Runnable task, java.lang.String name, boolean setMinPriority)
          Get a newly created background thread.
 ProductVersionHolder getEngineVersion()
           
 java.lang.Object getEnvironment()
          Return the environment object that this system was booted in.
 java.lang.String getJVMProperty(java.lang.String key)
          Return a property from the JVM's system set.
 java.util.Locale getLocale(java.lang.Object serviceModule)
          Return the locale of the service that the passed in module lives in.
 java.util.Locale getLocaleFromString(java.lang.String localeDescription)
          Translate a string of the form ll[_CC[_variant]] to a Locale.
 java.lang.String[] getServiceList(java.lang.String protocol)
          Return an array of the service identifiers that are running and implement the passed in protocol (java interface class name).
 java.lang.String getServiceName(java.lang.Object serviceModule)
          Return the name of the service that the passed in module lives in.
 PersistentService getServiceProvider(java.util.Properties startParams, java.lang.String subSubProtocol)
          Return the PersistentService for a subsubprotocol.
 PersistentService getServiceType(java.lang.Object serviceModule)
          Return the PersistentService object for a service.
 InfoStreams getSystemStreams()
          Get the defined default system streams object.
 UUIDFactory getUUIDFactory()
          Get the UUID factory for the system.
 java.lang.Object newInstanceFromIdentifier(int identifier)
          Obtain an new instance of a class that supports the given identifier.
 void removePersistentService(java.lang.String name)
           
 java.util.Locale setLocale(java.lang.Object serviceModule, java.lang.String userDefinedLocale)
          Set the locale for the service *outside* of boot time.
 java.util.Locale setLocale(java.util.Properties serviceProperties, java.lang.String userDefinedLocale)
          Set the locale for the service at boot time.
 void setThreadPriority(int priority)
          Set the priority of the current thread.
 void shutdown()
          Shut down the complete system that was started by this Monitor.
 void shutdown(java.lang.Object service)
          Shut down a service that was started by this Monitor.
 java.lang.Object startModule(boolean create, java.lang.Object service, java.lang.String protocol, java.lang.String identifier, java.util.Properties properties)
          Start a module.
 java.lang.Object startNonPersistentService(java.lang.String factoryInterface, java.lang.String serviceName, java.util.Properties properties)
          Start a non-persistent service.
 boolean startPersistentService(java.lang.String serviceName, java.util.Properties properties)
          Start a persistent service.
 void startServices(java.util.Properties properties, boolean bootAll)
          Start all services identified by derby.service.* in the property set.
 

Method Detail

findModule

public java.lang.Object findModule(java.lang.Object service,
                                   java.lang.String protocol,
                                   java.lang.String identifier)
Find the module in the system with the given module protocol, protocolVersion and identifier.

Returns:
The module instance if found, or null.

getServiceName

public java.lang.String getServiceName(java.lang.Object serviceModule)
Return the name of the service that the passed in module lives in.


getLocale

public java.util.Locale getLocale(java.lang.Object serviceModule)
Return the locale of the service that the passed in module lives in. Will return null if no-locale has been defined.


getLocaleFromString

public java.util.Locale getLocaleFromString(java.lang.String localeDescription)
                                     throws StandardException
Translate a string of the form ll[_CC[_variant]] to a Locale. This is in the Monitor because we want this translation to be in only one place in the code.

Throws:
StandardException

setLocale

public java.util.Locale setLocale(java.lang.Object serviceModule,
                                  java.lang.String userDefinedLocale)
                           throws StandardException
Set the locale for the service *outside* of boot time.

Parameters:
userDefinedLocale - A String in the form xx_YY, where xx is the language code and YY is the country code.
Returns:
The new Locale for the service
Throws:
StandardException - Thrown on error

setLocale

public java.util.Locale setLocale(java.util.Properties serviceProperties,
                                  java.lang.String userDefinedLocale)
                           throws StandardException
Set the locale for the service at boot time. The passed-in properties must be the one passed to the boot method.

Throws:
StandardException - Cloudscape error.

getServiceType

public PersistentService getServiceType(java.lang.Object serviceModule)
Return the PersistentService object for a service. Will return null if the service does not exist.


getServiceProvider

public PersistentService getServiceProvider(java.util.Properties startParams,
                                            java.lang.String subSubProtocol)
                                     throws StandardException
Return the PersistentService for a subsubprotocol.

Returns:
the PersistentService or null if it does not exist
Throws:
StandardException

getApplicationProperties

public java.util.Properties getApplicationProperties()

shutdown

public void shutdown()
Shut down the complete system that was started by this Monitor. Will cause the stop() method to be called on each loaded module.


shutdown

public void shutdown(java.lang.Object service)
Shut down a service that was started by this Monitor. Will cause the stop() method to be called on each loaded module. Requires that a context stack exist.


classFromIdentifier

public InstanceGetter classFromIdentifier(int identifier)
                                   throws StandardException
Obtain a class that supports the given identifier.

Parameters:
identifier - identifer to associate with class
Returns:
a reference InstanceGetter
Throws:
StandardException - See Monitor.classFromIdentifier

newInstanceFromIdentifier

public java.lang.Object newInstanceFromIdentifier(int identifier)
                                           throws StandardException
Obtain an new instance of a class that supports the given identifier.

Parameters:
identifier - identifer to associate with class
Returns:
a reference to a newly created object
Throws:
StandardException - See Monitor.newInstanceFromIdentifier

getEnvironment

public java.lang.Object getEnvironment()
Return the environment object that this system was booted in. This is a free form object that is set by the method the system is booted. For example when running in a Marimba system it is set to the maribma application context. In most environments it will be set to a java.io.File object representing the system home directory. Code that call this method usualy have predefined knowledge of the type of the returned object, e.g. Marimba store code knows that this will be set to a marimba application context.


getServiceList

public java.lang.String[] getServiceList(java.lang.String protocol)
Return an array of the service identifiers that are running and implement the passed in protocol (java interface class name). This list is a snapshot of the current running systesm, once the call returns the service may have been shutdown or new ones added.

Returns:
The list of service names, if no services exist that implement the protocol an array with zero elements is returned.

startPersistentService

public boolean startPersistentService(java.lang.String serviceName,
                                      java.util.Properties properties)
                               throws StandardException
Start a persistent service.
Do not call directly - use Monitor.startPersistentService()

Returns:
true if the service type is handled by the monitor, false if it isn't
Throws:
StandardException - An attempt to start the service failed.
See Also:
Monitor.startPersistentService(java.lang.String, java.util.Properties)

createPersistentService

public java.lang.Object createPersistentService(java.lang.String factoryInterface,
                                                java.lang.String serviceName,
                                                java.util.Properties properties)
                                         throws StandardException
Create a persistent service.
Do not call directly - use Monitor.startPersistentService()

Throws:
StandardException - An attempt to create the service failed.
See Also:
Monitor.createPersistentService(java.lang.String, java.lang.String, java.util.Properties)

removePersistentService

public void removePersistentService(java.lang.String name)
                             throws StandardException
Throws:
StandardException

startNonPersistentService

public java.lang.Object startNonPersistentService(java.lang.String factoryInterface,
                                                  java.lang.String serviceName,
                                                  java.util.Properties properties)
                                           throws StandardException
Start a non-persistent service.
Do not call directly - use Monitor.startNonPersistentService()

Throws:
StandardException - An attempt to start the service failed.
See Also:
Monitor.startNonPersistentService(java.lang.String, java.lang.String, java.util.Properties)

findService

public java.lang.Object findService(java.lang.String protocol,
                                    java.lang.String identifier)
Find a service.
Do not call directly - use Monitor.findService()

Returns:
a refrence to a module represeting the service or null if the service does not exist.
See Also:
Monitor.findService(java.lang.String, java.lang.String)

startModule

public java.lang.Object startModule(boolean create,
                                    java.lang.Object service,
                                    java.lang.String protocol,
                                    java.lang.String identifier,
                                    java.util.Properties properties)
                             throws StandardException
Start a module.
Do not call directly - use Monitor.startSystemModule() or Monitor.bootServiceModule()

Throws:
StandardException - An attempt to start the module failed.
See Also:
Monitor.startSystemModule(java.lang.String), Monitor.bootServiceModule(boolean, java.lang.Object, java.lang.String, java.util.Properties)

getSystemStreams

public InfoStreams getSystemStreams()
Get the defined default system streams object.


startServices

public void startServices(java.util.Properties properties,
                          boolean bootAll)
Start all services identified by derby.service.* in the property set. If bootAll is true the services that are persistent will be booted.


getJVMProperty

public java.lang.String getJVMProperty(java.lang.String key)
Return a property from the JVM's system set. In a Java2 environment this will be executed as a privliged block if and only if the property starts with db2j. If a SecurityException occurs, null is returned.


getDaemonThread

public java.lang.Thread getDaemonThread(java.lang.Runnable task,
                                        java.lang.String name,
                                        boolean setMinPriority)
Get a newly created background thread. The thread is set to be a daemon but is not started.


setThreadPriority

public void setThreadPriority(int priority)
Set the priority of the current thread. If the current thread was not returned by getDaemonThread() then no action is taken.


getEngineVersion

public ProductVersionHolder getEngineVersion()

getUUIDFactory

public UUIDFactory getUUIDFactory()
Get the UUID factory for the system. The UUID factory provides methods to create and recreate database unique identifiers.



Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.