public class ApplicationMBeansDiscoveryComponent extends Object implements ResourceDiscoveryComponent<BaseComponent<?>>
ApplicationMBeansComponent component class.
This class is not declared in the AS7 plugin descriptor. It is a tool that that plugin developers may use while writing their own plugin to monitor their application MBeans.
The custom plugin must:
The resource type using this class (or a subclass of this class) as a discovery component must indicate which type of server it runs inside. It may be either a JBossAS7 Standalone Server or a Managed Server.
Plugins authors are required to provide a resource key and name and mayprovide a resource description and version by declaring plugin configuration properties of the following names:
ApplicationMBeansDiscoveryComponent.PluginConfigProps.NEW_RESOURCE_KEYApplicationMBeansDiscoveryComponent.PluginConfigProps.NEW_RESOURCE_NAMEApplicationMBeansDiscoveryComponent.PluginConfigProps.NEW_RESOURCE_DESCRIPTIONApplicationMBeansDiscoveryComponent.PluginConfigProps.NEW_RESOURCE_VERSIONAlternatively, they can subclass create a subclass of this discovery component and override one/some/all of the following methods:
getNewResourceKey(org.rhq.core.domain.configuration.Configuration)getNewResourceName(org.rhq.core.domain.configuration.Configuration)getNewResourceDescription(org.rhq.core.domain.configuration.Configuration) getNewResourceVersion(org.rhq.core.domain.configuration.Configuration)By default, application MBeans will be searched with an EMS query defined in the plugin descriptor by the
ApplicationMBeansDiscoveryComponent.PluginConfigProps.BEANS_QUERY_STRING plugin-config property.
It is also possible to define the query string in a subclass overriding the
getBeansQueryString(org.rhq.core.domain.configuration.Configuration) method.
Plugin developers can implement their custom MBeans lookup method in a subclass overriding the
hasApplicationMBeans(org.rhq.core.domain.configuration.Configuration, org.mc4j.ems.connection.EmsConnection)
method.
The JMX server host will be detected by looking at the top level server resource plugin configuration
(StandaloneASComponent and HostControllerComponent). The JMX port detection mechanism depends on the
parent resource.
In standalone mode, the discovery component will look at the management port defined in the parent
StandaloneASComponent plugin configuration and add the value STANDALONE_REMOTING_PORT_OFFSET.
In domain mode, the discovery component will use '4447' plus the port offset of the managed server.
JMX connectivity on AS7 and EAP6 requires authentication and standalone and managed servers behaviors differ.
In standalone mode, the server will use the ManagementRealm, just as for HTTP management interface authentication.
Consequently, this class will pick up the credentials of the management user defined in the plugin configuration of
the parent server resource (StandaloneASComponent).
In other words, plugin authors have nothing to do.
In domain mode, the server will use the ApplicationRealm. Consequently, there is no way for the discovery component to discover credentials automatically and it will use "rhqadmin:rhqadmin" by default.
When working with managed servers, plugin developers should subclass the discovery component and override the
getCredentialsForManagedAS() method. For example, an implementation could lookup the credentials in a
text file.
<plugin
name="MyappMBeansPlugin"
displayName="Myapp MBeans Plugin"
package="com.myapp.services.plugin"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
<depends plugin="JBossAS7" useClasses="true"/>
<service name="Myapp Services"
discovery="org.rhq.modules.plugins.jbossas7.jmx.ApplicationMBeansDiscoveryComponent"
class="org.rhq.modules.plugins.jbossas7.jmx.ApplicationMBeansComponent"
description="Container for Myapp Services"
singleton="true">
<runs-inside>
<!-- The type of the server the application is running on -->
<parent-resource-type name="JBossAS7 Standalone Server" plugin="JBossAS7"/>
<parent-resource-type name="Managed Server" plugin="JBossAS7"/>
</runs-inside>
<plugin-configuration>
<c:simple-property name="beansQueryString" readOnly="true" default="myapp:service=*"/>
<c:simple-property name="newResourceKey" readOnly="true" default="myappServices"/>
<c:simple-property name="newResourceName" readOnly="true" default="Myapp Services"/>
<c:simple-property name="newResourceDescription" readOnly="true" default="Container for Myapp Services"/>
</plugin-configuration>
<!--
ApplicationMBeansComponent can be the parent of any JMXComponent (JMX plugin). For example, it's possible
to monitor a MBean with no line of Java code thanks to the MBeanResourceComponent facility. Plugin authors
only have to configure metrics (mapped to MBeans attributes) and operations (MBeans operations).
-->
<service name="HelloService" discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="org.rhq.plugins.jmx.MBeanResourceComponent" singleton="true">
<plugin-configuration>
<c:simple-property name="objectName" default="myapp:service=HelloService" readOnly="true"/>
</plugin-configuration>
<operation name="helloTo">
<parameters>
<c:simple-property name="p1" displayName="somebody" type="string" required="true"/>
</parameters>
<results>
<c:simple-property name="operationResult" type="string"/>
</results>
</operation>
</service>
</service>
</plugin>
ApplicationMBeansComponent| Modifier and Type | Class and Description |
|---|---|
static class |
ApplicationMBeansDiscoveryComponent.PluginConfigProps |
| Constructor and Description |
|---|
ApplicationMBeansDiscoveryComponent() |
| Modifier and Type | Method and Description |
|---|---|
Set<DiscoveredResourceDetails> |
discoverResources(ResourceDiscoveryContext<BaseComponent<?>> context) |
protected String |
getBeansQueryString(org.rhq.core.domain.configuration.Configuration pluginConfig)
The EMS query string chosen when using the default implementation of
hasApplicationMBeans(org.rhq.core.domain.configuration.Configuration, org.mc4j.ems.connection.EmsConnection). |
protected String[] |
getCredentialsForManagedAS()
Default implementation of the credentials lookup for JMX authentication against managed servers (domain mode).
|
protected String |
getNewResourceDescription(org.rhq.core.domain.configuration.Configuration pluginConfig) |
protected String |
getNewResourceKey(org.rhq.core.domain.configuration.Configuration pluginConfig) |
protected String |
getNewResourceName(org.rhq.core.domain.configuration.Configuration pluginConfig) |
protected String |
getNewResourceVersion(org.rhq.core.domain.configuration.Configuration pluginConfig) |
protected boolean |
hasApplicationMBeans(org.rhq.core.domain.configuration.Configuration pluginConfig,
org.mc4j.ems.connection.EmsConnection emsConnection)
Indicates if a managed server or a standalone server has application MBeans.
|
static org.mc4j.ems.connection.EmsConnection |
loadEmsConnection(org.rhq.core.domain.configuration.Configuration pluginConfig)
Creates a new
EmsConnection object. |
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent<?>> context) throws Exception
discoverResources in interface ResourceDiscoveryComponent<BaseComponent<?>>Exceptionprotected boolean hasApplicationMBeans(org.rhq.core.domain.configuration.Configuration pluginConfig,
org.mc4j.ems.connection.EmsConnection emsConnection)
pluginConfig - - the plugin configuration object for the ApplicationMBeansComponent that may be
createdemsConnection - - an active emsConnection which can be used to communicate with the serverprotected String[] getCredentialsForManagedAS()
protected String getBeansQueryString(org.rhq.core.domain.configuration.Configuration pluginConfig)
hasApplicationMBeans(org.rhq.core.domain.configuration.Configuration, org.mc4j.ems.connection.EmsConnection).pluginConfig - - the plugin configuration object for the ApplicationMBeansComponent that will be
createdprotected String getNewResourceKey(org.rhq.core.domain.configuration.Configuration pluginConfig)
pluginConfig - - the plugin configuration object for the ApplicationMBeansComponent that will be
createdprotected String getNewResourceName(org.rhq.core.domain.configuration.Configuration pluginConfig)
pluginConfig - - the plugin configuration object for the ApplicationMBeansComponent that will be
createdprotected String getNewResourceDescription(org.rhq.core.domain.configuration.Configuration pluginConfig)
pluginConfig - - the plugin configuration object for the ApplicationMBeansComponent that will be
createdprotected String getNewResourceVersion(org.rhq.core.domain.configuration.Configuration pluginConfig)
pluginConfig - - the plugin configuration object for the ApplicationMBeansComponent that will be
createdpublic static org.mc4j.ems.connection.EmsConnection loadEmsConnection(org.rhq.core.domain.configuration.Configuration pluginConfig)
EmsConnection object.pluginConfig - - a plugin configuration object of the ApplicationMBeansComponentEmsConnection object or null if connecting failedCopyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.