org.aopalliance.intercept.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
| Modifier and Type | Class and Description |
|---|---|
| private static class | MBeanClientInterceptor.MethodCacheKey
Simple wrapper class around a method name and its signature. |
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private Map | |
| private Map | |
| private ClassLoader | |
| private boolean | |
| private final ConnectorDelegate | |
| private Map | |
| private MBeanServerInvocationHandler | |
| protected final Log | logger
Logger available to subclasses. |
| private Class | |
| private ObjectName | |
| private final Object | |
| private boolean | |
| private MBeanServerConnection | |
| private MBeanServerConnection | |
| private JMXServiceURL | |
| private final Map | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Implements org. MBeanServerConnection if the "connectOnStartup"
is turned on (which it is by default).
|
| private Object | |
| private Collection | |
| protected Object | Returns: the converted result object, or the passed-in object if no conversion is necessarythe result object as returned by the result, MethodParameter MBeanServerthe method parameter of the proxy method that's been invoked parameter)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()
Implements org. BeanFactory on destruction of a bean.
|
| protected Object | Returns: the value returned as a result of the re-routed invocationthe invocation)MethodInvocation to re-routeRoute the invocation to the configured managed resource. |
| public Map | getEnvironment()
Allow |
| protected final Class | getManagementInterface()
Return the management interface of the target MBean,
or |
| protected Object | Returns: the result value of the new invocation, if succeededthe invocation that failed invocation, Exception the exception raised on remote invocation ex)Refresh the connection and retry the MBean invocation if possible. |
| public Object | Returns: the value returned as a result of the re-routed invocationthe invocation)MethodInvocation to re-routeImplements org. |
| private Object | |
| private Object | Returns: the value returned by the method invocation.the method corresponding to operation on the managed resource. method, Object[] the invocation arguments args)Routes a method invocation (not a property get/set) to the corresponding operation on the managed resource. |
| protected boolean | isPrepared()
Return whether this client interceptor has already been prepared, i.e. has already looked up the server and cached all metadata. |
| public void | prepare()
Ensures that an |
| private void | retrieveMBeanInfo(MBeanServerConnection server)
Loads the management interface info for the configured MBean into the caches. |
| public void | |
| public void | setBeanClassLoader(ClassLoader
the owning class loader beanClassLoader)Implements org. class loader to
a bean instance.
|
| public void | setConnectOnStartup(boolean connectOnStartup)
Set whether the proxy should connect to the |
| public void | |
| 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 |
| public void | setRefreshOnConnectFailure(boolean refreshOnConnectFailure)
Set whether to refresh the MBeanServer connection on connect failure. |
| public void | setServer(MBeanServerConnection server)
Set the |
| public void | |
| public void |
| agentId | back to summary |
|---|---|
| private String agentId
| |
| allowedAttributes | back to summary |
|---|---|
| private Map<String, MBeanAttributeInfo> allowedAttributes | |
| allowedOperations | back to summary |
|---|---|
| private Map<MBeanClientInterceptor. | |
| beanClassLoader | back to summary |
|---|---|
| private ClassLoader beanClassLoader
| |
| connectOnStartup | back to summary |
|---|---|
| private boolean connectOnStartup | |
| connector | back to summary |
|---|---|
| private final ConnectorDelegate connector | |
| environment | back to summary |
|---|---|
| private Map<String, ?> environment
| |
| invocationHandler | back to summary |
|---|---|
| private MBeanServerInvocationHandler invocationHandler
| |
| logger | back to summary |
|---|---|
| protected final Log logger Logger available to subclasses. | |
| managementInterface | back to summary |
|---|---|
| private Class<?> managementInterface
| |
| objectName | back to summary |
|---|---|
| private ObjectName objectName
| |
| preparationMonitor | back to summary |
|---|---|
| private final Object preparationMonitor | |
| refreshOnConnectFailure | back to summary |
|---|---|
| private boolean refreshOnConnectFailure | |
| server | back to summary |
|---|---|
| private MBeanServerConnection server
| |
| serverToUse | back to summary |
|---|---|
| private MBeanServerConnection serverToUse
| |
| serviceUrl | back to summary |
|---|---|
| private JMXServiceURL serviceUrl
| |
| signatureCache | back to summary |
|---|---|
| private final Map<Method, String[]> signatureCache | |
| useStrictCasing | back to summary |
|---|---|
| private boolean useStrictCasing | |
| MBeanClientInterceptor | back to summary |
|---|---|
| public MBeanClientInterceptor() | |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() Implements org. Prepares the
| |
| convertDataArrayToTargetArray | back to summary |
|---|---|
| private Object convertDataArrayToTargetArray(Object[] array, Class<?> targetClass) throws NoSuchMethodException | |
| convertDataArrayToTargetCollection | back to summary |
|---|---|
| private Collection | |
| convertResultValueIfNecessary | back to summary |
|---|---|
| protected Object convertResultValueIfNecessary(Object result, MethodParameter parameter) Convert the given result object (from attribute access or operation invocation) to the specified target class for returning from the proxy method.
| |
| destroy | back to summary |
|---|---|
| public void destroy() Implements org. Doc from org. Invoked by the containing
| |
| doInvoke | back to summary |
|---|---|
| protected Object doInvoke(MethodInvocation invocation) throws Throwable Route the invocation to the configured managed resource. Correctly routes JavaBean property
access to
| |
| getEnvironment | back to summary |
|---|---|
| public Map Allow Useful for specifying entries directly, for example via
| |
| getManagementInterface | back to summary |
|---|---|
| protected final Class Return the management interface of the target MBean,
or
| |
| handleConnectFailure | back to summary |
|---|---|
| protected Object handleConnectFailure(MethodInvocation invocation, Exception ex) throws Throwable Refresh the connection and retry the MBean invocation if possible. If not configured to refresh on connect failure, this method simply rethrows the original exception.
| |
| invoke | back to summary |
|---|---|
| public Object invoke(MethodInvocation invocation) throws Throwable Implements org. Route the invocation to the configured managed resource.
| |
| invokeAttribute | back to summary |
|---|---|
private Object invokeAttribute(PropertyDescriptor pd, MethodInvocation invocation) throws JMException, IOException
| |
| invokeOperation | back to summary |
|---|---|
| private Object invokeOperation(Method method, Object[] args) throws JMException, IOException Routes a method invocation (not a property get/set) to the corresponding operation on the managed resource. | |
| isPrepared | back to summary |
|---|---|
| protected boolean isPrepared() Return whether this client interceptor has already been prepared, i.e. has already looked up the server and cached all metadata. | |
| prepare | back to summary |
|---|---|
| public void prepare() Ensures that an | |
| retrieveMBeanInfo | back to summary |
|---|---|
| private void retrieveMBeanInfo(MBeanServerConnection server) throws MBeanInfoRetrievalException Loads the management interface info for the configured MBean into the caches. This information is used by the proxy when determining whether an invocation matches a valid operation or attribute on the management interface of the managed resource. | |
| setAgentId | back to summary |
|---|---|
| public void setAgentId(String agentId) Set the agent id of the Default is none. If specified, this will result in an
attempt being made to locate the attendant MBeanServer, unless
the | |
| setBeanClassLoader | back to summary |
|---|---|
| public void setBeanClassLoader(ClassLoader beanClassLoader) Implements org. Doc from org. Callback that supplies the bean Invoked after the population of normal bean properties but
before an initialization callback such as
| |
| setConnectOnStartup | back to summary |
|---|---|
| public void setConnectOnStartup(boolean connectOnStartup) Set whether the proxy should connect to the | |
| setEnvironment | back to summary |
|---|---|
| public void setEnvironment(Map<String, ?> environment) Specify the environment for the JMX connector. | |
| setManagementInterface | back to summary |
|---|---|
| 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. | |
| setObjectName | back to summary |
|---|---|
| public void setObjectName(Object objectName) throws MalformedObjectNameException Set the | |
| setRefreshOnConnectFailure | back to summary |
|---|---|
| public void setRefreshOnConnectFailure(boolean refreshOnConnectFailure) Set whether to refresh the MBeanServer connection on connect failure.
Default is Can be turned on to allow for hot restart of the JMX server, automatically reconnecting and retrying in case of an IOException. | |
| setServer | back to summary |
|---|---|
| public void setServer(MBeanServerConnection server) Set the | |
| setServiceUrl | back to summary |
|---|---|
| public void setServiceUrl(String url) throws MalformedURLException Set the service URL of the remote | |
| setUseStrictCasing | back to summary |
|---|---|
| public void setUseStrictCasing(boolean useStrictCasing) Set whether to use strict casing for attributes. Enabled by default. When using strict casing, a JavaBean property with a getter such as
| |
| Access | Constructor and Description |
|---|---|
| public | MethodCacheKey(String
the name of the method name, Class<?>[] the arguments in the method signature parameterTypes)Create a new instance of |
| Modifier and Type | Method and Description |
|---|---|
| public int | compareTo(MBeanClientInterceptor.
the object to be compared. otherImplements java. |
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. |
| public int | |
| public String |
| name | back to summary |
|---|---|
| private final String name | |
| parameterTypes | back to summary |
|---|---|
| private final Class<?>[] parameterTypes | |
| MethodCacheKey | back to summary |
|---|---|
| public MethodCacheKey(String name, Class<?>[] parameterTypes) Create a new instance of | |
| compareTo | back to summary |
|---|---|
| public int compareTo(MBeanClientInterceptor. Implements java. Doc from java. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The implementor must ensure The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |