users@jersey.java.net

Filter Spring beans by package before registering as resource

From: John B Staley <john.b.staley_at_ictl.nu>
Date: Mon, 26 Jul 2010 16:22:05 +0200

Hi,

I'm using Jersey and basically what I want to accomplish is having
multiple servlet mappings deployed within the same Spring context with
each containing a different set of Spring beans.

Currently each SpringServlet will register every Spring annotated root
resource. I would like to have a way of specifying what package should
belong to each servlet, i.e. like this (but it scan the Spring beans
instead of scanning the classpath)

<servlet>
   <servlet-name>jersey-one</servlet-name>
   <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
   <init-param>
      <param-name>com.sun.ws.rest.config.property.packages</param-name>
      <param-value>my.package.for.jersey.one</param-value>
   </init-param>
</servlet>
<servlet>
   <servlet-name>jersey-two</servlet-name>
   <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
   <init-param>
      <param-name>com.sun.ws.rest.config.property.packages</param-name>
      <param-value>my.package.for.jersey.two</param-value>
   </init-param>
</servlet>

Any hints on how I can accomplish this?

Thanks in advance,

Regards,
John