public class MBeanClientInterceptor extends Object implements org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
MethodInterceptor that routes calls to an
 MBean running on the supplied MBeanServerConnection.
 Works for both local and remote MBeanServerConnections.
 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
 connectOnStartup property to "false",
 you can defer this process until the first invocation against the proxy.
 
This functionality is usually used through MBeanProxyFactoryBean.
 See the javadoc of that class for more information.
MBeanProxyFactoryBean, 
setConnectOnStartup(boolean)| Modifier and Type | Field and Description | 
|---|---|
| protected Log | loggerLogger available to subclasses. | 
| Constructor and Description | 
|---|
| MBeanClientInterceptor() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | afterPropertiesSet()Prepares the  MBeanServerConnectionif the "connectOnStartup"
 is turned on (which it is by default). | 
| protected Object | convertResultValueIfNecessary(Object result,
                             org.springframework.core.MethodParameter parameter)Convert the given result object (from attribute access or operation invocation)
 to the specified target class for returning from the proxy method. | 
| void | destroy() | 
| protected Object | doInvoke(org.aopalliance.intercept.MethodInvocation invocation)Route the invocation to the configured managed resource. | 
| Map<String,?> | getEnvironment()Allow Map access to the environment to be set for the connector,
 with the option to add or override specific entries. | 
| protected Class<?> | getManagementInterface()Return the management interface of the target MBean,
 or  nullif none specified. | 
| protected Object | handleConnectFailure(org.aopalliance.intercept.MethodInvocation invocation,
                    Exception ex)Refresh the connection and retry the MBean invocation if possible. | 
| Object | invoke(org.aopalliance.intercept.MethodInvocation invocation)Route the invocation to the configured managed resource.. | 
| protected boolean | isPrepared()Return whether this client interceptor has already been prepared,
 i.e. | 
| void | prepare()Ensures that an  MBeanServerConnectionis configured and attempts
 to detect a local connection if one is not supplied. | 
| void | setAgentId(String agentId)Set the agent id of the  MBeanServerto locate. | 
| void | setBeanClassLoader(ClassLoader beanClassLoader) | 
| void | setConnectOnStartup(boolean connectOnStartup)Set whether or not the proxy should connect to the  MBeanServerat creation time ("true") or the first time it is invoked ("false"). | 
| void | setEnvironment(Map<String,?> environment)Specify the environment for the JMX connector. | 
| 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. | 
| void | setObjectName(Object objectName)Set the  ObjectNameof the MBean which calls are routed to,
 asObjectNameinstance or asString. | 
| void | setRefreshOnConnectFailure(boolean refreshOnConnectFailure)Set whether to refresh the MBeanServer connection on connect failure. | 
| void | setServer(MBeanServerConnection server)Set the  MBeanServerConnectionused to connect to the
 MBean which all invocations are routed to. | 
| void | setServiceUrl(String url)Set the service URL of the remote  MBeanServer. | 
| void | setUseStrictCasing(boolean useStrictCasing)Set whether to use strict casing for attributes. | 
protected final Log logger
public void setServer(MBeanServerConnection server)
MBeanServerConnection used to connect to the
 MBean which all invocations are routed to.public void setServiceUrl(String url) throws MalformedURLException
MBeanServer.MalformedURLExceptionpublic void setEnvironment(@Nullable
                           Map<String,?> environment)
@Nullable public Map<String,?> getEnvironment()
Useful for specifying entries directly, for example via "environment[myKey]". This is particularly useful for adding or overriding entries in child bean definitions.
public void setAgentId(String agentId)
MBeanServer to locate.
 Default is none. If specified, this will result in an
 attempt being made to locate the attendant MBeanServer, unless
 the "serviceUrl" property has been set.
public void setConnectOnStartup(boolean connectOnStartup)
MBeanServer
 at creation time ("true") or the first time it is invoked ("false").
 Default is "true".public void setRefreshOnConnectFailure(boolean refreshOnConnectFailure)
Can be turned on to allow for hot restart of the JMX server, automatically reconnecting and retrying in case of an IOException.
public void setObjectName(Object objectName) throws MalformedObjectNameException
ObjectName of the MBean which calls are routed to,
 as ObjectName instance or as String.MalformedObjectNameExceptionpublic void setUseStrictCasing(boolean useStrictCasing)
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.
public void setManagementInterface(@Nullable
                                   Class<?> managementInterface)
@Nullable protected final Class<?> getManagementInterface()
null if none specified.public void setBeanClassLoader(ClassLoader beanClassLoader)
setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAwarepublic void afterPropertiesSet()
MBeanServerConnection if the "connectOnStartup"
 is turned on (which it is by default).afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanpublic void prepare()
MBeanServerConnection is configured and attempts
 to detect a local connection if one is not supplied.protected boolean isPrepared()
@Nullable public Object invoke(org.aopalliance.intercept.MethodInvocation invocation) throws Throwable
invoke in interface org.aopalliance.intercept.MethodInterceptorinvocation - the MethodInvocation to re-routeThrowable - an invocation error propagated to the userdoInvoke(org.aopalliance.intercept.MethodInvocation), 
handleConnectFailure(org.aopalliance.intercept.MethodInvocation, java.lang.Exception)@Nullable protected Object handleConnectFailure(org.aopalliance.intercept.MethodInvocation invocation, Exception ex) throws Throwable
If not configured to refresh on connect failure, this method simply rethrows the original exception.
invocation - the invocation that failedex - the exception raised on remote invocationThrowable - an exception raised by the new invocation,
 if it failed as wellsetRefreshOnConnectFailure(boolean), 
doInvoke(org.aopalliance.intercept.MethodInvocation)@Nullable protected Object doInvoke(org.aopalliance.intercept.MethodInvocation invocation) throws Throwable
MBeanServerConnection.get/setAttribute and method invocation to
 MBeanServerConnection.invoke.invocation - the MethodInvocation to re-routeThrowable - an invocation error propagated to the user@Nullable protected Object convertResultValueIfNecessary(@Nullable Object result, org.springframework.core.MethodParameter parameter)
result - the result object as returned by the MBeanServerparameter - the method parameter of the proxy method that's been invokedpublic void destroy()
destroy in interface org.springframework.beans.factory.DisposableBean