@ -45,23 +45,25 @@ public class SimpleAliasRegistry implements AliasRegistry {
@@ -45,23 +45,25 @@ public class SimpleAliasRegistry implements AliasRegistry {
publicvoidregisterAlias(Stringname,Stringalias){
Assert.hasText(name,"'name' must not be empty");
Assert.hasText(alias,"'alias' must not be empty");
if(alias.equals(name)){
this.aliasMap.remove(alias);
}
else{
StringregisteredName=this.aliasMap.get(alias);
if(registeredName!=null){
if(registeredName.equals(name)){
// An existing alias - no need to re-register
return;
}
if(!allowAliasOverriding()){
thrownewIllegalStateException("Cannot register alias '"+alias+"' for name '"+
name+"': It is already registered for name '"+registeredName+"'.");
synchronized(this.aliasMap){
if(alias.equals(name)){
this.aliasMap.remove(alias);
}
else{
StringregisteredName=this.aliasMap.get(alias);
if(registeredName!=null){
if(registeredName.equals(name)){
// An existing alias - no need to re-register
return;
}
if(!allowAliasOverriding()){
thrownewIllegalStateException("Cannot register alias '"+alias+"' for name '"+
name+"': It is already registered for name '"+registeredName+"'.");
}
}
checkForAliasCircle(name,alias);
this.aliasMap.put(alias,name);
}
checkForAliasCircle(name,alias);
this.aliasMap.put(alias,name);
}
}
@ -92,9 +94,11 @@ public class SimpleAliasRegistry implements AliasRegistry {
@@ -92,9 +94,11 @@ public class SimpleAliasRegistry implements AliasRegistry {
@Override
publicvoidremoveAlias(Stringalias){
Stringname=this.aliasMap.remove(alias);
if(name==null){
thrownewIllegalStateException("No alias '"+alias+"' registered");
synchronized(this.aliasMap){
Stringname=this.aliasMap.remove(alias);
if(name==null){
thrownewIllegalStateException("No alias '"+alias+"' registered");