Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » IEclipseContext.get() does not return a value for @Creatable
IEclipseContext.get() does not return a value for @Creatable [message #1693934] Wed, 29 April 2015 11:40 Go to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Hi,

I have question regarding the injection mechanisms.

I have a class that I annotated with @Creatable @Singleton. Now I want to get the created instance. It works if I use it via injection, but it does not work if I try to get it via IEclipseContext#get().

Now I assume the reason why the created instance is not available in the context is, that otherwise the platform/DI container can not ensure that the instance is a singleton. In the context hierarchy you would be able to set another value. But shouldn't IEclipseContext#get() have the same semantics as @Inject?

I tried to debug and IEclipseContext#get() searches the context hierarchy. But it does not try to access the created singletons in any way. Is this by design? Would an additional check for the singleton instance hurt in any way?

I'm just trying to understand the mechanics here.

Greez,
Dirk
Re: IEclipseContext.get() does not return a value for @Creatable [message #1693983 is a reply to message #1693934] Wed, 29 April 2015 18:10 Go to previous message
Eclipse UserFriend
The injector is separate from contexts. The injector uses a set of object suppliers to obtain values to be injected into some class. The injector and contexts are linked by configuring the injector to use a ContextObjectSupplier to obtain values from a context.

The @Creatable and @Singleton annotations are managed entirely by the injector. See the reference to Singleton.class in InjectorImpl#internalMake and the reference to Creatable.class in step 5 of InjectorImpl#resolveArgs.

Brian.
Previous Topic:Size of a Part's client area during PostConstruct
Next Topic:Model persistence - transient?
Goto Forum:
  


Current Time: Fri Apr 19 22:13:16 GMT 2024

Powered by FUDForum. Page generated in 0.03199 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top