REST is becoming a popular approach for building web services, and the Jersey reference implementation is made to deal with the intricacies of this approach in the Java world. Marc Hadley takes a look at how to mesh Jersey with the Spring framework.
Jersey is based on annotated classes whereas Spring is based on named beans. The Spring ResourceProvider needs to map a class name to a Spring bean name which is accomplished with the initBeanName method: protected synchronized void initBeanName() { if (beanName==null) { String names[] = springContext.getBeanNamesForType(resourceClass); if (names.length==0) throw new RuntimeException("No configured bean for "+resourceClass.getName()); else if (names.length>1) throw new RuntimeException("Multiple configured beans for "+resourceClass.getName()); beanName=names[0]; } } I couldn't see any straightforward way to determine which bean to use for a given resource class if there is more than one defined at the top level so the provider requires a single top-level bean for each resource class.
Read Marc's entire post: http://weblogs.java.net/blog/mhadley/archive/2007/09/integrating_jer.html