2009/4/1 [email protected] <[email protected]>:
>
> On Apr 1, 3:42 am, James Strachan <[email protected]> wrote:
>> When I saw the getProvider() methods on Encounter I figured this was
>> the way of asking for a provider from inside an InjectionListener?
>
> When we were designing the API, the intention was to invalidate the
> Encounter when hear() returned. Unfortunately, I didn't actually write
> any code to do the invalidation. I'll do this! As it's written now, if
> you call getProvider() on an Encounter after hear() returns, it'll
> return a perpetually broken Provider. That provider will never have a
> working get() method.
>
> Can you do your getProvider() calls within hear()? That way you'll get
> much better performance: InjectableType.Listener gets invoked once per
> type, whereas hear() gets invoked once per instance. If you do all of
> your potentially-expensive Provider lookups at type-discovery time,
> things should perform reasonably.
I've just done that. I still get the same exception though. (See below).
I'm thinking we do need to defer looking up objects until as late as
possible; so that the injector can completely initialise itself before
we start looking up new objects? Or do you not think thats an issue?
1) Error notifying InjectableType.Listener
org.guiceyfruit.support.abstractguiceyfruitmodul...@dd5a3d (bound at
org.guiceyfruit.support.AbstractGuiceyFruitModule.bindAnnotationMemberProvider(AbstractGuiceyFruitModule.java:70))
of org.guiceyfruit.jsr250.ResourceTest$MyBean.
Reason: java.lang.IllegalStateException: This Provider cannot be used
until the Injector has been created.
at org.guiceyfruit.jsr250.ResourceTest$1.configure(ResourceTest.java:37)
1 error
at
com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:332)
at
com.google.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:152)
at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:105)
at com.google.inject.Guice.createInjector(Guice.java:92)
at com.google.inject.Guice.createInjector(Guice.java:69)
at com.google.inject.Guice.createInjector(Guice.java:59)
at
org.guiceyfruit.jsr250.ResourceTest.testResourceInjection(ResourceTest.java:33)
Caused by: java.lang.IllegalStateException: This Provider cannot be
used until the Injector has been created.
at
com.google.inject.internal.Preconditions.checkState(Preconditions.java:142)
at com.google.inject.spi.ProviderLookup$1.get(ProviderLookup.java:87)
at
org.guiceyfruit.support.AbstractGuiceyFruitModule$2.get(AbstractGuiceyFruitModule.java:63)
at
org.guiceyfruit.support.AbstractGuiceyFruitModule$2.get(AbstractGuiceyFruitModule.java:61)
at
org.guiceyfruit.support.AbstractGuiceyFruitModule$3.hear(AbstractGuiceyFruitModule.java:86)
at
com.google.inject.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:89)
at
com.google.inject.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:35)
at
com.google.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:44)
at
com.google.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:42)
at
com.google.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at
com.google.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:528)
at
com.google.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:398)
at
com.google.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2031)
at com.google.inject.internal.FailableCache.get(FailableCache.java:46)
at
com.google.inject.ConstructorInjectorStore.get(ConstructorInjectorStore.java:59)
at
com.google.inject.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:55)
at
com.google.inject.InjectorImpl.initializeBinding(InjectorImpl.java:378)
at com.google.inject.BindingProcessor$1$1.run(BindingProcessor.java:163)
at
com.google.inject.BindingProcessor.initializeBindings(BindingProcessor.java:209)
at
com.google.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:120)
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---