Thanks for the feedback, James. Sounds like I need to update the injectable
type listener docs to make it clear that you need to get your providers,
etc., out of the Encounter and pass those to the injection listener.

Like Jesse said, you actually have all of the information up front and can
do the work once per type instead of once per instance (just like we do
elsewhere in Guice, hence its good performance). This is what I was talking
about when I said that the injectable type listener should create a list of
of method/provider pairs and pass it to the injection listener. At run time,
the injection listener will just iterate over that list, get an object from
the provider and pass it to the method.

On the bright side, my hope is that this will be the world's fastest EJB
impl, at least after we performance tune Guice to get back to version one
levels.

Bob

On Wed, Apr 1, 2009 at 3:42 AM, James Strachan <[email protected]>wrote:

>
> I've nearly got a first spike of the JSR 250 support for @Resource
> going in GuiceyFruit using the current trunk of Guice. But I just
> banged my head when attempting, inside
> InjectionListener.afterInjection() to get the Encounter.getProvider()
> - to try look up a dependent object that I need.
>
> For example for JSR 250 the InjectionListener needs to get a JNDI
> Context object - which I was hoping to use Guice to dependency inject.
> When I saw the getProvider() methods on Encounter I figured this was
> the way of asking for a provider from inside an InjectionListener?
>
> Maybe I'm using the wrong API or maybe there's a small bug? Or maybe
> its just not possible to inject an InjectionListener? (The latter
> could be true due to ordering issues).
>
> FWIW here's the stack trace if it helps... Anyone got any ideas?
>
> .
> com.google.inject.ProvisionException: Guice provision errors:
>
> 1) Error notifying InjectionListener
> org.guiceyfruit.support.abstractguiceyfruitmodule$...@603bdc of
> org.guiceyfruit.jsr250.ResourceUsingBaseModuleTest$MyBean.
>  Reason: java.lang.IllegalStateException: This Provider cannot be used
> until the Injector has been created.
>  while locating org.guiceyfruit.jsr250.ResourceUsingBaseModuleTest$MyBean
>
> 1 error
>        at com.google.inject.InjectorImpl$4.get(InjectorImpl.java:768)
>        at com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:794)
>        at
> org.guiceyfruit.jsr250.ResourceUsingBaseModuleTest.testResourceInjection(ResourceUsingBaseModuleTest.java:56)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
> 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$1.afterInjection(AbstractGuiceyFruitModule.java:85)
>        at
> com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:97)
>        at
> com.google.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:100)
>        at
> com.google.inject.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:45)
>        at
> com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:813)
>        at
> com.google.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:42)
>        at com.google.inject.Scopes$1$1.get(Scopes.java:54)
>        at
> com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:48)
>        at com.google.inject.InjectorImpl$4$1.call(InjectorImpl.java:759)
>        at
> com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:805)
>        at com.google.inject.InjectorImpl$4.get(InjectorImpl.java:755)
>
> If its any help the source of the code using the InjectionListener /
> Encounter is here...
>
> http://code.google.com/p/guiceyfruit/source/browse/trunk/guiceyfruit-core/src/main/java/org/guiceyfruit/support/AbstractGuiceyFruitModule.java
>
> e.g. this is the line causing the issue:
>
> http://code.google.com/p/guiceyfruit/source/browse/trunk/guiceyfruit-core/src/main/java/org/guiceyfruit/support/AbstractGuiceyFruitModule.java#63
>
> when we attempt to inject an AnnotationMemberProvider instance so we
> can inject a member
>
> http://code.google.com/p/guiceyfruit/source/browse/trunk/guiceyfruit-core/src/main/java/org/guiceyfruit/support/AbstractGuiceyFruitModule.java#85
> --
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to