Ouf... I couldn't think of a good title for this mail (sorry). Here's the situation:
I have the following URI routing (simplified resource class names for this example, both classes extend ServerResource): router.attach("/workspaces/{wksp}/releases", WRR.class); router.attach("/workspaces/{wksp}/releases/{rel}", WRR.class); router.attach("/workspaces/{wksp}/releases/{rel}/{langOrFile}", WRFR.class); router.attach("/workspaces/{wksp}/releases/{rel}/{lang}/{file}", WRFR.class); The WRR class supports the DELETE method: @Delete @Override public Representation delete() throws ResourceException { // METHOD DEFINITION HERE } The WRFR class supports the GET method with 3 possible variants: XML, HTML, binary stream (a.k.a. a file's content): @Override public void doInit() throws ResourceException { // INIT CODE HERE List<Variant> variants = new ArrayList<Variant>(); variants.add(new Variant(MediaType.APPLICATION_XHTML)); variants.add(new Variant(MediaType.TEXT_XML)); variants.add(new Variant(MediaType.TEXT_HTML)); getVariants().put(Method.GET, variants); // The 3rd variant, binary stream, will be handled by get(), no need to declare it here (I guess...) } Now, here's the problem: I'd like to be able to perform a GET request to WRR too, but the request must be handled by WRFR instead. That is, I'd like to be able to say something like: GET /workspaces/w1/releases/ReleaseName and have it handled by WRFR (which already has all logic to do it), instead of WRR (as setup in the routing). The above particular request would list all files belonging to release ReleaseName. I've tried this on WRR: @Override public Representation get(Variant variant) throws ResourceException { WRFR wrfr = new WRFR(); wrfr.doInit(); return wrfr.get(variant); // Wired internally to another resource } And from the logs it seems the correct sequence is being performed: WRR.get() is called which in turn calls WRFR.get() but I'm getting NPEs all over the place. Tried also without calling doInit() explicitly (I guess the ServerResource calls it by default, right?) Is this the correct way to wire restlets internally? Is there any other (more elegant, more performant, "just working", whatever) solution to this problem? I can provide concrete examples of code with log traces if this will help you helping me fix this issue. Thanks in advance for your prompt and accurate (as usual) answer! P.S. There is a simple solution for my problem: GET /workspaces/w1/releases/ReleaseName/ROOT (or changing ROOT for any other hardcoded word), and adding simple logic on WRFR to handle this particular case, but it's neither intuitive (natural), nor elegant, so I'm discarding it for now. -- Fabián Mandelbaum IS Engineer ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2371507