Java Doc for Monitor.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » iapi » services » monitor » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derby.iapi.services.monitor 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.derby.iapi.services.monitor.Monitor

Monitor
public class Monitor (Code)

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:

  1. A fully qualified java class name that identifies the functionality or API that the service must provide. Typically this class represents a java interface. This class name is termed the factory interface.
  2. The identifier of the service. Services are identified by a String, this may be hard-coded, come from a UUID or any other source.
  3. An optional java.util.Properties set.

The running functionality of the service is provided by a module that implements the factory interface. The identifier of the this module is not (need not be) the same as the identifier of the service. The identifier of the service is held by the monitor in its service tables.
Each module in a service is keyed by at least one factory interface, identifier} pair. This pair is guaranteed to be unique within the service.
The lifetime of a module in a service is no longer than the lifetime of the service. Thus shutting down a service shuts down all the modules within a service. Optionally - an individual module within a service may be shutdown, this will in turn shutdown any modules it started if those module are not in use by other modules within the service. This would be handled by the monitor, not the module itself.
A service may be persistent, it goes through a boot in create mode, and subsequently boot in non-create mode, or a non-peristent service, it always boots in non-create mode. Persistent services can store their re-start parameters in their properties set, the monitor provides the persistent storage of the properties set. Non-persistent services do not have a properties set.

Booting Services
Services can be booted a number of ways

  • A non-persistent service can be booted by having a property in the application properties or the system (JVM) set.
     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
     
  • A persistent service can be booted by having a property in the application properties or the system (JVM) set.
     derby.service.service name=persistent storage type
     e.g.
     derby.service.mydatabase=serviceDirectory
     
    serviceDirectory 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 name
     
    This is then the factory interface for the service. Other storage types could be added in the future.
  • The monitor at start time looks for all persistent services that it can find and starts them. E.g. all directories in the system directory that have a file service.properties are started as services.
  • Services are started on demand, e.g. a findService attempts to boot a service if it cannot be found.
Any or all of these three latter methods can be implemented. A first release may just implement the look for all services and boot them. .

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:

  1. The service the module lives in or will live in.
  2. A fully qualified java class name that identifies the functionality or API that the module must provide. Typically this class represents a java interface. This class name is termed the factory interface.
  3. The identifier of the module. Modules are identified by a String, this may be null, be hard-coded, come from a UUID or any other source. If the identifier is null then the module is described as unidentified.
  4. Boot time only - A java.util.Properties set. This Properties set is service wide and typically contains parameters used to determine module implementation or runtime behaviour.

The service is identified by explicitly identifiying the System Service or by providing a reference to a module that already exists with the required service.
The factory interface is provided by a String constant of the form class.MODULE from the required interface.
The module identifier is provided in a fashion determined by the code, in most cases a unidentified module will suffice.
The Properties set is also determined in a fashion determined by the code at create or add service time.

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 name
 
is 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.
The monitor looks through four properties sets for lists of potential implementations in this order.
  1. The properties set of the service (i.e. that passed into Monitor.createPersistentService() or Monitor.startService()).
  2. The System (JVM) properties set (i.e. java.lang.System.getProperties()).
  3. The application properties set (i.e. obtained from the cloudscape.properties file).
  4. The default implementation properties set (i.e. obtained from the /org/apache/derby/modules.properties resource).
Any one of the properties can be missing or not have any implementations listed within it.
Every request to create an instance of a module searches the four implementation lists in the order above. Which list the current running code or the passed in service module came from is not relevant.
Within each list of potential implementations the search is conducted as follows:
  1. Attempt to load the class, if the class cannot be loaded skip to the next potential implementation.
  2. See if the factory interface is assignable from the class (isAssignableFrom() method of java.lang.Class), if not skip to the next potential implementation.
  3. See if an instance of the class can be created without any exceptions (newInstance() method of java.lang.Class), if not skip to the next potential implementation.
  4. [boot time only] See if the canSupport() method of ModuleControl returns true when called with the Properties set of the service, if not skip to the next potential implementation.
