Search code examples
javajerseymulti-tenantdefault-parameters

Default Jersey query parameter


I have Jersey client with a lot of functionality and now requirements are changed and I need to implement multitenancy for it.

I tried to implement automatic tenancy resolving on server side using URL of client that sent the request, but method getRemoteHost() from ServletRequest class in some cases returns only IP, but not a domain name, so it seems that I need to implement multitenancy feature also on client side and pass some parameters in query.

Is it possible to set default query parameter for the whole Jersey client instance without adding it into every method?


Solution

  • Yes - add a client filter that adds the parameter to every outgoing request - see http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/client/filter/ClientFilter.html