public void attach(Router router,Element child,boolean defaultRoute) {
attach(router,null,child,defaultRoute);
}
protected void attach(Router router,Filter filter,Element child,boolean defaultRoute) {
Name name = child.getName();
Context parentContext = router==null ? filter.getContext() : router.getContext();
if (name.equals(ROUTER)) {
String match = child.getAttributeValue("match");
if (match==null && filter==null && !defaultRoute) {
LOG.severe("The router element does not have the required match attribute.");
return;
}
if (defaultRoute) {
router.attachDefault(createRouter(parentContext,child));
} else if (router!=null) {
router.attach(match,createRouter(parentContext,child));
} else {
filter.setNext(createRouter(parentContext,child));
}
} else if (name.equals(ROUTE)) {
String match = child.getAttributeValue("match");
if (match==null && filter==null && !defaultRoute) {
LOG.severe("The route element does not have the required match attribute.");
return;
}
Class def = getTargetClass(child);
if (def==null) {
return;
}
if (isServerResource(def)) {
Restlet finder = Finder.createFinder(def, Finder.class, hasParametersOrAttributes(child) ? createContext(parentContext,child) : parentContext,parentContext.getLogger());
if (defaultRoute) {
LOG.fine("Mapping default -> "+def.getName());
router.attachDefault(finder);
} else if (router!=null) {
LOG.fine("Mapping "+match+" -> "+def.getName());