Class BaseMonitor
java.lang.Object
org.apache.derby.impl.services.monitor.BaseMonitor
- All Implemented Interfaces:
BundleFinder, ModuleFactory
- Direct Known Subclasses:
FileMonitor
Implementation of the monitor that uses the class loader
that the its was loaded in for all class loading.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) Properties(package private) Propertiesprivate ContextService(package private) ThreadGroupprivate boolean(package private) booleanprivate static final Stringprivate PrintWriterprivate InstanceGetter[](package private) booleanprivate static final StringLook for any services in the a properties set and the application property set and then start them.private final HashMap<String, PersistentService> Hash table of objects that implement PersistentService keyed by their getType() method.private final Vector<TopService> private InfoStreamsprivate TimerFactoryprivate AccessibleByteArrayOutputStreamprivate PrintWriterprivate UUIDFactory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddDebugFlags(String flags, boolean set) (package private) abstract InputStreamGet InputStream for application properties file Returns nul if it does not exist.(package private) static voidboot(Object module, boolean create, Properties properties) Boot a module.private voidBoot all persistent services that can be located at run time.protected voidbootProviderServices(PersistentService provider) Boot all persistent services that can be located by a single service provider
This method enumerates through all the service providers that are active and calls bootPersistentServices(PersistentService) to boot all the services that that provider knows about.protected ObjectbootService(PersistentService provider, String factoryInterface, String serviceName, Properties properties, boolean create) Boot (start or create) a service (persistent or non-persistent).(package private) static booleancanSupport(Object instance, Properties properties) If the module implements ModuleSupportable then call its canSupport() method to see if it can or should run in this setup.classFromIdentifier(int fmtId) Obtain a class that supports the given identifier.createPersistentService(String factoryInterface, String name, Properties properties) Create a persistent service.private voidDetermine which of the set of service providers (PersistentService objects) are supported in the current environment.(package private) voiddumpProperties(String title, Properties props) private voiddumpTempWriter(boolean bothPlaces) private static intfindImplementation(List<Class<?>> implementations, int startIndex, Class<?> factoryInterface) Find a class that implements the required index, return the index into the implementations vector of that class.findModule(Object serviceModule, String factoryInterface, String identifier) Find the module in the system with the given module protocol, protocolVersion and identifier.private booleanfindProviderAndStartService(String name, Properties properties, boolean bootTime) Find a provider and start a service.protected PersistentServicefindProviderForCreate(String name) private PersistentServicefindProviderFromName(String name, int colon) Find the service provider from a name that includes a service type, ie. is of the form 'type:name'.findService(String factoryInterface, String serviceName) Find a service.private TopServicefindTopService(Object serviceModule) Return the application set of properties which correspond to the set of properties in the file derby.properties.Get the locale from the ContextManager and then find the bundle based upon that locale.getCanonicalServiceName(String userSpecifiedName) Canonicalize a service name, mapping different user-specifications of a database name onto a single, standard name.private static ContextServicePrivileged lookup of the ContextService.getDaemonThread(Runnable task, String name, boolean setMinPriority) Get a newly created background thread.(package private) PropertiesGet the complete set of module properties by loading in contents of all the org/apache/derby/modules.properties files.getImplementations(Properties moduleList, boolean actualModuleList) Create an implementation set.Return the locale of the service that the passed in module lives in.getLocaleFromString(String localeDescription) Translate a string of the form ll[_CC[_variant]] to a Locale.private PersistentServicegetPersistentService(String subSubProtocol) Return a PersistentService implementation to handle the subSubProtocol.private PersistentServicegetPersistentService(String className, String subSubProtocol) private booleangetPersistentServiceImplementation(Class<?> possibleModule) String[]getServiceList(String protocol) Return an array of the service identifiers that are running and implement the passed in protocol (java interface class name).getServiceName(Object serviceModule) Return the name of the service that the passed in module lives in.getServiceProvider(String subSubProtocol) Return the PersistentService for a subsubprotocol.getServiceType(Object serviceModule) Return the PersistentService object for a service.private StringgetStorageFactoryClassName(String subSubProtocol) Find the StorageFactory class name that handles the subSub protocol.Get the defined default system streams object.private PrintWriterReturns the Timer factory for this system.Return the UUID factory for this system.(package private) abstract booleaninitialize(boolean lite) Initialize the monitor wrt the current environemnt.final booleanisDaemonThread(Thread thread) Check if a thread is a daemon thread created byModuleFactory.getDaemonThread(Runnable, String, boolean).protected ObjectloadInstance(Class<?> factoryInterface, Properties properties) load a module instance.private ObjectloadInstance(List<Class<?>> implementations, Class<?> factoryInterface, Properties properties) private ObjectnewInstance(Class<?> classObject) Return a new instance of classclassObjectusing a no-param constructor.newInstanceFromIdentifier(int identifier) Obtain an new instance of a class that supports the given identifier.protected PropertiesvoidRemoves a PersistentService.protected static PropertiesremoveRuntimeProperties(Properties properties) Return a property set that has the runtime properties removed.protected voidShould only be called if reportOn is true apart from report/Exception().protected voidprotected final voidrunWithState(Properties properties, PrintWriter log) Set the locale for the service *outside* of boot time.private static LocalesetLocale(Properties properties) setLocale(Properties serviceProperties, String userDefinedLocale) Set the locale for the service at boot time.private static booleansetMonitor(BaseMonitor baseMonitor) Privileged startup.voidshutdown()Shut down the complete system that was started by this Monitor.voidShut down a service that was started by this Monitor.startModule(boolean create, Object serviceModule, String factoryInterface, String identifier, Properties properties) Start a module.startNonPersistentService(String factoryInterface, String serviceName, Properties properties) Start a non-persistent service.final booleanstartPersistentService(String name, Properties properties) Start a peristent service.protected voidstartProviderService(PersistentService provider, String serviceName, Properties serviceProperties) Boot a service under the control of the providervoidstartServices(Properties properties, boolean bootAll) Start all services identified by derby.service.* in the property set.private static LocalestaticGetLocaleFromString(String localeDescription) private static voidPrivileged shutdown of the ContextService.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ModuleFactory
getEngineVersion, getEnvironment, getJVMProperty
-
Field Details
-
serviceProviders
Hash table of objects that implement PersistentService keyed by their getType() method. -
LINE
- See Also:
-
implementationSets
-
services
-
bootProperties
Properties bootProperties -
applicationProperties
Properties applicationProperties -
inShutdown
boolean inShutdown -
systemStreams
-
contextService
-
uuidFactory
-
timerFactory
-
reportOn
boolean reportOn -
logging
-
daemonGroup
ThreadGroup daemonGroup -
rc2
-
SERVICE
Look for any services in the a properties set and the application property set and then start them. A service is defined by derby.service.name=protocol- See Also:
-
storageFactories
-
tmpWriter
-
tmpArray
-
dumpedTempWriter
private boolean dumpedTempWriter
-
-
Constructor Details
-
BaseMonitor
BaseMonitor()
-
-
Method Details
-
getSystemStreams
Description copied from interface:ModuleFactoryGet the defined default system streams object.- Specified by:
getSystemStreamsin interfaceModuleFactory
-
shutdown
public void shutdown()Description copied from interface:ModuleFactoryShut down the complete system that was started by this Monitor. Will cause the stop() method to be called on each loaded module.- Specified by:
shutdownin interfaceModuleFactory
-
shutdown
Shut down a service that was started by this Monitor. Will cause the stop() method to be called on each loaded module.- Specified by:
shutdownin interfaceModuleFactory
-
runWithState
-
getCanonicalServiceName
Description copied from interface:ModuleFactoryCanonicalize a service name, mapping different user-specifications of a database name onto a single, standard name.- Specified by:
getCanonicalServiceNamein interfaceModuleFactory- Throws:
StandardException
-
findService
Description copied from interface:ModuleFactoryFind a service.
Do not call directly - use Monitor.findService()- Specified by:
findServicein interfaceModuleFactory- Returns:
- a refrence to a module represeting the service or null if the service does not exist.
- See Also:
-
getLocale
Description copied from interface:ModuleFactoryReturn the locale of the service that the passed in module lives in. Will return null if no-locale has been defined.- Specified by:
getLocalein interfaceModuleFactory
-
getLocaleFromString
Description copied from interface:ModuleFactoryTranslate 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.- Specified by:
getLocaleFromStringin interfaceModuleFactory- Throws:
StandardException
-
getServiceName
Return the name of the service that the passed in module lives in.- Specified by:
getServiceNamein interfaceModuleFactory
-
setLocale
Set the locale for the service *outside* of boot time.- Specified by:
setLocalein interfaceModuleFactory- 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- Standard Derby error.
-
setLocale
public Locale setLocale(Properties serviceProperties, 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.- Specified by:
setLocalein interfaceModuleFactory- Throws:
StandardException- Standard Derby error.
-
getServiceType
Return the PersistentService object for a service. Will return null if the service does not exist.- Specified by:
getServiceTypein interfaceModuleFactory
-
startModule
public Object startModule(boolean create, Object serviceModule, String factoryInterface, String identifier, Properties properties) throws StandardException Start a module.- Specified by:
startModulein interfaceModuleFactory- Throws:
StandardException- se An attempt to start the module failed.- See Also:
-
findTopService
-
findModule
Description copied from interface:ModuleFactoryFind the module in the system with the given module protocol, protocolVersion and identifier.- Specified by:
findModulein interfaceModuleFactory- Returns:
- The module instance if found, or null.
-
classFromIdentifier
Obtain a class that supports the given identifier.- Specified by:
classFromIdentifierin interfaceModuleFactory- Parameters:
fmtId- identifer to associate with class- Returns:
- a reference InstanceGetter
- Throws:
StandardException- See Monitor.classFromIdentifier- See Also:
-
newInstanceFromIdentifier
Obtain an new instance of a class that supports the given identifier.- Specified by:
newInstanceFromIdentifierin interfaceModuleFactory- Parameters:
identifier- identifer to associate with class- Returns:
- a reference to a newly created object or null if a matching class cannot be found.
- Throws:
StandardException- See Monitor.newInstanceFromIdentifier
-
loadInstance
load a module instance. Look through the implementations for a module that implements the required factory interface and can handle the properties given. The module's start or create method is not called. -
loadInstance
private Object loadInstance(List<Class<?>> implementations, Class<?> factoryInterface, Properties properties) -
findImplementation
-
newInstance
-
getApplicationProperties
Description copied from interface:ModuleFactoryReturn the application set of properties which correspond to the set of properties in the file derby.properties.- Specified by:
getApplicationPropertiesin interfaceModuleFactory
-
getServiceList
Return an array of the service identifiers that are running and implement the passed in protocol (java interface class name).- Specified by:
getServiceListin interfaceModuleFactory- Returns:
- The list of service names, if no services exist that implement the protocol an array with zero elements is returned.
- See Also:
-
dumpProperties
-
report
Should only be called if reportOn is true apart from report/Exception(). -
reportException
-
addDebugFlags
-
startServices
Description copied from interface:ModuleFactoryStart all services identified by derby.service.* in the property set. If bootAll is true the services that are persistent will be booted.- Specified by:
startServicesin interfaceModuleFactory
-
startPersistentService
public final boolean startPersistentService(String name, Properties properties) throws StandardException Start a peristent service.- Specified by:
startPersistentServicein interfaceModuleFactory- Parameters:
name- Name of the service to be startedproperties- Property set made available to all modules booted for this service, through their ModuleControl.boot method.- 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:
-
createPersistentService
public Object createPersistentService(String factoryInterface, String name, Properties properties) throws StandardException Create a persistent service.- Specified by:
createPersistentServicein interfaceModuleFactory- Returns:
- The module from the service if it was created successfully, null if a service already existed.
- Throws:
StandardException- An exception was thrown trying to create the service.- See Also:
-
removePersistentService
Removes a PersistentService. Could be used for drop database.- Specified by:
removePersistentServicein interfaceModuleFactory- Parameters:
name- : Service name to be removed.- Throws:
StandardException
-
startNonPersistentService
public Object startNonPersistentService(String factoryInterface, String serviceName, Properties properties) throws StandardException Start a non-persistent service.- Specified by:
startNonPersistentServicein interfaceModuleFactory- Throws:
StandardException- An attempt to start the service failed.- See Also:
-
getImplementations
Create an implementation set. Look through the properties object for all properties that start with derby.module and add the value into the vector. If no implementations are listed in the properties object then null is returned. -
getPersistentServiceImplementation
-
getDefaultImplementations
-
getDefaultModuleProperties
Properties getDefaultModuleProperties()Get the complete set of module properties by loading in contents of all the org/apache/derby/modules.properties files. This must be executed in a privileged block otherwise when running in a security manager environment no properties will be returned. -
removeRuntimeProperties
Return a property set that has the runtime properties removed. -
applicationPropertiesStream
Get InputStream for application properties file Returns nul if it does not exist.- Throws:
IOException
-
readApplicationProperties
-
determineSupportedServiceProviders
private void determineSupportedServiceProviders()Determine which of the set of service providers (PersistentService objects) are supported in the current environment. If a PersistentService implementation does not implement ModuleControl then it is assumed it does support the current environment. Otherwise the canSupport() method makes the determination. Any providers that are not supported are removed from the list. -
bootPersistentServices
private void bootPersistentServices()Boot all persistent services that can be located at run time.
This method enumerates through all the service providers that are active and calls bootPersistentServices(PersistentService) to boot all the services that that provider knows about. -
bootProviderServices
Boot all persistent services that can be located by a single service provider
This method enumerates through all the service providers that are active and calls bootPersistentServices(PersistentService) to boot all the services that that provider knows about. -
findProviderAndStartService
private boolean findProviderAndStartService(String name, Properties properties, boolean bootTime) throws StandardException Find a provider and start a service.- Throws:
StandardException
-
findProviderForCreate
- Throws:
StandardException
-
findProviderFromName
Find the service provider from a name that includes a service type, ie. is of the form 'type:name'. If type is less than 3 characters then it is assumed to be of type directory, i.e. a windows driver letter.- Throws:
StandardException
-
getServiceProvider
Description copied from interface:ModuleFactoryReturn the PersistentService for a subsubprotocol.- Specified by:
getServiceProviderin interfaceModuleFactory- Returns:
- the PersistentService or null if it does not exist
- Throws:
StandardException
-
getPersistentService
Return a PersistentService implementation to handle the subSubProtocol.- Returns:
- Valid PersistentService or null if the protocol is not handled.
- Throws:
StandardException
-
getPersistentService
private PersistentService getPersistentService(String className, String subSubProtocol) throws StandardException - Throws:
StandardException
-
getStorageFactoryClassName
-
startProviderService
protected void startProviderService(PersistentService provider, String serviceName, Properties serviceProperties) throws StandardException Boot a service under the control of the provider- Throws:
StandardException
-
bootService
protected Object bootService(PersistentService provider, String factoryInterface, String serviceName, Properties properties, boolean create) throws StandardException Boot (start or create) a service (persistent or non-persistent).- Throws:
StandardException
-
getUUIDFactory
Return the UUID factory for this system. Returns null if there isn't one. See com.ibm.db2j.system.System- Specified by:
getUUIDFactoryin interfaceModuleFactory
-
getTimerFactory
Returns the Timer factory for this system.- Specified by:
getTimerFactoryin interfaceModuleFactory- Returns:
- the system's Timer factory.
-
getTempWriter
-
dumpTempWriter
private void dumpTempWriter(boolean bothPlaces) -
canSupport
If the module implements ModuleSupportable then call its canSupport() method to see if it can or should run in this setup. If it doesn't then it can always run. -
boot
Boot a module. If the module implements ModuleControl then its boot() method is called. Otherwise all the boot code is assumed to take place in its constructor.- Throws:
StandardException
-
staticGetLocaleFromString
- Throws:
StandardException
-
setLocale
- Throws:
StandardException
-
getBundle
Get the locale from the ContextManager and then find the bundle based upon that locale.- Specified by:
getBundlein interfaceBundleFinder- Parameters:
messageId- Message being searched for.
-
getDaemonThread
Description copied from interface:ModuleFactoryGet a newly created background thread. The thread is set to be a daemon but is not started.- Specified by:
getDaemonThreadin interfaceModuleFactory
-
isDaemonThread
Description copied from interface:ModuleFactoryCheck if a thread is a daemon thread created byModuleFactory.getDaemonThread(Runnable, String, boolean).- Specified by:
isDaemonThreadin interfaceModuleFactory- Parameters:
thread- the thread to check- Returns:
trueifthreadwas created bygetDaemonThread(),falseotherwise.
-
getContextService
Privileged lookup of the ContextService. Must be private so that user code can't call this entry point. -
stopContextService
private static void stopContextService()Privileged shutdown of the ContextService. Must be private so that user code can't call this entry point. -
setMonitor
Privileged startup. Must be private so that user code can't call this entry point. Returns true if the system is already booted or in the process of shutting down. -
initialize
abstract boolean initialize(boolean lite) Initialize the monitor wrt the current environemnt. Returns false if the monitor cannot be initialized, true otherwise.
-