I switched to using @Inject and things are working fine now.
Thanks,
Sam
On Dec 23, 2008, at 6:45 PM, Sam Pullara wrote:
> Hi All,
>
> I'm trying to use Injectable in Jersey 1.0.1 to pass in my JPA
> EntityManager. Based on all the stuff that I have read I was lead
> to believe that something like this would work:
>
> @Provider
> public static class EntityManagerProvider extends
> PerRequestTypeInjectableProvider<Context, EntityManager> {
>
> public EntityManagerProvider() {
> super(EntityManager.class);
> }
>
> public Injectable<EntityManager>
> getInjectable(ComponentContext ic, Context context) {
> return new Injectable<EntityManager>() {
> public EntityManager getValue() {
> return ems.get();
> }
> };
> }
> }
>
> When it starts up it does find it and register it:
>
> INFO: Provider classes found:
> class com.sampullara.chatservice.web.JPAFilter$EntityManagerProvider
>
> And even instantiates an instance of it. However, when my Resource
> gets constructed:
>
> public Users(@Context EntityManager em) {
> this.em = em;
> entity = "User";
> }
>
> It just passes in null and I never get a callback. What am I doing
> wrong?
>
> Thanks,
> Sam
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>