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: 2602
Registered: July 2012
Senior Member

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.

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
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 757
Registered: January 2012
Senior Member

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.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Size of a Part's client area during PostConstruct
Next Topic:Model persistence - transient?
Goto Forum:

Current Time: Wed Jun 20 19:31:18 GMT 2018

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

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

Back to the top