public ProcessingNode buildNode(Configuration config) throws Exception {
boolean inActionSet = this.treeBuilder.getAttribute(ActionSetNodeBuilder.IN_ACTION_SET) != null;
// Is it an action-set call ?
this.actSetName = config.getAttribute("set", null);
if (actSetName == null) {
if (inActionSet) {
// Check that children are only parameters or actions
Configuration children[] = config.getChildren();
for (int i = 0; i < children.length; i++) {
String name = children[i].getName();
if (!"act".equals(name) && !"parameter".equals(name)) {
throw new ConfigurationException("An action set can only contain actions and not '"
+ name + "' at " + children[i].getLocation());
}
}
}
String name = config.getAttribute("name", null);
String source = config.getAttribute("src", null);
String type = this.treeBuilder.getTypeForStatement(config, Action.ROLE + "Selector");
ActTypeNode actTypeNode = new ActTypeNode(
type,
VariableResolverFactory.getResolver(source, this.manager),
name,
inActionSet
);
this.treeBuilder.setupNode(actTypeNode, config);
actTypeNode.setChildren(buildChildNodes(config));
return actTypeNode;
} else {
if (inActionSet) {
throw new ConfigurationException("Cannot call an action set from an action set at " + config.getLocation());
}
// Action set call
if (config.getAttribute("src", null) != null) {
getLogger().warn("The 'src' attribute is ignored for action-set call at " + config.getLocation());
}
this.actSetNode = new ActSetNode();
this.treeBuilder.setupNode(this.actSetNode, config);
this.actSetNode.setChildren(buildChildNodes(config));
return this.actSetNode;
}
}
|