Hi Denis,
If you have one root resource class in one package then you can use
the package scanning configuration. I presume you know about?
There is currently no direct support for what you want. But you can
easily extend the Jersey DefaultResourceConfig [1], off the top of my
head, as follows:
public class ClassesResourceConfig extends DefaultResourceConfig {
public ClassesResourceConfig(Map<String, Object> props) {
String classNamesProperty = (String)props.get("classes");
String[] classNames = getElements(new String[]
{ classNamesProperty });
ClassLoader cl =
Thread.currentThread().getContextClassLoader();
for (String className : classNames) {
getClasses.add(Class.forName(className, false, cl));
}
}
}
The "props" parameter will contain all the init-params and you can get
the init-param declaring the ";" separate list of fully qualified
class names. Then you can do:
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>x.y.z.ClassesResourceConfig</param-value>
</init-param>
<init-param>
<param-name>classes</param-name>
<param-
value>org.foo.rest.MyApplication1;org.foo.rest.MyApplication2</param-
value>
</init-param>
Paul.
[1]
https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.2/api/jersey/com/sun/jersey/api/core/DefaultResourceConfig.html
On Mar 23, 2009, at 3:30 PM, Denis wrote:
> Hi all,
>
> Do you know if there's a way to deploy just one root resource class?
> I've seen that we can extend the jax-rs Application class to declare
> a root resource class but I was wondering
> if those classes cannot be declared in the web.xml like that:
>
> <web-app>
> <servlet>
> <servlet-name>Jersey Web Application</servlet-name>
> <servlet-
> class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-
> class>
>
> <init-param>
> <param-name>...</param-name>
> <param-
> value>org.foo.rest.MyApplication1;org.foo.rest.MyApplication2</param-
> value>
> </init-param>
>
> </servlet>
>
>
> Regards,
>