On Dec 8, 2009, at 3:37 PM, Robert Naczinski wrote:
> Hi,
>
> how I can use com.sun.jersey.api.core.DefaultResourceConfig ?
>
> It seems to be a provider of properties. I found this snipet:
>
> <servlet >
>
> <servlet-name>Jersey Web Application</servlet-name >
>
> <servlet-
> class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-
> class
>
> <init-param>
>
> <param-
> name>com.sun.jersey.config.property.resourceConfigClass</param-name>
>
> <param-value>com.sun.jersey.api.core.DefaultResourceConfig</
> param-value>
>
> </init-param>
>
> <init-param>
>
> </servlet>
>
The above will not work because Jersey will instantiate
DefaultResourceConfig and it will contain no root resource classes.
You need to do something like:
package foo;
public class MyConfig extends DefaultResourceConfig {
...
}
and then declare "foo.MyConfig" as the value of the
"com.sun.jersey.config.property.resourceConfigClass" property.
> How I can get this propeties in my resources?
>
Independently of how you configure the Jersey ServletContainer you can
inject ResourceConfig:
@Context ResourceConfig rc
To get access to properties/features. All servlet init-params will be
included as properties. Note that the instance of the ResourceConfig
injected is not guaranteed to be the same class as the class
registered in the web.xml.
If you are writing a component that needs to work on the client and
server side you can inject:
@Context FeaturesAndProperties fp
Paul.