Class KeyNamingStrategy
java.lang.Object
org.springframework.jmx.export.naming.KeyNamingStrategy
- All Implemented Interfaces:
InitializingBean
,ObjectNamingStrategy
ObjectNamingStrategy
implementation that builds
ObjectName
instances from the key used in the
"beans" map passed to MBeanExporter
.
Can also check object name mappings, given as Properties
or as mappingLocations
of properties files. The key used
to look up is the key used in MBeanExporter
's "beans" map.
If no mapping is found for a given key, the key itself is used to
build an ObjectName
.
- Since:
- 1.2
- Author:
- Rob Harrop, Juergen Hoeller
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Merges theProperties
configured in themappings
andmappingLocations
into the finalProperties
instance used forObjectName
resolution.getObjectName
(Object managedBean, String beanKey) Attempts to retrieve theObjectName
via the given key, trying to find a mapped value in the mappings first.void
setMappingLocation
(Resource location) Set a location of a properties file to be loaded, containing object name mappings.void
setMappingLocations
(Resource... mappingLocations) Set location of properties files to be loaded, containing object name mappings.void
setMappings
(Properties mappings) Set local properties, containing object name mappings, e.g.
-
Field Details
-
logger
Log
instance for this class.
-
-
Constructor Details
-
KeyNamingStrategy
public KeyNamingStrategy()
-
-
Method Details
-
setMappings
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
Set a location of a properties file to be loaded, containing object name mappings. -
setMappingLocations
Set location of properties files to be loaded, containing object name mappings. -
afterPropertiesSet
Merges theProperties
configured in themappings
andmappingLocations
into the finalProperties
instance used forObjectName
resolution.- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
IOException
-
getObjectName
public ObjectName getObjectName(Object managedBean, @Nullable String beanKey) throws MalformedObjectNameException Attempts to retrieve theObjectName
via the given key, trying to find a mapped value in the mappings first.- 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
-