* @param node the markup node
* @return builder that handles the node
*/
public static Builder getRenderer(Node node) {
BuilderRuleContext context = new BuilderRuleContext();
context.setNode(node);
try {
Catalog catalog = getCatalog();
Command command = null;
if (node.getQname() == null) {
command = catalog.getCommand(Globals.FIND_DEFAULT_BUILDER_COMMAND_NAME);
} else {
String prefix = node.getQname();
String uri = node.getNamespaceURI(prefix);
if (uri != null) {
command = catalog.getCommand(uri);
if (command == null) {
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null) {
facesContext.getExternalContext().getRequestMap()
.put(Globals.CLAY_CUSTOM_BUILDER_XMLNS, uri);
}
command = catalog.getCommand(Globals.FIND_UNKNOWN_BUILDER_COMMAND_NAME);
}
} else {
command = catalog.getCommand(Globals.FIND_UNKNOWN_BUILDER_COMMAND_NAME);
}
}
command.execute(context);
} catch (Exception e) {
log.error(e);
throw new RuntimeException(e);
}
return context.getBuilder();
}