|
From: Solomon D. <sd...@gm...> - 2008-10-08 19:40:27
|
The current Spring/RESTEasy integration is pretty slick. I'd like to
propose a couple of changes that might make it even better.
1) ResourceExposingService: Expose a spring bean with jax-rs annotations at
different contexts. Think of it as writing code for a sub-resource, and
exposing it via Spring.
Most of the time, one Class maps to one configuration (either Singleton or
Prototype). Sometimes, it may be convenient to have two or more
configurations of the same Class. For example, take a GenericCRUDResource
which does generic crud operations on a specific JPA Entity type which is
also JAXB annotated - GET "/" maps some group list functionality;
GET/PUT/DELETE "/{id} and POST "/" would do the appropriate CRUD operation.
All that GenericCRUDResource needs is a specific Domain Class, an
EntityManager and a unique basePath.
We can do the following in the Spring XML:
<!-- create & configure a book and author GenericCRUDResource -->
<bean class="com.jboss.resteasy.<something>.ResourceExposingService">
<property name="resource" ref="bookResource" />
<property name="basePath" value="/books/" />
</bean>
<!-- spring namespace wrapper -->
<resteasy:expose resource="authorResource" basePath="/authors/" />
The processing of ResourceExposingService is pretty straight forward to add
to SpringBeanProcessor
else if (bean instanceof ResourceExposingService)
{
ResourceExposingService exposer = (ResourceExposingService) bean;
registry.addSingletonResource(exposer.getResource(),
exposer.getBasePath());
}
2) Having RestEasy configured purely in spring, including
configuration/management of the Registry and Dispatcher in Spring, plus
integration with the Spring MVC framework - I'll fill in this idea in a
future email.
What do you think about item 1?
-Solomon
|