OpenJPA includes built-in support for a JMX Platform MBean provider, but a custom instrumentation
providers can be created by implementing the
InstrumentationProvider
interface or more simply by extending
AbstractInstrumentationProvider
. To use the custom instrumentation provider,
include the class in your classpath and specify the class name as the base value on the
openjpa.Instrumentation
configuration property.
OpenJPA includes instruments for various caches, but you can also create your own instruments. To
create a custom instrument you need to implement the
Instrument
interface or more simply extend
AbstractInstrument
. If you are building a Platform MBean JMX-based
instrument this effort can be simplified by extending
JMXInstrument
. If you create your own custom
provider, class name aliases can be registered within the provider to simplify configuration. For example,
the instrument com.my.app.MySQLInstrument
could be aliased as
MySQLInstrument
within custom provider
com.my.app.InstrumentationProvider
.
OpenJPA provides the ability to plug in custom instruments and gives instruments direct access to the configuration, but it is up to the creator of the instrument to add the internal monitoring. This often requires modifying or extending base OpenJPA classes (such as the Broker) or using a byte-code weaving tool such as AspectJ to produce aspect-based instruments.
Here is an example of how a custom instrumentation provider could be enabled with an instrument class
aliased by the provider as MySQLInstrument
.
<!-- Enable custom provider and instrument --> <property name="openjpa.Instrumentation" value="com.my.app.InstrumentationProvider(Instrument='MySQLInstrument')"/>