Top Description Fields Constructors Methods
org.springframework.jmx.export.assembler

public Class InterfaceBasedMBeanInfoAssembler

extends AbstractConfigurableMBeanInfoAssembler
implements BeanClassLoaderAware, InitializingBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.Aware
Imports
java.lang.reflect.Method, .Modifier, java.util.Arrays, .Enumeration, .Map, .Properties, org.springframework.beans.factory.BeanClassLoaderAware, .InitializingBean, org.springframework.lang.Nullable, org.springframework.util.ClassUtils, .CollectionUtils, .StringUtils

Subclass of AbstractReflectiveMBeanInfoAssembler that allows for the management interface of a bean to be defined using arbitrary interfaces. Any methods or properties that are defined in those interfaces are exposed as MBean operations and attributes.

By default, this class votes on the inclusion of each operation or attribute based on the interfaces implemented by the bean class. However, you can supply an array of interfaces via the managedInterfaces property that will be used instead. If you have multiple beans and you wish each bean to use a different set of interfaces, then you can map bean keys (that is the name used to pass the bean to the MBeanExporter) to a list of interface names using the interfaceMappings property.

If you specify values for both interfaceMappings and managedInterfaces, Spring will attempt to find interfaces in the mappings first. If no interfaces for the bean are found, it will use the interfaces defined by managedInterfaces.

Authors
Rob Harrop, Juergen Hoeller
Since
1.2
See Also
setManagedInterfaces, setInterfaceMappings, MethodNameBasedMBeanInfoAssembler, SimpleReflectiveMBeanInfoAssembler, org.springframework.jmx.export.MBeanExporter

Field Summary

Modifier and TypeField and Description
private ClassLoader
private Properties
interfaceMappings

Mappings of bean keys to an array of classes.

private Class<?>[]
private Map<String, Class<?>[]>
resolvedInterfaceMappings

Mappings of bean keys to an array of classes.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

protected boolean

Returns:

true if the Method is declared in one of the configured interfaces, otherwise false.
includeOperation
(Method
the operation Method.
method
,
String
the key associated with the MBean in the beans Map.
beanKey
)

Implements abstract org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.includeOperation.

Check to see if the Method is declared in one of the configured interfaces and that it is public.
protected boolean

Returns:

true if the Method is declared in one of the configured interfaces, otherwise false.
includeReadAttribute
(Method
the accessor Method.
method
,
String
the key associated with the MBean in the beans Map.
beanKey
)

Implements abstract org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.includeReadAttribute.

Check to see if the Method is declared in one of the configured interfaces and that it is public.
protected boolean

Returns:

true if the Method is declared in one of the configured interfaces, otherwise false.
includeWriteAttribute
(Method
the mutator Method.
method
,
String
the key associated with the MBean in the beans Map.
beanKey
)

Implements abstract org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.includeWriteAttribute.

Check to see if the Method is declared in one of the configured interfaces and that it is public.
private boolean
isDeclaredInInterface(Method method, String beanKey)

Checks to see if the given method is declared in a managed interface for the given bean.

private boolean

Returns:

true if the Method is declared in one of the configured interfaces and is public, otherwise false.
isPublicInInterface
(Method
the Method to check.
method
,
String
the key associated with the MBean in the beans map
beanKey
)

Check to see if the Method is both public and declared in one of the configured interfaces.

private Class<?>[]

Returns:

the resolved Class
resolveClassNames
(String[]
the class names to resolve
classNames
,
String
the bean key that the class names are associated with
beanKey
)

Resolve the given class names into Class objects.

private Map<String, Class<?>[]>

Returns:

the resolved interface mappings (with Class objects as values)
resolveInterfaceMappings
(Properties
the specified interface mappings
mappings
)

Resolve the given interface mappings, turning class names into Class objects.

public void
setBeanClassLoader(ClassLoader
the owning class loader
beanClassLoader
)

Implements org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Callback that supplies the bean class loader to a bean instance.
public void
setInterfaceMappings(Properties
the mappings of bean keys to interface names
mappings
)

Set the mappings of bean keys to a comma-separated list of interface names.

public void
setManagedInterfaces(Class<?>...
an array of classes indicating the interfaces to use. Each entry MUST be an interface.
managedInterfaces
)

Set the array of interfaces to use for creating the management info.

