<html><head> | |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | |
<title>2. Custom Providers and Instruments</title><link rel="stylesheet" href="css/docbook.css" type="text/css"><base href="display"><meta name="generator" content="DocBook XSL Stylesheets V1.72.0"><link rel="start" href="manual.html" title="Apache OpenJPA 2.1 User's Guide"><link rel="up" href="ref_guide_instrumentation.html" title="Chapter 16. Instrumentation"><link rel="prev" href="ref_guide_instrumentation.html" title="Chapter 16. Instrumentation"><link rel="next" href="appendices.html" title="Part 4. Appendices"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2. | |
Custom Providers and Instruments | |
</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ref_guide_instrumentation.html">Prev</a> </td><th width="60%" align="center">Chapter 16. | |
Instrumentation | |
</th><td width="20%" align="right"> <a accesskey="n" href="appendices.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ref_guide_instrumentation_custom"></a>2. | |
Custom Providers and Instruments | |
</h2></div></div></div><a class="indexterm" name="d0e36652"></a><p> | |
OpenJPA includes built-in support for a JMX Platform MBean provider, but a custom instrumentation | |
providers can be created by implementing the | |
<a xmlns:xlink="http://www.w3.org/1999/xlink" href="../javadoc/org/apache/openjpa/lib/instrumentation/InstrumentationProvider.html" target="_top"> | |
<code class="classname">InstrumentationProvider</code></a> interface or more simply by extending | |
<a xmlns:xlink="http://www.w3.org/1999/xlink" href="../javadoc/org/apache/openjpa/lib/instrumentation/AbstractInstrumentationProvider.html" target="_top"> | |
<code class="classname">AbstractInstrumentationProvider</code></a>. To use the custom instrumentation provider, | |
include the class in your classpath and specify the class name as the base value on the | |
<a href="ref_guide_conf_openjpa.html#openjpa.Instrumentation" title="5.39. openjpa.Instrumentation"><code class="literal">openjpa.Instrumentation</code></a> configuration property. | |
</p><p> | |
OpenJPA includes instruments for various caches, but you can also create your own instruments. To | |
create a custom instrument you need to implement the | |
<a xmlns:xlink="http://www.w3.org/1999/xlink" href="../javadoc/org/apache/openjpa/lib/instrumentation/Instrument.html" target="_top"> | |
<code class="classname">Instrument</code></a> interface or more simply extend | |
<a xmlns:xlink="http://www.w3.org/1999/xlink" href="../javadoc/org/apache/openjpa/lib/instrumentation/AbstractInstrument.html" target="_top"> | |
<code class="classname">AbstractInstrument</code></a>. If you are building a Platform MBean JMX-based | |
instrument this effort can be simplified by extending | |
<a xmlns:xlink="http://www.w3.org/1999/xlink" href="../javadoc/org/apache/openjpa/instrumentation/jmx/JMXInstrument.html" target="_top"> | |
<code class="classname">JMXInstrument</code></a>. If you create your own custom | |
provider, class name aliases can be registered within the provider to simplify configuration. For example, | |
the instrument <code class="classname">com.my.app.MySQLInstrument</code> could be aliased as | |
<code class="classname">MySQLInstrument</code> within custom provider | |
<code class="classname">com.my.app.InstrumentationProvider</code>. | |
</p><p> | |
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. | |
</p><p> | |
Here is an example of how a custom instrumentation provider could be enabled with an instrument class | |
aliased by the provider as <code class="classname">MySQLInstrument</code>. | |
</p><pre class="programlisting"> | |
<!-- Enable custom provider and instrument --> | |
<property name="openjpa.Instrumentation" value="com.my.app.InstrumentationProvider(Instrument='MySQLInstrument')"/> | |
</pre></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ref_guide_instrumentation.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ref_guide_instrumentation.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="appendices.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 16. | |
Instrumentation | |
</td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top"> Part 4. Appendices</td></tr></table></div></body></html> |