The easy answer: consider using Warp Persist (http://www.wideplay.com) for
guicy persistence. Although support for multiple persistence units is not
implemented in 1.0, we have have experimental support for it in the trunk.
If you depend on that functionality let me know and we will help you get
started.

The other answer would be yes, you can do that. Have a look at how Guice
implements Names.named(...). You basically have to bind to annotation
instances instead of types, and you do that by subclassing the annotation
and binding to an instance of that subclass.

Hope this helps,
Robbie

On Sun, Aug 31, 2008 at 6:59 PM, elek <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> Is there any way to inject dynamic values to a class according to the
> annotation parameters with Guice?
> Eg.: I have the following fields in a class:
>
> @PersistenceContext(unitName="Test1PU")
> EntityManager em1;
>
> @PersistenceContext(unitName="Test2PU")
> EntityManager em2;
>
> An I would like to inject different EntityManager instances.
> Unfortunately I can't access the annotation or the original Field over
> the the Provider interface:
>
>
> binder.bind(EntityManager.class).annotatedWith(PersistenceContext.class).toProvider(new
> EntityManagerProvider(directory, ???unitName value???));
>
> Is there any solution for it?
>
> Thanks:
> m.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to