Package org.springframework.core
Class SimpleAliasRegistry
- java.lang.Object
- org.springframework.core.SimpleAliasRegistry
- All Implemented Interfaces:
AliasRegistry
- Direct Known Subclasses:
DefaultSingletonBeanRegistry,SimpleBeanDefinitionRegistry
public class SimpleAliasRegistry extends Object implements AliasRegistry
Simple implementation of theAliasRegistryinterface. Serves as base class forBeanDefinitionRegistryimplementations.- Since:
- 2.5.2
- Author:
- Juergen Hoeller
Constructor Summary
Constructors Constructor Description SimpleAliasRegistry()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanallowAliasOverriding()Return whether alias overriding is allowed.StringcanonicalName(String name)Determine the raw name, resolving aliases to canonical names.protected voidcheckForAliasCircle(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.String[]getAliases(String name)Return the aliases for the given name, if defined.booleanhasAlias(String name, String alias)Determine whether the given name has the given alias registered.booleanisAlias(String name)Determine whether this given name is defines as an alias (as opposed to the name of an actually registered component).voidregisterAlias(String name, String alias)Given a name, register an alias for it.voidremoveAlias(String alias)Remove the specified alias from this registry.voidresolveAliases(StringValueResolver valueResolver)Resolve all alias target names and aliases registered in this factory, applying the given StringValueResolver to them.
Constructor Detail
SimpleAliasRegistry
public SimpleAliasRegistry()
Method Detail
registerAlias
public void registerAlias(String name, String alias)
Description copied from interface:AliasRegistryGiven a name, register an alias for it.- Specified by:
registerAliasin interfaceAliasRegistry- Parameters:
name- the canonical namealias- the alias to be registered
allowAliasOverriding
protected boolean allowAliasOverriding()
Return whether alias overriding is allowed. Default istrue.
hasAlias
public boolean hasAlias(String name, String alias)
Determine whether the given name has the given alias registered.- Parameters:
name- the name to checkalias- the alias to look for- Since:
- 4.2.1
removeAlias
public void removeAlias(String alias)
Description copied from interface:AliasRegistryRemove the specified alias from this registry.- Specified by:
removeAliasin interfaceAliasRegistry- Parameters:
alias- the alias to remove
isAlias
public boolean isAlias(String name)
Description copied from interface:AliasRegistryDetermine whether this given name is defines as an alias (as opposed to the name of an actually registered component).- Specified by:
isAliasin interfaceAliasRegistry- Parameters:
name- the name to check- Returns:
- whether the given name is an alias
getAliases
public String[] getAliases(String name)
Description copied from interface:AliasRegistryReturn the aliases for the given name, if defined.- Specified by:
getAliasesin interfaceAliasRegistry- Parameters:
name- the name to check for aliases- Returns:
- the aliases, or an empty array if none
resolveAliases
public void resolveAliases(StringValueResolver valueResolver)
Resolve all alias target names and aliases registered in this factory, 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- the StringValueResolver to apply
checkForAliasCircle
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- the candidate namealias- the candidate alias- See Also:
registerAlias(java.lang.String, java.lang.String),hasAlias(java.lang.String, java.lang.String)
canonicalName
public String canonicalName(String name)
Determine the raw name, resolving aliases to canonical names.- Parameters:
name- the user-specified name- Returns:
- the transformed name