in velocity-tools-generic/src/main/java/org/apache/velocity/tools/config/ToolboxConfiguration.java [106:151]
public void validate()
{
super.validate();
if (getScope() == null)
{
throw new ConfigurationException(this, "Toolbox scope cannot be null");
}
if (!Scope.exists(getScope()))
{
throw new ConfigurationException(this, "Scope '"+getScope()+"' is not recognized. Please correct or add your new custom scope with "+Scope.class.getName()+".add(\""+getScope()+"\").");
}
// validate that all tools are allowed in this scope
for (ToolConfiguration tool : getTools())
{
// check if this toolbox's scope has been declared invalid
for (String invalidScope : tool.getInvalidScopes())
{
if (getScope().equals(invalidScope))
{
throw new InvalidScopeException(this, tool);
}
}
// if the set of valid scopes has been limited, check to be
// sure that this toolbox's scope is in the set
String[] validScopes = tool.getValidScopes();
if (validScopes != null && validScopes.length > 0)
{
boolean found = false;
for (String validScope : validScopes)
{
if (getScope().equals(validScope))
{
found = true;
break;
}
}
if (!found)
{
throw new InvalidScopeException(this, tool);
}
}
}
}