If all these checks pass then the instance is a valid implementation and its boot() method of ModuleControl is called to activate it. Note that the search order within the list obtained from a Properties set is not guaranteed.

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:

  1. See if the instance of the module an instance of the factory interface (isInstance() method of java.lang.Class), if not skip to the next module.
  2. See if the identifier of the module matches the required identifier, if not skip to the next module.
  3. See if the canSupport() method of ModuleControl returns true when called with the Properties set of the service, if not skip to the next module.
Note that no search order of the modules is guaranteed.
Also note that a module may be found by a different factory interface to the one it was created under. Thus a class may implement multiple factory interfaces, its boot method has no knowledge of which factory interface it was requested by.

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?



Field Summary
final public static  StringDEBUG_FALSE
    
final public static  StringDEBUG_TRUE
    
final public static  StringNEW_INSTANCE_FROM_ID_TRACE_DEBUG_FLAG
    
final public static  StringSERVICE_TYPE_DIRECTORY
    
final public static  ObjectsyncMe
    

Constructor Summary
public  Monitor()
    

Method Summary
public static  ObjectbootServiceModule(boolean create, Object serviceModule, String factoryInterface, Properties properties)
     Boot or find a unidentified module within a service.
public static  ObjectbootServiceModule(boolean create, Object serviceModule, String factoryInterface, String identifier, Properties properties)
     Boot or find a identified module within a service.
public static  InstanceGetterclassFromIdentifier(int identifier)
     Obtain the class object for a class that supports the given identifier.
public static  voidclearMonitor()
    
public static  ObjectcreatePersistentService(String factoryInterface, String serviceName, Properties properties)
     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.
public static  StandardExceptionexceptionStartingModule(Throwable t)
     return a StandardException to indicate that an exception caused starting the module to fail.
Parameters:
  t - the exception which caused starting the module to fail.
public static  ObjectfindService(String factoryInterface, String serviceName)
     Find a service.
public static  ObjectfindServiceModule(Object serviceModule, String factoryInterface)
     Find an unidentified module within a service.
public static  ObjectfindSystemModule(String factoryInterface)
     Find a module in the system service.
public static  intgetEngineType(Properties startParams)
    
public static  LocalegetLocaleFromString(String localeDescription)
     Translate a localeDescription of the form ll[_CC[_variant]] to a Locale object.
public static  ModuleFactorygetMonitor()
     Get the monitor.
public static  ModuleFactorygetMonitorLite()
    
public static  ObjectgetServiceModule(Object serviceModule, String factoryInterface)
    
public static  StringgetServiceName(Object serviceModule)
     Return the name of the service that the passed in module lives in.
public static  HeaderPrintWritergetStream()
    
public static  ObjectgetSystemModule(String factoryInterface)
    
public static  booleanisDesiredCreateType(Properties p, int type)
    
public static  booleanisDesiredType(Properties startParams, int desiredProperty)
    
public static  booleanisDesiredType(int engineType, int desiredProperty)
    
public static  booleanisFullUpgrade(Properties startParams, String oldVersionInfo)
     Single point for checking if an upgrade is allowed.
public static  voidlogMessage(String messageText)
    
public static  voidlogTextMessage(String messageID)
    
public static  voidlogTextMessage(String messageID, Object a1)
    
public static  voidlogTextMessage(String messageID, Object a1, Object a2)
    
public static  voidlogTextMessage(String messageID, Object a1, Object a2, Object a3)
    
public static  voidlogTextMessage(String messageID, Object a1, Object a2, Object a3, Object a4)
    
public static  StandardExceptionmissingImplementation(String implementation)
     return a StandardException to indicate a missing implementation.
Parameters:
  implementation - the module name of the missing implementation.
public static  StandardExceptionmissingProductVersion(String productGenusName)
     return a StandardException to indicate that a module failed to start because it could not obtain the version of a required product.
Parameters:
  productGenusName - The genus name of the product.
public static  ObjectnewInstanceFromIdentifier(int identifier)
     Obtain an new instance of a class that supports the given identifier.
public static  voidremovePersistentService(String name)
    
