Top Description Fields Constructors Methods
org.springframework.core

public Class SimpleAliasRegistry

extends Object
implements AliasRegistry
Class Inheritance
All Implemented Interfaces
org.springframework.core.AliasRegistry
Imports
java.util.ArrayList, .HashMap, .List, .Map, java.util.concurrent.ConcurrentHashMap, org.apache.commons.logging.Log, .LogFactory, org.springframework.util.Assert, .ObjectUtils, .StringUtils, .StringValueResolver

Simple implementation of the AliasRegistry interface.

Serves as base class for org.springframework.beans.factory.support.BeanDefinitionRegistry implementations.

Authors
Juergen Hoeller, Qimiao Chen, Sam Brannen
Since
2.5.2

Field Summary

Modifier and TypeField and Description
private final Map<String, String>
aliasMap

Map from alias to canonical name.

protected final Log
logger

Logger available to subclasses.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean
allowAliasOverriding()

Determine whether alias overriding is allowed.

public String

Returns:

the transformed name
canonicalName
(String
the user-specified name
name
)

Determine the raw name, resolving aliases to canonical names.

protected void
checkForAliasCircle(String
the candidate name
name
,
String
the candidate alias
alias
)

Check whether the given name points back to the given alias as an alias in the other direction already, catching a circular reference upfront and throwing a corresponding IllegalStateException.

public String[]
getAliases(String
the name to check for aliases
name
)

Implements org.springframework.core.AliasRegistry.getAliases.

Return the aliases for the given name, if defined.

public boolean
hasAlias(String
the name to check
name
,
String
the alias to look for
alias
)

Determine whether the given name has the given alias registered.

public boolean
isAlias(String
the name to check
name
)

Implements org.springframework.core.AliasRegistry.isAlias.

Determine whether the given name is defined as an alias (as opposed to the name of an actually registered component).

public void
registerAlias(String
the canonical name
name
,
String
the alias to be registered
alias
)

Implements org.springframework.core.AliasRegistry.registerAlias.

Given a name, register an alias for it.

public void
removeAlias(String
the alias to remove
alias
)

Implements org.springframework.core.AliasRegistry.removeAlias.

Remove the specified alias from this registry.

public void
resolveAliases(StringValueResolver
the StringValueResolver to apply
valueResolver
)

Resolve all alias target names and aliases registered in this registry, applying the given StringValueResolver to them.

private void
retrieveAliases(String
the target name to find aliases for
name
,
List<String>
the resulting aliases list
result
)

Transitively retrieve all aliases for the given name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

aliasMapback to summary
private final Map<String, String> aliasMap

Map from alias to canonical name.

loggerback to summary
protected final Log logger

Logger available to subclasses.

Constructor Detail

SimpleAliasRegistryback to summary
public SimpleAliasRegistry()

Method Detail

allowAliasOverridingback to summary
protected boolean allowAliasOverriding()

Determine whether alias overriding is allowed.

Default is true.

canonicalNameback to summary
public String canonicalName(String name)

Determine the raw name, resolving aliases to canonical names.

Parameters
name:String

the user-specified name

Returns:String

the transformed name

checkForAliasCircleback to summary
protected void checkForAliasCircle(String name, String alias)

Check whether the given name points back to the given alias as an alias in the other direction already, catching a circular reference upfront and throwing a corresponding IllegalStateException.

Parameters
name:String

the candidate name

alias:String

the candidate alias

See Also
registerAlias, hasAlias
getAliasesback to summary
public String[] getAliases(String name)

Implements org.springframework.core.AliasRegistry.getAliases.

Doc from org.springframework.core.AliasRegistry.getAliases.

Return the aliases for the given name, if defined.

Parameters
name:String

the name to check for aliases

Returns:String[]

the aliases, or an empty array if none

Annotations
@Override
hasAliasback to summary
public boolean hasAlias(String name, String alias)

Determine whether the given name has the given alias registered.

Parameters
name:String

the name to check

alias:String

the alias to look for

Since
4.2.1
isAliasback to summary
public boolean isAlias(String name)

Implements org.springframework.core.AliasRegistry.isAlias.

Doc from org.springframework.core.AliasRegistry.isAlias.

Determine whether the given name is defined as an alias (as opposed to the name of an actually registered component).

Parameters
name:String

the name to check

Returns:boolean

whether the given name is an alias

Annotations
@Override
registerAliasback to summary
public void registerAlias(String name, String alias)

Implements org.springframework.core.AliasRegistry.registerAlias.

Doc from org.springframework.core.AliasRegistry.registerAlias.

Given a name, register an alias for it.

Parameters
name:String

the canonical name

alias:String

the alias to be registered

Annotations
@Override
removeAliasback to summary
public void removeAlias(String alias)

Implements org.springframework.core.AliasRegistry.removeAlias.

Doc from org.springframework.core.AliasRegistry.removeAlias.

Remove the specified alias from this registry.

Parameters
alias:String

the alias to remove

Annotations
@Override
resolveAliasesback to summary
public void resolveAliases(StringValueResolver valueResolver)

Resolve all alias target names and aliases registered in this registry, applying the given StringValueResolver to them.

The value resolver may for example resolve placeholders in target bean names and even in alias names.

Parameters
valueResolver:StringValueResolver

the StringValueResolver to apply

retrieveAliasesback to summary
private void retrieveAliases(String name, List<String> result)

Transitively retrieve all aliases for the given name.

Parameters
name:String

the target name to find aliases for

result:List<String>

the resulting aliases list