users@jersey.java.net

Re: Integrating Jersey & Hibernate

From: Martin Probst <mail_at_martin-probst.com>
Date: Tue, 22 Apr 2008 11:37:40 +0200

Hi,

>> @Paul: is there a reason why service() is final? If not, I could
>> simply extend ServletContainer, no wrapping necessary.
> Changed in the trunk. I have a habit of making things final unless
> otherwise required!

Cool.

> You said in another email:
>
>> The problem is that I want "BookResource" to directly map to a
>> persistent class, so I can't have it being created by Jersey - it
>> needs to be loaded by Hibernate. Maybe I can hook into the creation
>> of the resource (by having my own ComponentProvider) and access the
>> path parameter to load the instance from persistence?
>
> I presume you manage to solve that with what you did above?

Not quite, see my other email in thread "One Resource class for two
URLs". The solution in this thread only worked with non-root (nested)
resources that are created "manually" from within a root resource that
represents a collection of them. Combining this with a custom
ComponentProvider as described in the other thread allows both -
properly injected resources loaded from Hibernate from within a root
resource and properly injected, Hibernate-backed root resources
themselves.

Regards,
Martin