Hi Stephan
On 02/10/12 08:33, Klevenz, Stephan wrote:
Hi CXF Community,

Maybe this is just  a new-be question about CXF/JAX-RS but reading 
documentation doesn't bring me to a solution.

I have a resource which will handle the path segment

@Path("c/d")

Actually this is only a sub path of multiple and dynamic root paths:

a1/b1/c/d
a2/b2/c/d
...
an/bn/c/d

"c/d" is just a placeholde for a more complex resource handling which is the 
same for all roots.

Has anyone an idea how to model this with CXF/JAX-RS or can at least point to 
documentation describing this kind of problem?


is it effectively about reusing the same piece of code no matter what the root path is ?

May be a subresource locator can do ?

@Path("/a{id1}/b{id2}")
public Root {

   @Path("/")
   public CDHandler getCDPathHandler() {
       return new CDHandler();
   }

}

@Path("/some/other/path")
public Root2 {

   @Path("/")
   public CDHandler getCDPathHandler() {
       return new CDHandler();
   }

}

etc. Note the same resource such as Root, Root2 or CDHandler itself can delegate to themselves if needed:

@Path("/some/other/path")
public Root2 {

   @Path("/bar")
   public CDHandler getCDPathHandler() {
       return this;
   }
   @GET
   @Path("/book")
   public Book get() {}

   @Path("/")
   public CDHandler getCDPathHandler() {
       return new CDHandler();
   }

}

so

/some/other/path/book
and
/some/other/path/bar/book

will be handled by get(),

/some/other/path/bar/1/2/3
/some/other/path/1/2/3

will be taken care of by CDHandler...

Does above help ?

Cheers, Sergey
Thanks in advance.

Regards,
Stephan
--




Reply via email to