public static  booleansetMonitor(ModuleFactory theMonitor)
     Initialise this class, must only be called by an implementation of the monitor (ModuleFactory).
public static  voidstartMonitor(Properties bootProperties, PrintStream logging)
     Start a Monitor based software system. This method will execute the following steps.
  1. Create an instance of a module (monitor) of the required implementation.
  2. Start the monitor which will in turn start any requested services
  3. Execute the run() method of startCode (if startCode was not null).
  4. Return.

If MonitorBoot.start() is called more then once then subsequent calls have no effect.
Parameters:
  bootProperties - The application properties
Parameters:
  logging - Where to place initial error output.

public static  ObjectstartNonPersistentService(String factoryInterface, String serviceName, Properties properties)
     Start a non-persistent service.
public static  booleanstartPersistentService(String serviceName, Properties properties)
     Start a persistent service.
public static  ObjectstartSystemModule(String factoryInterface)
     Start or find a module in the system service.

Field Detail
DEBUG_FALSE
final public static String DEBUG_FALSE(Code)



DEBUG_TRUE
final public static String DEBUG_TRUE(Code)



NEW_INSTANCE_FROM_ID_TRACE_DEBUG_FLAG
final public static String NEW_INSTANCE_FROM_ID_TRACE_DEBUG_FLAG(Code)
Global debug flag to turn on tracing of reads calls newInstanceFromIdentifier()



SERVICE_TYPE_DIRECTORY
final public static String SERVICE_TYPE_DIRECTORY(Code)



syncMe
final public static Object syncMe(Code)




Constructor Detail
Monitor
public Monitor()(Code)




Method Detail
bootServiceModule
public static Object bootServiceModule(boolean create, Object serviceModule, String factoryInterface, Properties properties) throws StandardException(Code)
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. a reference to a module.
exception:
  StandardException - An attempt to start the module failed.



bootServiceModule
public static Object bootServiceModule(boolean create, Object serviceModule, String factoryInterface, String identifier, Properties properties) throws StandardException(Code)
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. a reference to a module.
exception:
  StandardException - An attempt to start the module failed.



classFromIdentifier
public static InstanceGetter classFromIdentifier(int identifier) throws StandardException(Code)
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. a valid class object
exception:
  StandardException - See text above.



clearMonitor
public static void clearMonitor()(Code)



createPersistentService
public static Object createPersistentService(String factoryInterface, String serviceName, Properties properties) throws StandardException(Code)
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
A context manager will be created and installed at the start of this method and destroyed just before this method returns. The module from the service if it was created successfully, null if a service already existed.
exception:
  StandardException - An exception was thrown trying to create the service.




exceptionStartingModule
public static StandardException exceptionStartingModule(Throwable t)(Code)
return a StandardException to indicate that an exception caused starting the module to fail.
Parameters:
  t - the exception which caused starting the module to fail. The exception.



findService
public static Object findService(String factoryInterface, String serviceName)(Code)
Find a service. a refrence to a module represeting the service or null if the service does not exist.



findServiceModule
public static Object findServiceModule(Object serviceModule, String factoryInterface) throws StandardException(Code)
Find an unidentified module within a service.
The service is defined by the service that the module serviceModule lives in. a reference to a module or null if one cannot be found.



findSystemModule
public static Object findSystemModule(String factoryInterface) throws StandardException(Code)
Find a module in the system service. a reference to a module or null if one cannot be found.



getEngineType
public static int getEngineType(Properties startParams)(Code)

Parameters:
  startParams - startup parameters type of engine



getLocaleFromString
public static Locale getLocaleFromString(String localeDescription) throws StandardException(Code)
Translate a localeDescription of the form ll[_CC[_variant]] to a Locale object.



getMonitor
public static ModuleFactory getMonitor()(Code)
Get the monitor.



getMonitorLite
public static ModuleFactory getMonitorLite()(Code)



getServiceModule
public static Object getServiceModule(Object serviceModule, String factoryInterface)(Code)



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



getStream
public static HeaderPrintWriter getStream()(Code)



getSystemModule
public static Object getSystemModule(String factoryInterface)(Code)



