/** * Attaches a Resource class to this router as the default target to invoke * when no route matches. It actually sets a default route that scores all * calls to 1.0. * * @param defaultTargetClass * The target Resource class to attach. * @return The created route. */ public Route attachDefault(Class<? extends Resource> defaultTargetClass) { return attachDefault(createFinder(defaultTargetClass)); }
/** * Attaches a target Resource class to this router based on a given URI * pattern. A new route will be added routing to the target when calls with * a URI matching the pattern will be received. * * @param uriPattern * The URI pattern that must match the relative part of the * resource URI. * @param targetClass * The target Resource class to attach. * @return The created route. */ public Route attach(String uriPattern, Class<? extends Resource> targetClass) { return attach(uriPattern, createFinder(targetClass)); }
@Override protected Finder createFinder( Class<? extends Resource> targetClass) { Finder result = super.createFinder(targetClass); result.setContext(getContext().createChildContext()); return result; }
/** * Creates a new finder instance based on the "targetClass" property. * * In addition to super class behavior, this method will set the context of * the finder by creating a protected context via the * {@link Context#createChildContext()} method. * * @param targetClass * The target Resource class to attach. * @return The new finder instance. */ @Override protected Finder createFinder(Class<? extends Resource> targetClass) { Finder result = super.createFinder(targetClass); result.setContext(getContext().createChildContext()); return result; }