users@jersey.java.net

[Jersey] Re: Use Guice to inject something into an XmlAdapter

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Tue, 02 Aug 2011 15:03:53 +0200

Hi Alexander,

I apologize for delayed response.

Could you please send out the test project,
so that i can have a look?

Thanks,

~Jakub

On 9.7.2011 12:51, Alexander Zapi wrote:
> Hi!
>
> I have implemented an XmlAdapter and I would like that Guice injects something (e.g. an EntityManager) when Jersey instantiates this XmlAdapter. Is this possible? How to do this?
>
> I want my adapter to look like this:
>
> public class CustomerAdapter extends XmlAdapter<Long, Customer> {
>
> @Inject
> public CustomerAdapter(Something s) {
> {
> // do something with s
> }
> }
>
>
> I want Jersey/Guice to inject an instance of Something. When I try out this code, I get a runtime exception that a no-args constructor for CustomerAdapter is missing.
>
>
> Perhaps somebody can help me, thank you!
> Alex