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

public Class KeyNamingStrategy

extends Object
implements ObjectNamingStrategy, InitializingBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.InitializingBean, org.springframework.jmx.export.naming.ObjectNamingStrategy
Imports
java.io.IOException, java.util.Properties, javax.management.MalformedObjectNameException, .ObjectName, org.apache.commons.logging.Log, .LogFactory, org.springframework.beans.factory.InitializingBean, org.springframework.core.io.Resource, org.springframework.core.io.support.PropertiesLoaderUtils, org.springframework.jmx.support.ObjectNameManager, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils

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.

Authors
Rob Harrop, Juergen Hoeller
Since
1.2
See Also
setMappings, setMappingLocation, setMappingLocations, org.springframework.jmx.export.MBeanExporter#setBeans

Field Summary

Modifier and TypeField and Description
protected final Log
logger

Log instance for this class.

private Resource[]
mappingLocations

Stores the Resources containing properties that should be loaded into the final merged set of Properties used for ObjectName resolution.

private Properties
mappings

Stores the mappings of bean key to ObjectName.

private Properties
mergedMappings

Stores the result of merging the mappings Properties with the properties stored in the resources defined by mappingLocations.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

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

Merges the Properties configured in the mappings and mappingLocations into the final Properties instance used for ObjectName resolution.

public ObjectName
getObjectName(Object
the bean that will be exposed under the returned ObjectName
managedBean
,
String
the key associated with this bean in the beans map passed to the MBeanExporter
beanKey
)

Implements org.springframework.jmx.export.naming.ObjectNamingStrategy.getObjectName.

Attempts to retrieve the ObjectName via the given key, trying to find a mapped value in the mappings first.

public void
setMappingLocation(Resource location)

Set a location of a properties file to be loaded, containing object name mappings.

public void
setMappingLocations(Resource... mappingLocations)

Set location of properties files to be loaded, containing object name mappings.

public void
setMappings(Properties mappings)

Set local properties, containing object name mappings, e.g. via the "props" tag in XML bean definitions.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
protected final Log logger

Log instance for this class.

mappingLocationsback to summary
private Resource[] mappingLocations

Stores the Resources containing properties that should be loaded into the final merged set of Properties used for ObjectName resolution.

Annotations
@Nullable
mappingsback to summary
private Properties mappings

Stores the mappings of bean key to ObjectName.

Annotations
@Nullable
mergedMappingsback to summary
private Properties mergedMappings

Stores the result of merging the mappings Properties with the properties stored in the resources defined by mappingLocations.

Annotations
@Nullable

Constructor Detail

KeyNamingStrategyback to summary
public KeyNamingStrategy()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet() throws IOException

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

Merges the Properties configured in the mappings and mappingLocations into the final Properties instance used for ObjectName resolution.

Annotations
@Override
getObjectNameback to summary
public ObjectName getObjectName(Object managedBean, String beanKey) throws MalformedObjectNameException

Implements org.springframework.jmx.export.naming.ObjectNamingStrategy.getObjectName.

Attempts to retrieve the ObjectName via the given key, trying to find a mapped value in the mappings first.

Parameters
managedBean:Object

Doc from org.springframework.jmx.export.naming.ObjectNamingStrategy.getObjectName.

the bean that will be exposed under the returned ObjectName

beanKey:String

Doc from org.springframework.jmx.export.naming.ObjectNamingStrategy.getObjectName.

the key associated with this bean in the beans map passed to the MBeanExporter

Returns:ObjectName

Doc from org.springframework.jmx.export.naming.ObjectNamingStrategy.getObjectName.

the ObjectName instance

Annotations
@Override
Exceptions
MalformedObjectNameException:

Doc from org.springframework.jmx.export.naming.ObjectNamingStrategy.getObjectName.

if the resulting ObjectName is invalid

setMappingLocationback to summary
public void setMappingLocation(Resource location)

Set a location of a properties file to be loaded, containing object name mappings.

setMappingLocationsback to summary
public void setMappingLocations(Resource... mappingLocations)

Set location of properties files to be loaded, containing object name mappings.

setMappingsback to summary
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.