isDesiredCreateType
public static boolean isDesiredCreateType(Properties p, int type)(Code)
Return true if the properties set provided contains database creation attributes for a database of the correct type



isDesiredType
public static boolean isDesiredType(Properties startParams, int desiredProperty)(Code)

Parameters:
  startParams - startup parameters
Parameters:
  desiredProperty - property we're interested in true type is as desired.false otherwise



isDesiredType
public static boolean isDesiredType(int engineType, int desiredProperty)(Code)



isFullUpgrade
public static boolean isFullUpgrade(Properties startParams, String oldVersionInfo) throws StandardException(Code)
Single point for checking if an upgrade is allowed. true a full upgrade has been requested, false soft upgrade mode is active.



logMessage
public static void logMessage(String messageText)(Code)



logTextMessage
public static void logTextMessage(String messageID)(Code)



logTextMessage
public static void logTextMessage(String messageID, Object a1)(Code)



logTextMessage
public static void logTextMessage(String messageID, Object a1, Object a2)(Code)



logTextMessage
public static void logTextMessage(String messageID, Object a1, Object a2, Object a3)(Code)



logTextMessage
public static void logTextMessage(String messageID, Object a1, Object a2, Object a3, Object a4)(Code)



missingImplementation
public static StandardException missingImplementation(String implementation)(Code)
return a StandardException to indicate a missing implementation.
Parameters:
  implementation - the module name of the missing implementation. The exception.



missingProductVersion
public static StandardException missingProductVersion(String productGenusName)(Code)
return a StandardException to indicate that a module failed to start because it could not obtain the version of a required product.
Parameters:
  productGenusName - The genus name of the product. The exception.



newInstanceFromIdentifier
public static Object newInstanceFromIdentifier(int identifier) throws StandardException(Code)
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. a reference to a newly created object
exception:
  StandardException - See text above.



removePersistentService
public static void removePersistentService(String name) throws StandardException(Code)



setMonitor
public static boolean setMonitor(ModuleFactory theMonitor)(Code)
Initialise this class, must only be called by an implementation of the monitor (ModuleFactory).



startMonitor
public static void startMonitor(Properties bootProperties, PrintStream logging)(Code)
Start a Monitor based software system. This method will execute the following steps.
  1. Create an instance of a module (monitor) of the required implementation.
  2. Start the monitor which will in turn start any requested services
  3. Execute the run() method of startCode (if startCode was not null).
  4. Return.

If MonitorBoot.start() is called more then once then subsequent calls have no effect.
Parameters:
  bootProperties - The application properties
Parameters:
  logging - Where to place initial error output. This location will be useduntil an InfoStreams module is successfully started.




startNonPersistentService
public static Object startNonPersistentService(String factoryInterface, String serviceName, Properties properties) throws StandardException(Code)
Start a non-persistent service.

Context
A context manager will be created and installed at the start of this method and destroyed just before this method returns. The module from the service if it was started successfully.
exception:
  StandardException - An exception was thrown trying to start the service.




startPersistentService
public static boolean startPersistentService(String serviceName, Properties properties) throws StandardException(Code)
Start a persistent service. The name of the service can include a service type, in the form 'type:serviceName'.
Note that the return type only indicates if the service can be handled by the monitor. It does not indicate the service was started successfully. The cases are
  1. Service type not handled - false returned.
  2. Service type handled, service does not exist, true returned.
  3. Service type handled, service exists and booted OK, true returned.
  4. Service type handled, service exists and failed to boot, exception thrown.
If true is returned then findService should be used to see if the service exists or not.

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.
Parameters:
  serviceName - Name of the service to be started
Parameters:
  properties - Property set made available to all modules bootedfor this service, through their ModuleControl.boot method. true if the service type is handled by the monitor, false if it isn't
exception:
  StandardException - An attempt to start the service failed.




startSystemModule
public static Object startSystemModule(String factoryInterface) throws StandardException(Code)
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);
 
a reference to a module.
exception:
  StandardException - An attempt to start the module failed.
See Also:   ModuleControl.boot



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.