org.springframework.jmx.access
Class MBeanClientInterceptor

java.lang.Object
  extended by org.springframework.jmx.access.MBeanClientInterceptor
All Implemented Interfaces:
Advice, Interceptor, MethodInterceptor, InitializingBean
Direct Known Subclasses:
MBeanProxyFactoryBean

public class MBeanClientInterceptor
extends Object
implements MethodInterceptor, InitializingBean

MethodInterceptor implementation that routes calls to an MBean running on the supplied MBeanServerConnection. Works for both local and remote MBeanServerConnections.

This functionality is usually used through MBeanProxyFactoryBean. See the javadoc of that class for more information.

Since:
1.2
Author:
Rob Harrop, Juergen Hoeller
See Also:
MBeanProxyFactoryBean

Constructor Summary
MBeanClientInterceptor()
           
 
Method Summary
 void afterPropertiesSet()
          Ensures that an MBeanServerConnection is configured and attempts to detect a local connection if one is not supplied.
 Object invoke(MethodInvocation invocation)
          Route the invocation to the configured managed resource.
 void setObjectName(String objectName)
          Set the ObjectName of the MBean which calls are routed to.
 void setServer(MBeanServerConnection server)
          Set the MBeanServerConnection used 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)
          Enables and disables strict casing for attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MBeanClientInterceptor

public MBeanClientInterceptor()
Method Detail

setUseStrictCasing

public void setUseStrictCasing(boolean useStrictCasing)
Enables and disables strict casing for attributes. When using strict casing a JavaBean property with a getter such as getFoo() translates to an attribute called Foo. With strict casing disable getFoo() would translate to just foo.


setServer

public void setServer(MBeanServerConnection server)
Set the MBeanServerConnection used to connect to the MBean which all invocations are routed to.


setServiceUrl

public void setServiceUrl(String url)
                   throws IOException
Set the service URL of the remote MBeanServer.

Throws:
IOException

setObjectName

public void setObjectName(String objectName)
                   throws MalformedObjectNameException
Set the ObjectName of the MBean which calls are routed to.

Throws:
MalformedObjectNameException

afterPropertiesSet

public void afterPropertiesSet()
                        throws JMException
Ensures that an MBeanServerConnection is configured and attempts to detect a local connection if one is not supplied.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
JMException

invoke

public Object invoke(MethodInvocation invocation)
              throws InvalidInvocationException,
                     Throwable
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.

Specified by:
invoke in interface MethodInterceptor
Parameters:
invocation - the MethodInvocation to re-route.
Returns:
the value returned as a result of the re-routed invocation.
Throws:
InvalidInvocationException - if the invocation does not match an attribute or operation on the management interface of the resource.
Throwable - typically as the result of an error during invocation


Copyright (c) 2002-2005 The Spring Framework Project.