users@jersey.java.net

[Jersey] Re: How to configure custom providers/resources using ResourceConfig

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Tue, 02 Aug 2011 11:52:20 +0200

Hi,

On 1.8.2011 19:28, charlesk wrote:
> Thanks Jakub. I'll try that.
>
> Another question that may be related. I would also like to configure Jersey
> filters (that implements ContainerRequestFilter). Is there any specific
> ResourceConfig implementation class that I should be using for configuring
> filters?

You can use the same class (PackagesResourceConfig). You only need to use
the constructor taking a property bag [2].

> For an example, I have something like this (In servlet web.xml). I like to
> configure this in ResourceConfig so that I can inject using @Context
> ResourceConfig _context in my Jersey filter.
Do you mean Servlet filter? Jersey's ServletContainer could also be used
as a Servlet filter
and could be configured in a similar way as if it was used as a Servlet
(via parameters).
You can also extend from it. To get inspired, you may want to look at
[3] (see [4] for the source code).

Does it cover your use case?

~Jakub

[2]http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/core/PackagesResourceConfig.html#PackagesResourceConfig%28java.util.Map%29
[3]http://jersey.java.net/nonav/apidocs/latest/contribs/jersey-spring/index.html
[4]http://java.net/projects/jersey/sources/svn/content/tags/jersey-1.8/jersey/contribs/spring/src/main/java/com/sun/jersey/spi/spring/container/servlet/SpringServlet.java

> <filter>
> <filter-name>HelloWorldFilter</filter-name>
>
> <filter-class>yjava.ws.examples.helloworld.HelloWorldFilter</filter-class>
> <init-param>
> <param-name>helloworldfilter.disabled</param-name>
> <param-value>false</param-value>
> </init-param>
> <init-param>
> <param-name>format.allow</param-name>
> <param-value>foo,bar</param-value>
> </init-param>
> </filter>
>
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/How-to-configure-custom-providers-resources-using-ResourceConfig-tp6635080p6641825.html
> Sent from the Jersey mailing list archive at Nabble.com.
>