| java.lang.Object org.springframework.jmx.access.MBeanClientInterceptor
All known Subclasses: org.springframework.jmx.access.MBeanProxyFactoryBean,
MBeanClientInterceptor | public class MBeanClientInterceptor implements MethodInterceptor,BeanClassLoaderAware,InitializingBean,DisposableBean(Code) | | org.aopalliance.intercept.MethodInterceptor that routes calls to an
MBean running on the supplied MBeanServerConnection .
Works for both local and remote MBeanServerConnection s.
By default, the MBeanClientInterceptor will connect to the
MBeanServer and cache MBean metadata at startup. This can
be undesirable when running against a remote MBeanServer
that may not be running when the application starts. Through setting the
MBeanClientInterceptor.setConnectOnStartup(boolean) connectOnStartup property to "false",
you can defer this process until the first invocation against the proxy.
Requires JMX 1.2's MBeanServerConnection feature.
As a consequence, this class will not work on JMX 1.0.
This functionality is usually used through
MBeanProxyFactoryBean .
See the javadoc of that class for more information.
author: Rob Harrop author: Juergen Hoeller since: 1.2 See Also: MBeanProxyFactoryBean See Also: MBeanClientInterceptor.setConnectOnStartup |
Field Summary | |
final protected Log | logger |
Method Summary | |
public void | afterPropertiesSet() Prepares the MBeanServerConnection if the "connectOnStartup"
is turned on (which it is by default). | protected Object | convertResultValueIfNecessary(Object result, Class targetClass) Convert the given result object (from attribute access or operation invocation)
to the specified target class for returning from the proxy method. | public void | destroy() Closes any JMXConnector that may be managed by this interceptor. | final protected Class | getManagementInterface() Return the management interface of the target MBean,
or null if none specified. | public Object | invoke(MethodInvocation invocation) Route the invocation to the configured managed resource. | protected boolean | isPrepared() Return whether this client interceptor has already been prepared,
i.e. | protected MBeanServer | locateMBeanServer(String agentId) Attempt to locate an existing MBeanServer .
Called if no
MBeanClientInterceptor.setServiceUrl "serviceUrl" was specified.
The default implementation attempts to find an MBeanServer using
a standard lookup. | public void | prepare() Ensures that an MBeanServerConnection is configured and attempts
to detect a local connection if one is not supplied. | public void | setAgentId(String agentId) Set the agent id of the MBeanServer to locate.
Default is none. | public void | setBeanClassLoader(ClassLoader beanClassLoader) | public void | setConnectOnStartup(boolean connectOnStartup) Set whether or not the proxy should connect to the MBeanServer
at creation time ("true") or the first time it is invoked ("false"). | public void | setManagementInterface(Class managementInterface) Set the management interface of the target MBean, exposing bean property
setters and getters for MBean attributes and conventional Java methods
for MBean operations. | public void | setObjectName(Object objectName) Set the ObjectName of the MBean which calls are routed to,
as ObjectName instance or as String . | public void | setServer(MBeanServerConnection server) Set the MBeanServerConnection used to connect to the
MBean which all invocations are routed to. | public void | setServiceUrl(String url) Set the service URL of the remote MBeanServer . | public void | setUseStrictCasing(boolean useStrictCasing) Set whether to use strict casing for attributes. |
logger | final protected Log logger(Code) | | Logger available to subclasses
|
afterPropertiesSet | public void afterPropertiesSet()(Code) | | Prepares the MBeanServerConnection if the "connectOnStartup"
is turned on (which it is by default).
|
convertResultValueIfNecessary | protected Object convertResultValueIfNecessary(Object result, Class targetClass)(Code) | | Convert the given result object (from attribute access or operation invocation)
to the specified target class for returning from the proxy method.
Parameters: result - the result object as returned by the MBeanServer Parameters: targetClass - the result type of the proxy method that's been invoked the converted result object, or the passed-in object if no conversionis necessary |
destroy | public void destroy() throws Exception(Code) | | Closes any JMXConnector that may be managed by this interceptor.
|
getManagementInterface | final protected Class getManagementInterface()(Code) | | Return the management interface of the target MBean,
or null if none specified.
|
invoke | public Object invoke(MethodInvocation invocation) throws Throwable(Code) | | Route the invocation to the configured managed resource. Correctly routes JavaBean property
access to MBeanServerConnection.get/setAttribute and method invocation to
MBeanServerConnection.invoke . Any attempt to invoke a method that does not
correspond to an attribute or operation defined in the management interface of the managed
resource results in an InvalidInvocationException .
Parameters: invocation - the MethodInvocation to re-route. the value returned as a result of the re-routed invocation. throws: InvocationFailureException - if the invocation does not match an attribute oroperation on the management interface of the resource. throws: Throwable - typically as the result of an error during invocation |
isPrepared | protected boolean isPrepared()(Code) | | Return whether this client interceptor has already been prepared,
i.e. has already looked up the server and cached all metadata.
|
prepare | public void prepare()(Code) | | Ensures that an MBeanServerConnection is configured and attempts
to detect a local connection if one is not supplied.
|
setConnectOnStartup | public void setConnectOnStartup(boolean connectOnStartup)(Code) | | Set whether or not the proxy should connect to the MBeanServer
at creation time ("true") or the first time it is invoked ("false").
Default is "true".
|
setManagementInterface | public void setManagementInterface(Class managementInterface)(Code) | | Set the management interface of the target MBean, exposing bean property
setters and getters for MBean attributes and conventional Java methods
for MBean operations.
|
setServer | public void setServer(MBeanServerConnection server)(Code) | | Set the MBeanServerConnection used to connect to the
MBean which all invocations are routed to.
|
setUseStrictCasing | public void setUseStrictCasing(boolean useStrictCasing)(Code) | | Set whether to use strict casing for attributes. Enabled by default.
When using strict casing, a JavaBean property with a getter such as
getFoo() translates to an attribute called Foo .
With strict casing disabled, getFoo() would translate to just
foo .
|
|
|