users@jersey.java.net

[Jersey] Spring and Jersey Integration

From: Ricardo Borillo <Ricardo.Borillo_at_si.uji.es>
Date: Tue, 25 Jan 2011 12:02:50 +0100

Hi all,

I'm using SpringServlet with Jersey 1.4.
For the system design, i have DAO objects to access data and model objects
to implement my business logic:

@Component
@XmlRootElement
public cass Sample {
   @Autowired
   public MyDAO myDAO;
   ... methods and attributes ...

   public void update()
   {
       myDAO.update(this);
   }
}

My service layer access the model and the model access data through DAO
implementation.

In the service layer, i have my jersey methods:

    @PUT
    @Path("{id}")
    @Produces(MediaType.TEXT_XML)
    @Consumes(MediaType.TEXT_XML)
    public Response update(Sample sample)
    {
            sample.update();
            return Response.ok(sample).build();
    }

The problem is that the bean "sample" received by the previous method, is
not a Spring Bean and the collaborators are not autowired ...
Is it possible to get from Jersey a class "Sample" instance autowired by
Spring?

I try to add InjectParam in the method, but i only get a new instance
without the HTTP data from client:

    @PUT
    @Path("{id}")
    @Produces(MediaType.TEXT_XML)
    @Consumes(MediaType.TEXT_XML)
    public Response update(@InjectParam Sample sample)

Thanks in advance

---
Salut,
====================================
Ricardo Borillo Domenech
http://xml-utils.com
twitter: @borillo