Hi,
Have you thought about using subresource locators? I.e. instead of
repeating {namespace} in every resource path, have a single root
resource with that path parameter and make the rest available through
subresource locators?
Other option would be to have you servlet filter handle the url
replacement in the output stream as well.
Martin
On 20.6.2011 21:43, Maciek wrote:
> Hi,
>
> we are developing a web application that uses Jersey as a JAX-RS
> implementation. At the moment one of our requirements is to introduce
> a multi-tenancy into the application. Since we don't have full control
> over the domain we have decided to "namespace" the application. Just
> as an example: assuming that to this point some page is reachable at
> "http://domain.com/search.html", after the introduction of the
> multi-tenancy the same page is going to be at
> "http://domain.com/{namespace}/search.html".
>
> We have created the javax.servlet.Filter that wraps the
> javax.servlet.http.HttpServletRequest and strips the first "directory"
> in the path - the namespace. Both getServletPath() and getRequestURI()
> methods return the modified values. We thought that this way the whole
> application should work correctly without changes and only few DAOs
> will have to honor the namespace of the request.
>
> With such a filter the static content is served correctly, JAX-RS
> resource matching also works without problems. The problem is with the
> URIs that the services generate inside theirs outputs using
> javax.ws.rs.core.UriInfo - they don't contain the namespace part. Of
> course we could have modify all our root resource classes, so that
> they ignore the namespace in the path, but we prefer a more generic
> solution. Do you have any hints how to solve the above problem?
>
> Thanks