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: 2493
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
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 640
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.

Brian.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Size of a Part's client area during PostConstruct
Next Topic:Detaching and joining views
Goto Forum:
  


Current Time: Tue Sep 19 11:53:13 GMT 2017

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

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