Top Description Fields Constructors Methods
org.apache.derby.impl.services.jmx

public final Class JMXManagementService

extends Object
implements ManagementService, ModuleControl
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.monitor.ModuleControl, org.apache.derby.iapi.services.jmx.ManagementService, org.apache.derby.mbeans.ManagementMBean
Imports
java.lang.management.ManagementFactory, java.util.HashMap, .HashSet, .Map, .Properties, javax.management.JMException, .MBeanInfo, .MBeanServer, .ObjectName, .StandardMBean, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.Property, org.apache.derby.mbeans.Version, .ManagementMBean, .VersionMBean, org.apache.derby.iapi.services.jmx.ManagementService, org.apache.derby.iapi.services.monitor.ModuleControl, .ModuleFactory, .Monitor, org.apache.derby.iapi.services.property.PropertyUtil, org.apache.derby.shared.common.security.SystemPermission

This class implements the ManagementService interface and provides a simple management and monitoring service. An mbean registered with this service remains until it is unregistered. While registered with this service it may be registered and unregistered with the jmx service a number of times.
See Also
org.apache.derby.iapi.services.jmx.ManagementService

Field Summary

Modifier and TypeField and Description
private static final SystemPermission
CONTROL

Control permission (permissions are immutable).

private MBeanServer
mbeanServer

Platform MBean server, from ManagementFactory.getPlatformMBeanServer().

private ObjectName
myManagementBean

If this object is registered as a management mbean then myManagementBean represents its name.

private MBeanServer
private Map<ObjectName, StandardMBean>
registeredMbeans

The set of mbeans registered to this service by Derby's code.

private String
systemIdentifier

Runtime value to disambiguate multiple Derby systems in the same virtual machine but different class loaders.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public synchronized void
boot(boolean
True if the database should be created
create
,
Properties
Configuration properties
properties
)

Implements org.apache.derby.iapi.services.monitor.ModuleControl.boot.

Start the management service if derby.system.jmx is true.

private void
checkJMXControl()

This method used to require SystemPermission("jmx", "control") to change the management state.

private synchronized void
findServer()

Initialize the management service by obtaining the platform MBeanServer and registering system beans.

private static ModuleFactory
getMonitor()

Must be private so that user code can't call this entry point.

public synchronized String
getSystemIdentifier()

Implements org.apache.derby.mbeans.ManagementMBean.getSystemIdentifier.

Get the system identifier that this MBean is managing.

public synchronized boolean
private void
jmxRegister(final StandardMBean standardMBean, final ObjectName beanName)

Register an mbean with the platform mbean server.

private void
jmxUnregister(final ObjectName mbeanName)

Unregister an mbean from the JMX plaform server but leave it registered to this service.

public String
quotePropertyValue(String
the value to quote
value
)

Implements org.apache.derby.iapi.services.jmx.ManagementService.quotePropertyValue.

Quote an MBean key property value, so that it is safe to pass to registerMBean even if it potentially contains special characters.

public synchronized <T> Object
registerMBean(final T
The MBean to wrap with a StandardMBean and register
bean
,
final Class<T>
The management interface for the MBean.
beanInterface
,
final String
The String representation of the MBean's key properties, they will be added into the ObjectName with Derby's domain. Key type should be first with a short name for the bean, typically the class name without the package.
keyProperties
)

Implements org.apache.derby.iapi.services.jmx.ManagementService.registerMBean.

Registers an MBean with the MBean server as a StandardMBean.

public synchronized void
startManagement()

Implements org.apache.derby.mbeans.ManagementMBean.startManagement.

Inform Derby to start its JMX management by registering MBeans relevant to its current state.

public synchronized void
public synchronized void
stopManagement()

Implements org.apache.derby.mbeans.ManagementMBean.stopManagement.

Inform Derby to stop its JMX management by unregistering its MBeans.

public void
unregisterMBean(Object
An identifier returned by registerMBean.
mbeanIdentifier
)

Implements org.apache.derby.iapi.services.jmx.ManagementService.unregisterMBean.

Unregister an mbean using an object previous returned from registerMBean.

private synchronized void
unregisterMBean(final ObjectName
Bean to unregister.
mbeanName
)

Unregisters an mbean from this service and JMX plaform server

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CONTROLback to summary
private static final SystemPermission CONTROL

Control permission (permissions are immutable).

mbeanServerback to summary
private MBeanServer mbeanServer

Platform MBean server, from ManagementFactory.getPlatformMBeanServer(). If not null then this service has registered mbeans with the plaform MBean server. If null then this service either has no mbeans registered or one mbean registered (representing itself).

myManagementBeanback to summary
private ObjectName myManagementBean

If this object is registered as a management mbean then myManagementBean represents its name. This will be non-null when derby.system.jmx is true.

myManagementServerback to summary
private MBeanServer myManagementServer
registeredMbeansback to summary
private Map<ObjectName, StandardMBean> registeredMbeans

The set of mbeans registered to this service by Derby's code. These beans are registered with the platform mbean server if mbeanServer is not null.

systemIdentifierback to summary
private String systemIdentifier

Runtime value to disambiguate multiple Derby systems in the same virtual machine but different class loaders. Set as the system attribute in the ObjectName for all MBeans registered.

Constructor Detail

JMXManagementServiceback to summary
public JMXManagementService()

Method Detail

bootback to summary
public synchronized void boot(boolean create, Properties properties) throws StandardException

Implements org.apache.derby.iapi.services.monitor.ModuleControl.boot.

Start the management service if derby.system.jmx is true.

