Class KeyNamingStrategy
- java.lang.Object
- org.springframework.jmx.export.naming.KeyNamingStrategy
- All Implemented Interfaces:
InitializingBean,ObjectNamingStrategy
public class KeyNamingStrategy extends Object implements ObjectNamingStrategy, InitializingBean
ObjectNamingStrategyimplementation that buildsObjectNameinstances from the key used in the "beans" map passed toMBeanExporter.Can also check object name mappings, given as
Propertiesor asmappingLocationsof properties files. The key used to look up is the key used inMBeanExporter's "beans" map. If no mapping is found for a given key, the key itself is used to build anObjectName.- Since:
- 1.2
- Author:
- Rob Harrop, Juergen Hoeller
- See Also:
setMappings(java.util.Properties),setMappingLocation(org.springframework.core.io.Resource),setMappingLocations(org.springframework.core.io.Resource...),MBeanExporter.setBeans(java.util.Map<java.lang.String, java.lang.Object>)
Constructor Summary
Constructors Constructor Description KeyNamingStrategy()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Merges thePropertiesconfigured in themappingsandmappingLocationsinto the finalPropertiesinstance used forObjectNameresolution.ObjectNamegetObjectName(Object managedBean, String beanKey)Attempts to retrieve theObjectNamevia the given key, trying to find a mapped value in the mappings first.voidsetMappingLocation(Resource location)Set a location of a properties file to be loaded, containing object name mappings.voidsetMappingLocations(Resource... mappingLocations)Set location of properties files to be loaded, containing object name mappings.voidsetMappings(Properties mappings)Set local properties, containing object name mappings, e.g.
Constructor Detail
KeyNamingStrategy
public KeyNamingStrategy()
Method Detail
setMappings
public void setMappings(Properties mappings)
Set local properties, containing object name mappings, e.g. via the "props" tag in XML bean definitions. These can be considered defaults, to be overridden by properties loaded from files.
setMappingLocation
public void setMappingLocation(Resource location)
Set a location of a properties file to be loaded, containing object name mappings.
setMappingLocations
public void setMappingLocations(Resource... mappingLocations)
Set location of properties files to be loaded, containing object name mappings.
afterPropertiesSet
public void afterPropertiesSet() throws IOException
Merges thePropertiesconfigured in themappingsandmappingLocationsinto the finalPropertiesinstance used forObjectNameresolution.- Specified by:
afterPropertiesSetin interfaceInitializingBean- Throws:
IOException
getObjectName
public ObjectName getObjectName(Object managedBean, String beanKey) throws MalformedObjectNameException
Attempts to retrieve theObjectNamevia the given key, trying to find a mapped value in the mappings first.- Specified by:
getObjectNamein interfaceObjectNamingStrategy- Parameters:
managedBean- the bean that will be exposed under the returnedObjectNamebeanKey- the key associated with this bean in the beans map passed to theMBeanExporter- Returns:
- the
ObjectNameinstance - Throws:
MalformedObjectNameException- if the resultingObjectNameis invalid