Class MetadataNamingStrategy
- java.lang.Object
- org.springframework.jmx.export.naming.MetadataNamingStrategy
- All Implemented Interfaces:
InitializingBean
,ObjectNamingStrategy
public class MetadataNamingStrategy extends Object implements ObjectNamingStrategy, InitializingBean
An implementation of theObjectNamingStrategy
interface that reads theObjectName
from the source-level metadata. Falls back to the bean key (bean name) if noObjectName
can be found in source-level metadata.Uses the
JmxAttributeSource
strategy interface, so that metadata can be read using any supported implementation. Out of the box,AnnotationJmxAttributeSource
introspects a well-defined set of Java 5 annotations that come with Spring.- Since:
- 1.2
- Author:
- Rob Harrop, Juergen Hoeller
- See Also:
ObjectNamingStrategy
,AnnotationJmxAttributeSource
Constructor Summary
Constructors Constructor Description MetadataNamingStrategy()
Create a newMetadataNamingStrategy
which needs to be configured through thesetAttributeSource(org.springframework.jmx.export.metadata.JmxAttributeSource)
method.MetadataNamingStrategy(JmxAttributeSource attributeSource)
Create a newMetadataNamingStrategy
for the givenJmxAttributeSource
.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.ObjectName
getObjectName(Object managedBean, String beanKey)
Reads theObjectName
from the source-level metadata associated with the managed resource'sClass
.void
setAttributeSource(JmxAttributeSource attributeSource)
Set the implementation of theJmxAttributeSource
interface to use when reading the source-level metadata.void
setDefaultDomain(String defaultDomain)
Specify the default domain to be used for generating ObjectNames when no source-level metadata has been specified.
Constructor Detail
MetadataNamingStrategy
public MetadataNamingStrategy()
Create a newMetadataNamingStrategy
which needs to be configured through thesetAttributeSource(org.springframework.jmx.export.metadata.JmxAttributeSource)
method.
MetadataNamingStrategy
public MetadataNamingStrategy(JmxAttributeSource attributeSource)
Create a newMetadataNamingStrategy
for the givenJmxAttributeSource
.- Parameters:
attributeSource
- the JmxAttributeSource to use
Method Detail
setAttributeSource
public void setAttributeSource(JmxAttributeSource attributeSource)
Set the implementation of theJmxAttributeSource
interface to use when reading the source-level metadata.
setDefaultDomain
public void setDefaultDomain(String defaultDomain)
Specify the default domain to be used for generating ObjectNames when no source-level metadata has been specified.The default is to use the domain specified in the bean name (if the bean name follows the JMX ObjectName syntax); else, the package name of the managed bean class.
afterPropertiesSet
public void afterPropertiesSet()
Description copied from interface:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,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.
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
getObjectName
public ObjectName getObjectName(Object managedBean, String beanKey) throws MalformedObjectNameException
Reads theObjectName
from the source-level metadata associated with the managed resource'sClass
.- Specified by:
getObjectName
in interfaceObjectNamingStrategy
- Parameters:
managedBean
- the bean that will be exposed under the returnedObjectName
beanKey
- the key associated with this bean in the beans map passed to theMBeanExporter
- Returns:
- the
ObjectName
instance - Throws:
MalformedObjectNameException
- if the resultingObjectName
is invalid