Services
A service is a collection of modules that combine to provide
the full functionality defined by the service. A service is defined
by three pieces of information:
Booting Services
Services can be booted a number of ways
derby.service.service name=class name e.g. # Added to the properties automatically by the class org.apache.derby.jdbc.EmbeddedDriver derby.service.jdbc=java.sql.Driver
derby.service.service name=persistent storage type e.g. derby.service.mydatabase=serviceDirectoryserviceDirectory is a type understood by the monitor which means that there is a directory named mydatabase within the system directory and within it is a properties file service.properties. This properties set is the set for the service and must contain a property
derby.protocol=class nameThis is then the factory interface for the service. Other storage types could be added in the future.
System Service
A special service exists, the System Service. This service has no factory interface,
no identifier and no Properties set. It allows modules to be started that are required
by another service (or the monitor itself) but are not fundamentally part of the service.
Modules within this service are unidentified.
Typically these modules are system wide types of functionality like streams, uuid creation etc.
The lifetime of a system module is the lifetime of the monitor.
Optionally - this could be changed to reference count on individual modules, requires
some minor api changes.
Modules
A module is found or booted using four pieces of information:
Module Implementations
When creating an instance of a module, an implementation is found through lists of
potential implementations.
A list of potential implementations is obtained from a Properties set. Any property
within this set that is of the form
derby.module.tag=java class nameis seen by the monitor as a possible implementation. tag has no meaning within the monitor, it is only there to provide uniqueness within the properties file. Typically the tag is to provide some description for human readers of the properties file, e.g. derby.module.lockManager for an implementation of a lock manager.
Module Searching
When searching for a module the search space is always restricted to a single service.
This service is usually the system service or the service of the module making the
search request. It would be very rare (wrong?) to search for a module in a service that
was not the current service and not the system service.
Within the list of modules in the service the search is conducted as follows:
Service Properties
Within the service's Properties a module may search for its parameters. It identifies
its parameters using a unqiue parameter name and its identifier.
Unique parameter names are made unique through the 'dot' convention of Properties
files. A module protocol picks some unique key portion to start, e.g. RawStore for the RawStoreFactory
and then extends that for specific parameters, e.g. RawStore.PageSize. Thus
parameters that are typically understood by all implementations of that protocol would
start with that key portion. Parameters for specific implementations add another key portion
onto the protocol key portion, e.g. RawStore.FileSystem for an file system implementation
of the raw store, with a specific parameter being RawStore.FileSystem.SectorSize.
These are general guidelines, UUID's could be used as the properties keys but
would make the parameters hard to read.
When a module is unidentified it should look for a parameter using just
the property key for that parameter, e.g. getProperty("RawStore.PageSize").
When a module has an identifier is should look for a property using the
key with a dot and the identifier appended, e.g. getProperty("RawStore.PageSize" + "." + identifier).
In addition to searching for parameters in the service properties set, the system and
application set may be searched using the getProperty() method of ModuleFactory.
Should any order be defined for this, should it be automatic?
| Modifier and Type | Field and Description |
|---|---|
| private static boolean | |
| public static final String | |
| public static final String | |
| private static ModuleFactory | |
| public static final String | NEW_INSTANCE_FROM_ID_TRACE_DEBUG_FLAG
Global debug flag to turn on tracing of reads calls newInstanceFromIdentifier() |
| public static final String | |
| public static final Object |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static Object | Returns: a reference to a module.Boot or find a unidentified module within a service. |
| public static Object | Returns: a reference to a module.Boot or find a identified module within a service. |
| public static InstanceGetter | Returns: a valid class objectObtain the class object for a class that supports the given identifier. |
| public static void | |
| public static Object | Returns: The module from the service if it was created successfully, null if a service already existed.Create a named service that implements the java interface (or class) fully qualified by factoryInterface. |
| public static StandardException | Returns: The exception.the exception which caused starting the module to fail. t)return a StandardException to indicate that an exception caused starting the module to fail. |
| public static Object | Returns: a refrence to a module represeting the service or null if the service does not exist.Find a service. |
| public static Object | Returns: a reference to a module or null if one cannot be found.Find an unidentified module within a service. |
| public static Object | Returns: a reference to a module or null if one cannot be found.Find a module in the system service. |
| public static int | |
| public static Locale | getLocaleFromString(String localeDescription)
Translate a localeDescription of the form ll[_CC[_variant]] to a Locale object. |
| public static ModuleFactory | |
| public static ModuleFactory | |
| public static Object | |
| public static String | getServiceName(Object serviceModule)
Return the name of the service that the passed in module lives in. |
| public static HeaderPrintWriter | |
| public static Object | |
| public static boolean | isDesiredCreateType(Properties p, int type)
Return true if the properties set provided contains database creation attributes for a database of the correct type |
| public static boolean | Returns: true type is as desired. false otherwisestartup parameters startParams, int property we're interested in desiredProperty)
|
| public static boolean | |
| public static boolean | Returns: true a full upgrade has been requested, false soft upgrade mode is active.Single point for checking if an upgrade is allowed. |
| public static void | |
| public static void | |
| public static void | |
| public static StandardException | Returns: The exception.the module name of the missing implementation. implementation)return a StandardException to indicate a missing implementation. |
| public static StandardException | Returns: The exception.The genus name of the product. productGenusName)return a StandardException to indicate that a module failed to start because it could not obtain the version of a required product. |
| public static Object | Returns: a reference to a newly created objectObtain an new instance of a class that supports the given identifier. |
| public static void | |
| public static boolean | setMonitor(ModuleFactory theMonitor)
Initialize this class, must only be called by an implementation of the monitor (ModuleFactory). |
| public static void | startMonitor(Properties
The application properties bootProperties, PrintWriter Where to place initial error output. This location will be used
until an InfoStreams module is successfully started. logging)Start a Monitor based software system. |
| public static Object | Returns: The module from the service if it was started successfully.Start a non-persistent service. |
| public static boolean | Returns: true if the service type is handled by the monitor, false if it isn'tName of the service to be started serviceName, Properties Property set made available to all modules booted
for this service, through their ModuleControl.boot method. properties)Start a persistent service. |
| public static Object | Returns: a reference to a module.Start or find a module in the system service. |
| active | back to summary |
|---|---|
| private static boolean active | |
| DEBUG_FALSE | back to summary |
|---|---|
| public static final String DEBUG_FALSE | |
| DEBUG_TRUE | back to summary |
|---|---|
| public static final String DEBUG_TRUE | |
| monitor | back to summary |
|---|---|
| private static ModuleFactory monitor | |
| NEW_INSTANCE_FROM_ID_TRACE_DEBUG_FLAG | back to summary |
|---|---|
| public static final String NEW_INSTANCE_FROM_ID_TRACE_DEBUG_FLAG Global debug flag to turn on tracing of reads calls newInstanceFromIdentifier() | |
| SERVICE_TYPE_DIRECTORY | back to summary |
|---|---|
| public static final String SERVICE_TYPE_DIRECTORY | |
| syncMe | back to summary |
|---|---|
| public static final Object syncMe | |
| Monitor | back to summary |
|---|---|
| public Monitor() | |
| bootServiceModule | back to summary |
|---|---|
| public static Object bootServiceModule(boolean create, Object serviceModule, String factoryInterface, Properties properties) throws StandardException Boot or find a unidentified module within a service. This call allows modules to start or create any modules they explicitly require to exist within their service. If no module matching the criteria is found (see this class's prologue for details) then an instance will be created (see prologue) and booted as follows. ((ModuleControl) instance).boot(create, (String) null, properties); The service is defined by the service that the module serviceModule lives in, typically this call is made from the boot method of a module and thus 'this' is passed in for serviceModule.
| |
| bootServiceModule | back to summary |
|---|---|
| public static Object bootServiceModule(boolean create, Object serviceModule, String factoryInterface, String identifier, Properties properties) throws StandardException Boot or find a identified module within a service. This call allows modules to start or create any modules they explicitly require to exist within their service. If no module matching the criteria is found (see this class's prologue for details) then an instance will be created (see prologue) and booted as follows. ((ModuleControl) instance).boot(create, identifer, properties); The service is defined by the service that the module serviceModule lives in, typically this call is made from the boot method of a module and thus 'this' is passed in for serviceModule.
| |
| classFromIdentifier | back to summary |
|---|---|
| public static InstanceGetter classFromIdentifier(int identifier) throws StandardException Obtain the class object for a class that supports the given identifier. If no class has been registered for the identifier then a StandardException is thrown with no attached java.lang exception (nextException). If a problem loading or accessing the class is obtained then a StandardException is thrown with the real java.lang exception attached.
| |
| clearMonitor | back to summary |
|---|---|
| public static void clearMonitor() | |
| createPersistentService | back to summary |
|---|---|
| public static Object createPersistentService(String factoryInterface, String serviceName, Properties properties) throws StandardException Create a named service that implements the java interface (or class) fully qualified by factoryInterface. The Properties object specifies create time parameters to be used by the modules within the service. Any module created by this service may add or remove parameters within the properties object in their ModuleControl.boot() method. The properties set will be saved by the Monitor for later use when the monitor is started. Context
| |
| exceptionStartingModule | back to summary |
|---|---|
| public static StandardException exceptionStartingModule(Throwable t) return a StandardException to indicate that an exception caused starting the module to fail.
| |
| findService | back to summary |
|---|---|
| public static Object findService(String factoryInterface, String serviceName) Find a service.
| |
| findServiceModule | back to summary |
|---|---|
| public static Object findServiceModule(Object serviceModule, String factoryInterface) throws StandardException Find an unidentified module within a service.
| |
| findSystemModule | back to summary |
|---|---|
| public static Object findSystemModule(String factoryInterface) throws StandardException Find a module in the system service.
| |
| getEngineType | back to summary |
|---|---|
public static int getEngineType(Properties startParams)
| |
| getLocaleFromString | back to summary |
|---|---|
| public static Locale getLocaleFromString(String localeDescription) throws StandardException Translate a localeDescription of the form ll[_CC[_variant]] to a Locale object. | |
| getMonitor | back to summary |
|---|---|
| public static ModuleFactory getMonitor() Get the monitor. | |
| getMonitorLite | back to summary |
|---|---|
| public static ModuleFactory getMonitorLite() | |
| getServiceModule | back to summary |
|---|---|
| public static Object getServiceModule(Object serviceModule, String factoryInterface) | |
| getServiceName | back to summary |
|---|---|
| public static String getServiceName(Object serviceModule) Return the name of the service that the passed in module lives in. | |
| getStream | back to summary |
|---|---|
| public static HeaderPrintWriter getStream() | |
| getSystemModule | back to summary |
|---|---|
| public static Object getSystemModule(String factoryInterface) Return a system module. If it cannot be found or the monitor is not running then null is returned. | |
| isDesiredCreateType | back to summary |
|---|---|
| public static boolean isDesiredCreateType(Properties p, int type) Return true if the properties set provided contains database creation attributes for a database of the correct type | |
| isDesiredType | back to summary |
|---|---|
public static boolean isDesiredType(Properties startParams, int desiredProperty)
| |
| isDesiredType | back to summary |
|---|---|
| public static boolean isDesiredType(int engineType, int desiredType) Is engineType a match for desiredType. A match exists if the bit intersect of the two values is no zero. | |
| isFullUpgrade | back to summary |
|---|---|
| public static boolean isFullUpgrade(Properties startParams, String oldVersionInfo) throws StandardException Single point for checking if an upgrade is allowed.
| |
| logMessage | back to summary |
|---|---|
| public static void logMessage(String messageText) | |
| logTextMessage | back to summary |
|---|---|
| public static void logTextMessage(String messageID, Object... args) | |
| logThrowable | back to summary |
|---|---|
| public static void logThrowable(Throwable t) Logs the stack trace of the specified throwable object. | |
| missingImplementation | back to summary |
|---|---|
| public static StandardException missingImplementation(String implementation) return a StandardException to indicate a missing implementation.
| |
| missingProductVersion | back to summary |
|---|---|
| public static StandardException missingProductVersion(String productGenusName) return a StandardException to indicate that a module failed to start because it could not obtain the version of a required product.
| |
| newInstanceFromIdentifier | back to summary |
|---|---|
| public static Object newInstanceFromIdentifier(int identifier) throws StandardException Obtain an new instance of a class that supports the given identifier. If no class has been registered for the identifier then a StandardException is thrown with no attached java.lang exception (getNestedException). If a problem loading or accessing the class or creating the object is obtained then a StandardException is thrown with the real java.lang exception attached.
| |
| removePersistentService | back to summary |
|---|---|
| public static void removePersistentService(String name) throws StandardException | |
| setMonitor | back to summary |
|---|---|
| public static boolean setMonitor(ModuleFactory theMonitor) Initialize this class, must only be called by an implementation of the monitor (ModuleFactory). | |
| startMonitor | back to summary |
|---|---|
| public static void startMonitor(Properties bootProperties, PrintWriter logging) Start a Monitor based software system. This method will execute the following steps.
If MonitorBoot.start() is called more then once then subsequent calls have no effect.
| |
| startNonPersistentService | back to summary |
|---|---|
| public static Object startNonPersistentService(String factoryInterface, String serviceName, Properties properties) throws StandardException Start a non-persistent service. Context
| |
| startPersistentService | back to summary |
|---|---|
| public static boolean startPersistentService(String serviceName, Properties properties) throws StandardException Start a persistent service. The name of the service can include a
service type, in the form 'type:serviceName'.
The poperty set passed in is for boot options for the modules required to start the service. It does not support defining different or new modules implementations.
| |
| startSystemModule | back to summary |
|---|---|
| public static Object startSystemModule(String factoryInterface) throws StandardException Start or find a module in the system service. This call allows modules to explictly start services they require. If no module matching the criteria is found (see this class's prologue for details) then an instance will be created (see prologue) and booted as follows. ((ModuleControl) instance).boot(false, (String) null, (Properties) null);
| |