jeudi 12 mars 2015

How to write single JAX-RS resource for variable number of path parameters



I have been writing a JAX-RS based ReST application using Apache Wink and I understood the concept of association between path params to resource handle class. Here I see that, We can define paths using @Path annotation and corresponding resource which will get called based on HTTP Method..


Now I am looking at something like a resource which should get called for variable number of path parameters.


For example I want my single resource class CollegeResource should be called for URIs like /rest/college, /rest/college/subject, /rest/college/subject/teachers, and it can go up to any number of path parameters.


If I know the number of path params in prior then I could have achieved this using something like this /rest/college/{param1}/{param2}. But number of path params is unknown. So I felt (I may be wrong) can not use this approach.


One more way I could still use is using query parameters. But I want this to be available to be as path params only.


Is there any way to get this done using apache wink with any other configuration ? If not in Apache wink, any other JAX-RS implementaions support this ?




Aucun commentaire:

Enregistrer un commentaire