Community
Participate
Working Groups
I think it would be useful to add the 'appendToContext' parameter for the Creatable annotation and put the new instance of the 'Creatable' object to the current IEclipseContext instance, when the parameter is set to true. When the class is annotated with the Singleton it should be the main application context
I'm not really a big fan of Creatable to begin with, as we can't tell if something has been instantiated for a specific object instance injection or provided by the context. So now that you'd like the option to stash a Creatable in a context, I have to ask why? What specific usecase are you trying to solve? How often does this come up? We usually seek fine grained control over where our objects are instantiated. PW
(In reply to Paul Webster from comment #1) > I'm not really a big fan of Creatable to begin with, as we can't tell if > something has been instantiated for a specific object instance injection or > provided by the context. > > So now that you'd like the option to stash a Creatable in a context, I have > to ask why? What specific usecase are you trying to solve? How often does > this come up? > > We usually seek fine grained control over where our objects are instantiated. > > PW It is some kind of shortcut for user. Having the class annotated with @Creatable(appendToContext=true) they can directly retrieve such instance from the context without performing additional context registration steps. From my point of view it simplifies the source code. Daniel
(In reply to Daniel Rolka from comment #2) > > It is some kind of shortcut for user. Having the class annotated with > @Creatable(appendToContext=true) they can directly retrieve such instance > from the context without performing additional context registration steps. > From my point of view it simplifies the source code. I'm looking for a couple of specific instances where this will be used. Right now, I don't think we use it in the platform at all, and because we want to control where items are created, we don't have a lot of opportunities. PW
There's another reason why the ability to add new objects to a specific context is necessary, the @Singleton annotation. Tom Schindl has written about it in 2009 already: https://www.eclipse.org/forums/index.php/t/797114/ For me, I'm hit by the same problem described in the forum thread, that my @Singleton is destroyed at undesired time. Since my problem is more specific, it could also help me to just let singletons be added to the root context automatically instead of the most current context. Guido
(In reply to Guido Schnepp from comment #4) > There's another reason why the ability to add new objects to a specific > context is necessary, the @Singleton annotation. Tom Schindl has written > about it in 2009 already: https://www.eclipse.org/forums/index.php/t/797114/ > > For me, I'm hit by the same problem described in the forum thread, that my > @Singleton is destroyed at undesired time. Since my problem is more > specific, it could also help me to just let singletons be added to the root > context automatically instead of the most current context. > > Guido Correction: Toms answer is from 2014, not 2009 (his registration date :-))
First question, is it still the case that a @Singleton value is not added to the application/root context? IMHO that would be a natural assumption. And additionally if you need more control in which context an object is located you should use an IContextFunction. I'm against adding an additional parameter to an annotation that is not recommended nowadays.