Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,10 +44,10 @@ public interface AliasRegistry {
|
||||
/**
|
||||
* Determine whether this given name is defines as an alias
|
||||
* (as opposed to the name of an actually registered component).
|
||||
* @param beanName the bean name to check
|
||||
* @param name the name to check
|
||||
* @return whether the given name is an alias
|
||||
*/
|
||||
boolean isAlias(String beanName);
|
||||
boolean isAlias(String name);
|
||||
|
||||
/**
|
||||
* Return the aliases for the given name, if defined.
|
||||
|
||||
@@ -144,6 +144,22 @@ public class SimpleAliasRegistry implements AliasRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param name the candidate name
|
||||
* @param alias the candidate alias
|
||||
* @see #registerAlias
|
||||
*/
|
||||
protected void checkForAliasCircle(String name, String alias) {
|
||||
if (alias.equals(canonicalName(name))) {
|
||||
throw new IllegalStateException("Cannot register alias '" + alias +
|
||||
"' for name '" + name + "': Circular reference - '" +
|
||||
name + "' is a direct or indirect alias for '" + alias + "' already");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the raw name, resolving aliases to canonical names.
|
||||
* @param name the user-specified name
|
||||
@@ -163,20 +179,4 @@ public class SimpleAliasRegistry implements AliasRegistry {
|
||||
return canonicalName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param name the candidate name
|
||||
* @param alias the candidate alias
|
||||
* @see #registerAlias
|
||||
*/
|
||||
protected void checkForAliasCircle(String name, String alias) {
|
||||
if (alias.equals(canonicalName(name))) {
|
||||
throw new IllegalStateException("Cannot register alias '" + alias +
|
||||
"' for name '" + name + "': Circular reference - '" +
|
||||
name + "' is a direct or indirect alias for '" + alias + "' already");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user