stack.add(extensionName);
checkRequirements(stack);
}
private void checkRequirements(List<String> stack) {
PageExtension top = getRegistry().getExtension(stack.get(stack.size()-1));
if (top == null) {
throw new IllegalArgumentException("There is no registered extension '"+stack.get(stack.size()-1)+"'.");
}
for (String requiredName: top.getRequired()) {
PageExtension required = getRegistry().getExtension(requiredName);
for (String onStack: stack) {
if (required.getName().equals(onStack)) {
throw new IllegalStateException("There is a cycle in page extension requirements, DFS stack: " + stack);
}
}
stack.add(required.getName());
checkRequirements(stack);
}
stack.remove(stack.size()-1);
}