This content has been marked as final.
Show 5 replies
-
1. Re: Producing dependent instance into SessionScoped bean
nickarls Feb 1, 2010 9:47 AM (in response to lfryc)I think it's because the injection of toInject into InjectionConsumer happens at first reference to InjectionConsumer and since it's a dependent value, it's not proxied and you end up with the initial value
-
2. Re: Producing dependent instance into SessionScoped bean
alin.heyoulin.qq.com Feb 1, 2010 9:53 AM (in response to lfryc)Try this:
1. Use InjectionConsumer as RequestScoped
2. Call InjectionConsumer.getFromInject within a requestScope
3. Call InjectionProvider.setToInject(othervalue
)
4. Call InjectionConsumer.getFromInject within an other requestScope -
3. Re: Producing dependent instance into SessionScoped bean
lfryc Feb 1, 2010 10:09 AM (in response to lfryc)Is this the good solution?
@Named @SessionScoped public class InjectionConsumer implements Serializable { @Inject Instance<String> toInject; public String getFromInject() { return toInject.get(); } }
It seems work for me.
-
4. Re: Producing dependent instance into SessionScoped bean
nickarls Feb 1, 2010 10:10 AM (in response to lfryc)@Inject @ToInject Instance<String> toInject
and toInject.get() could also be an option(?)
-
5. Re: Producing dependent instance into SessionScoped bean
nickarls Feb 1, 2010 10:12 AM (in response to lfryc)I started writing my response before you posted, honest! ;-)