(and of course you'd need to control whether your injection is of a
Provider<NSEM>, depending on when you expect your class to have its members
injected)


On Fri, Mar 25, 2011 at 3:34 PM, Fred Faber <[email protected]> wrote:

> Seems like a standard case, as in:
>
> bind(NoSqlEntityManager.class)
>   .toProvider(new Provider<NoSqlEntityManager>() {
>      @Override public NoSqlEntityManager get() {
>          NoSqlMgrFactory factory = NoSqlPersistence.createMgrFactory();
>          return factory.createMgr();
>     }
>    }).in(Singleton.class);
>
> or
>
> @Provides @Singleton provideNoSqlEntityManager() {
>      NoSqlMgrFactory factory = NoSqlPersistence.createMgrFactory();
>      return factory.createMgr();
> }
>
> Fred
>
> On Fri, Mar 25, 2011 at 2:43 PM, deanhiller <[email protected]>wrote:
>
>> Throughout our program on top of Gemfire we have many objects with
>> this field
>>
>> @Inject
>> private NoSqlEntityManager map;
>>
>> Now, this code generates an instance we want bound to that interface
>>
>>      NoSqlMgrFactory factory = NoSqlPersistence.createMgrFactory();
>>      NoSQLEntityManager mgr = factory.createMgr();
>>
>> BUT BUT BUT, we cannot call these methods in the Guice Module
>> configure method!!!!  We can only call these methods AFTER the
>> Guice.injector() call returns.  Is there a way in the Module, I can
>> bind a Provider that will create this SINGLE instance of my
>> NoSQLEntityManager at a later time(after the Injector is fully
>> realized)??
>>
>> MORE Detail on why if you need: createMgrFactory scans all classes for
>> annotations and sets up listeners that the application developer wrote
>> that have Guice dependency on them, and the injector is called in
>> those so if createMgrFactory is in the Guice Module, the app
>> developers get a NullPointer since there is no injector yet.
>>
>> thanks,
>> Dean
>>
>> --
>> 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.
>>
>>
>

-- 
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