Starting the service means:

  • getting the platform MBeanServer which may require starting it
  • registering a Version mbean representing the system
Parameters
create:boolean

Doc from org.apache.derby.iapi.services.monitor.ModuleControl.boot.

True if the database should be created

properties:Properties

Doc from org.apache.derby.iapi.services.monitor.ModuleControl.boot.

Configuration properties

Exceptions
StandardException:

Doc from org.apache.derby.iapi.services.monitor.ModuleControl.boot.

Module cannot be started.

checkJMXControlback to summary
private void checkJMXControl()

This method used to require SystemPermission("jmx", "control") to change the management state.

findServerback to summary
private synchronized void findServer()

Initialize the management service by obtaining the platform MBeanServer and registering system beans. Separate from boot() to allow future changes where the jmx management can be enabled on the fly.

getMonitorback to summary
private static ModuleFactory getMonitor()

Must be private so that user code can't call this entry point.

getSystemIdentifierback to summary
public synchronized String getSystemIdentifier()

Implements org.apache.derby.mbeans.ManagementMBean.getSystemIdentifier.

Doc from org.apache.derby.mbeans.ManagementMBean.getSystemIdentifier.

Get the system identifier that this MBean is managing. The system identifier is a runtime value to disambiguate multiple Derby systems in the same virtual machine but different class loaders.

Returns:String

Runtime identifier for the system, null if Derby is not running.

isManagementActiveback to summary
public synchronized boolean isManagementActive()

Implements org.apache.derby.mbeans.ManagementMBean.isManagementActive.

Doc from org.apache.derby.mbeans.ManagementMBean.isManagementActive.

Is Derby's JMX management active. If active then Derby has registered MBeans relevant to its current state.

Returns:boolean

true Derby has registered beans, false Derby has not registered any beans.

jmxRegisterback to summary
private void jmxRegister(final StandardMBean standardMBean, final ObjectName beanName) throws JMException

Register an mbean with the platform mbean server.

jmxUnregisterback to summary
private void jmxUnregister(final ObjectName mbeanName)

Unregister an mbean from the JMX plaform server but leave it registered to this service. This is so that if jmx is reenabled we can reestablish all vaid mbeans (that are still registered with this service).

quotePropertyValueback to summary
public String quotePropertyValue(String value)

Implements org.apache.derby.iapi.services.jmx.ManagementService.quotePropertyValue.

Doc from org.apache.derby.iapi.services.jmx.ManagementService.quotePropertyValue.

Quote an MBean key property value, so that it is safe to pass to registerMBean even if it potentially contains special characters.

Parameters
value:String

the value to quote

Returns:String

the quoted value

Annotations
@Override
registerMBeanback to summary
public synchronized <T> Object registerMBean(final T bean, final Class<T> beanInterface, final String keyProperties) throws StandardException

Implements org.apache.derby.iapi.services.jmx.ManagementService.registerMBean.

Registers an MBean with the MBean server as a StandardMBean. Use of the StandardMBean allows the implementation details of Derby's mbeans to be hidden from JMX, thus only exposing the MBean's interface in org.apache.derby.mbeans.

Parameters
<T>

Doc from org.apache.derby.iapi.services.jmx.ManagementService.registerMBean. The kind of bean

bean:T

The MBean to wrap with a StandardMBean and register

beanInterface:Class<T>

The management interface for the MBean.

keyProperties:String

The String representation of the MBean's key properties, they will be added into the ObjectName with Derby's domain. Key type should be first with a short name for the bean, typically the class name without the package.

Returns:Object

Doc from org.apache.derby.iapi.services.jmx.ManagementService.registerMBean.

An identifier that can later be used to unregister the mbean.

Exceptions
StandardException:

Doc from org.apache.derby.iapi.services.jmx.ManagementService.registerMBean.

on error

startManagementback to summary
public synchronized void startManagement()

Implements org.apache.derby.mbeans.ManagementMBean.startManagement.

Doc from org.apache.derby.mbeans.ManagementMBean.startManagement.

Inform Derby to start its JMX management by registering MBeans relevant to its current state. If Derby is not booted then no action is taken.

Require SystemPermission("jmx", "control") if a security manager is installed.

stopback to summary
public synchronized void stop()

Implements org.apache.derby.iapi.services.monitor.ModuleControl.stop.

Doc from org.apache.derby.iapi.services.monitor.ModuleControl.stop.

Stop the module. The module may be found via a findModule() method until some time after this method returns. Therefore the factory must be prepared to reject requests to it once it has been stopped. In addition other modules may cache a reference to the module and make requests of it after it has been stopped, these requests should be rejected as well.

stopManagementback to summary
public synchronized void stopManagement()

Implements org.apache.derby.mbeans.ManagementMBean.stopManagement.

Doc from org.apache.derby.mbeans.ManagementMBean.stopManagement.

Inform Derby to stop its JMX management by unregistering its MBeans. If Derby is not booted then no action is taken.

Require SystemPermission("jmx", "control") if a security manager is installed.

unregisterMBeanback to summary
public void unregisterMBean(Object mbeanIdentifier)

Implements org.apache.derby.iapi.services.jmx.ManagementService.unregisterMBean.

Unregister an mbean using an object previous returned from registerMBean.

Parameters
mbeanIdentifier:Object

Doc from org.apache.derby.iapi.services.jmx.ManagementService.unregisterMBean.

An identifier returned by registerMBean.

unregisterMBeanback to summary
private synchronized void unregisterMBean(final ObjectName mbeanName)

Unregisters an mbean from this service and JMX plaform server

Parameters
mbeanName:ObjectName

Bean to unregister.