Inherited from org.springframework.jmx.export.assembler.AbstractConfigurableMBeanInfoAssembler:
getNotificationInfosetNotificationInfoMappingssetNotificationInfos

Field Detail

beanClassLoaderback to summary
private ClassLoader beanClassLoader
Annotations
@Nullable
interfaceMappingsback to summary
private Properties interfaceMappings

Mappings of bean keys to an array of classes.

Annotations
@Nullable
managedInterfacesback to summary
private Class<?>[] managedInterfaces
Annotations
@Nullable
resolvedInterfaceMappingsback to summary
private Map<String, Class<?>[]> resolvedInterfaceMappings

Mappings of bean keys to an array of classes.

Annotations
@Nullable

Constructor Detail

InterfaceBasedMBeanInfoAssemblerback to summary
public InterfaceBasedMBeanInfoAssembler()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Doc from org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

Annotations
@Override
includeOperationback to summary
protected boolean includeOperation(Method method, String beanKey)

Implements abstract org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.includeOperation.

Check to see if the Method is declared in one of the configured interfaces and that it is public.

Parameters
method:Method

the operation Method.

beanKey:String

the key associated with the MBean in the beans Map.

Returns:boolean

true if the Method is declared in one of the configured interfaces, otherwise false.

Annotations
@Override
includeReadAttributeback to summary
protected boolean includeReadAttribute(Method method, String beanKey)

Implements abstract org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.includeReadAttribute.

Check to see if the Method is declared in one of the configured interfaces and that it is public.

Parameters
method:Method

the accessor Method.

beanKey:String

the key associated with the MBean in the beans Map.

Returns:boolean

true if the Method is declared in one of the configured interfaces, otherwise false.

Annotations
@Override
includeWriteAttributeback to summary
protected boolean includeWriteAttribute(Method method, String beanKey)

Implements abstract org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.includeWriteAttribute.

Check to see if the Method is declared in one of the configured interfaces and that it is public.

Parameters
method:Method

the mutator Method.

beanKey:String

the key associated with the MBean in the beans Map.

Returns:boolean

true if the Method is declared in one of the configured interfaces, otherwise false.

Annotations
@Override
isDeclaredInInterfaceback to summary
private boolean isDeclaredInInterface(Method method, String beanKey)

Checks to see if the given method is declared in a managed interface for the given bean.

isPublicInInterfaceback to summary
private boolean isPublicInInterface(Method method, String beanKey)

Check to see if the Method is both public and declared in one of the configured interfaces.

Parameters
method:Method

the Method to check.

beanKey:String

the key associated with the MBean in the beans map

Returns:boolean

true if the Method is declared in one of the configured interfaces and is public, otherwise false.

resolveClassNamesback to summary
private Class<?>[] resolveClassNames(String[] classNames, String beanKey)

Resolve the given class names into Class objects.

Parameters
classNames:String[]

the class names to resolve

beanKey:String

the bean key that the class names are associated with

Returns:Class<?>[]

the resolved Class

resolveInterfaceMappingsback to summary
private Map<String, Class<?>[]> resolveInterfaceMappings(Properties mappings)

Resolve the given interface mappings, turning class names into Class objects.

Parameters
mappings:Properties

the specified interface mappings

Returns:Map<String, Class<?>[]>

the resolved interface mappings (with Class objects as values)

setBeanClassLoaderback to summary
public void setBeanClassLoader(ClassLoader beanClassLoader)

Implements org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Doc from org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Callback that supplies the bean class loader to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean's InitializingBean#afterPropertiesSet() method or a custom init-method.

Parameters
beanClassLoader:ClassLoader

the owning class loader

Annotations
@Override
setInterfaceMappingsback to summary
public void setInterfaceMappings(Properties mappings)

Set the mappings of bean keys to a comma-separated list of interface names.

The property key should match the bean key and the property value should match the list of interface names. When searching for interfaces for a bean, Spring will check these mappings first.

Parameters
mappings:Properties

the mappings of bean keys to interface names

setManagedInterfacesback to summary
public void setManagedInterfaces(Class<?>... managedInterfaces)

Set the array of interfaces to use for creating the management info. These interfaces will be used for a bean if no entry corresponding to that bean is found in the interfaceMappings property.

Parameters
managedInterfaces:Class<?>[]

an array of classes indicating the interfaces to use. Each entry MUST be an interface.

See Also
setInterfaceMappings