On Dec 15, 2008, at 4:12 PM, Ray Krueger wrote:
>> BTW because your resource classes are registered using Spring you
>> do not
>> have to register them using Jersey. Thus if you want you can remove:
>>
>> <init-param>
>> <param-name>com.sun.jersey.config.property.packages</param-name>
>> <param-value>org.freebxml.omar.server.interfaces.rest</param-value>
>> </init-param>
>>
>> from your web.xml and class scanning will only be performed by
>> Spring.
>
> Does that require any other special annotations? Or is @Path enough?
@Path is sufficient. The life-cycle/scope is determined by the Spring-
based annotations.
If interested the code that does this from
SpringComponentProviderFactory is presented at the end of the email.
JavaDoc for the Spring Servlet is here:
https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.1/api/contribs/jersey-spring/com/sun/jersey/spi/spring/container/servlet/package-summary.html
Paul.
private void register(ResourceConfig rc,
ConfigurableApplicationContext springContext) {
String[] names = springContext.getBeanDefinitionNames();
for (String name : names) {
Class<?> type =
ClassUtils.getUserClass( springContext.getType(name) );
if (ResourceConfig.isProviderClass(type)) {
LOGGER.info("Registering Spring bean, " + name +
", of type " + type.getName() +
" as a provider class");
rc.getClasses().add(type);
} else if (ResourceConfig.isRootResourceClass(type)) {
LOGGER.info("Registering Spring bean, " + name +
", of type " + type.getName() +
" as a root resource class");
rc.getClasses().add(type);
}
}
}