INT-2628 Add ObjectNamingStrategy to IMBE
Allow customization of the generated ObjectName for the Integration components. JIRA: https://jira.springsource.org/browse/INT-2628 INT-2628 Polishing - Address PR comments - Rename `naming-strategy` to `object-naming-strategy` for consistency with `object-name-static-properties`
This commit is contained in:
committed by
Artem Bilan
parent
01ab48d664
commit
9849e2087d
@@ -366,6 +366,46 @@
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
<para>
|
||||
Custom elements can be appended to the object name by providing a reference to a
|
||||
<classname>Properties</classname> object in the <code>object-name-static-properties</code> attribute.
|
||||
</para>
|
||||
<para>
|
||||
Also, since <emphasis>Spring Integration 3.0</emphasis>, you can use a custom
|
||||
<ulink url="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jmx/export/naming/ObjectNamingStrategy.html"
|
||||
>ObjectNamingStrategy</ulink>
|
||||
using the <code>object-naming-strategy</code> attribute. This permits greater control over the naming of the
|
||||
MBeans. For example, to group all Integration MBeans under
|
||||
an 'Integration' type. A simple custom naming strategy implementation might be:
|
||||
</para>
|
||||
<programlisting language="java"><![CDATA[public class Namer implements ObjectNamingStrategy {
|
||||
|
||||
private final ObjectNamingStrategy realNamer = new KeyNamingStrategy();
|
||||
@Override
|
||||
public ObjectName getObjectName(Object managedBean, String beanKey) throws MalformedObjectNameException {
|
||||
String actualBeanKey = beanKey.replace("type=", "type=Integration,componentType=");
|
||||
return realNamer.getObjectName(managedBean, actualBeanKey);
|
||||
}
|
||||
|
||||
}]]></programlisting>
|
||||
<para>
|
||||
The <code>beanKey</code> argument is a String containing the standard object name beginning with
|
||||
the <code>default-domain</code> and including any additional static properties.
|
||||
This example simply moves the standard <code>type</code> part to <code>componentType</code> and
|
||||
sets the <code>type</code> to 'Integration',
|
||||
enabling selection of all Integration MBeans in one query:
|
||||
<code>"my.domain:type=Integration,*</code>. This also groups the beans under one tree entry under the
|
||||
domain in tools like VisualVM.
|
||||
</para>
|
||||
<note>
|
||||
The default naming strategy is a
|
||||
<ulink url="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jmx/export/naming/MetadataNamingStrategy.html"
|
||||
>MetadataNamingStrategy</ulink>. The exporter propagates the <code>default-domain</code> to that object to allow it
|
||||
to generate a fallback object name if parsing of the bean key fails. If your custom naming strategy is a
|
||||
<classname>MetadataNamingStrategy</classname> (or subclass), the exporter will <emphasis role="bold">not</emphasis>
|
||||
propagate the <code>default-domain</code>; you will need to configure it on your strategy bean.
|
||||
</note>
|
||||
</section>
|
||||
|
||||
<section id="jmx-channel-features">
|
||||
|
||||
@@ -63,12 +63,23 @@
|
||||
<section id="3.0-jmx">
|
||||
<title>JMX Support</title>
|
||||
<para>
|
||||
A new <code><int-jmx:tree-polling-channel-adapter/></code> is provided; this
|
||||
adapter queries the JMX MBean tree and sends a message with a payload that is the
|
||||
graph of objects that matches the query. By default the MBeans are mapped to
|
||||
primitives and simple Objects like Map, List and arrays - permitting simple
|
||||
transformation, for example, to JSON
|
||||
<xref linkend="jmx"/>.
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
A new <code><int-jmx:tree-polling-channel-adapter/></code> is provided; this
|
||||
adapter queries the JMX MBean tree and sends a message with a payload that is the
|
||||
graph of objects that matches the query. By default the MBeans are mapped to
|
||||
primitives and simple Objects like Map, List and arrays - permitting simple
|
||||
transformation, for example, to JSON.
|
||||
</listitem>
|
||||
<listitem>
|
||||
The <classname>IntegrationMBeanExporter</classname> now allows the configuration of
|
||||
a custom <classname>ObjectNamingStrategy</classname> using the <code>naming-strategy</code>
|
||||
attribute.
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
For more information, see <xref linkend="jmx"/>.
|
||||
</para>
|
||||
</section>
|
||||
<section id="3.0-tail">
|
||||
|
||||
Reference in New Issue
Block a user