Spring Framework

org.springframework.core
Class SimpleAliasRegistry

java.lang.Object
  extended by org.springframework.core.SimpleAliasRegistry
All Implemented Interfaces:
AliasRegistry
Direct Known Subclasses:
DefaultSingletonBeanRegistry, SimpleBeanDefinitionRegistry

public class SimpleAliasRegistry
extends java.lang.Object
implements AliasRegistry

Simple implementation of the AliasRegistry interface. Serves as base class for BeanDefinitionRegistry implementations.

Since:
2.5.2
Author:
Juergen Hoeller

Constructor Summary
SimpleAliasRegistry()
           
 
Method Summary
protected  boolean allowAliasOverriding()
          Return whether alias overriding is allowed.
 java.lang.String canonicalName(java.lang.String name)
          Determine the raw name, resolving aliases to canonical names.
protected  void checkForAliasCircle(java.lang.String name, java.lang.String alias)
          Check whether the given name points back to given alias as an alias in the other direction, catching a circular reference upfront and throwing a corresponding IllegalStateException.
 java.lang.String[] getAliases(java.lang.String name)
          Return the aliases for the given name, if defined.
 boolean isAlias(java.lang.String name)
          Determine whether this given name is defines as an alias (as opposed to the name of an actually registered component).
 void registerAlias(java.lang.String name, java.lang.String alias)
          Given a name, register an alias for it.
 void removeAlias(java.lang.String alias)
          Remove the specified alias from this registry.
 void resolveAliases(StringValueResolver valueResolver)
          Resolve all alias target names and aliases registered in this factory, applying the given StringValueResolver to them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleAliasRegistry

public SimpleAliasRegistry()
Method Detail

registerAlias

public void registerAlias(java.lang.String name,
                          java.lang.String alias)
Description copied from interface: AliasRegistry
Given a name, register an alias for it.

Specified by:
registerAlias in interface AliasRegistry
Parameters:
name - the canonical name
alias - the alias to be registered

allowAliasOverriding

protected boolean allowAliasOverriding()
Return whether alias overriding is allowed. Default is true.


removeAlias

public void removeAlias(java.lang.String alias)
Description copied from interface: AliasRegistry
Remove the specified alias from this registry.

Specified by:
removeAlias in interface AliasRegistry
Parameters:
alias - the alias to remove

isAlias

public boolean isAlias(java.lang.String name)
Description copied from interface: AliasRegistry
Determine whether this given name is defines as an alias (as opposed to the name of an actually registered component).

Specified by:
isAlias in interface AliasRegistry
Parameters:
name - the bean name to check
Returns:
whether the given name is an alias

getAliases

public java.lang.String[] getAliases(java.lang.String name)
Description copied from interface: AliasRegistry
Return the aliases for the given name, if defined.

Specified by:
getAliases in interface AliasRegistry
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

canonicalName

public java.lang.String canonicalName(java.lang.String name)
Determine the raw name, resolving aliases to canonical names.

Parameters:
name - the user-specified name
Returns:
the transformed name

checkForAliasCircle

protected void checkForAliasCircle(java.lang.String name,
                                   java.lang.String alias)
Check whether the given name points back to given alias as an alias in the other direction, catching a circular reference upfront and throwing a corresponding IllegalStateException.

Parameters:
name - the candidate name
alias - the candidate alias
See Also:
registerAlias(java.lang.String, java.lang.String)

Spring Framework