And i have a class which manage my views like that:
public class Manager
@Inject private A a;
@Inject private B b;
When I make A and B visible at least one time, i can instantiate this class without problem, but when those classes were never been visible, i got the message : "no actual value was found for the argument" for the Injected classes. I figured out that this comes when the class wasn't instantiated and never got inserted on context, but even when i force the instantiation, i got the error.
I don't know if I make myself clear but I would like to know what process the framework do to insert the class on context, or if there is something i'm doing wrong.
I don't get it. Without those notes I can't inject my classes.
Classes annotated with @Creatable will be automatically created by the injector if an instance was not present in the injection context. The automatically-generated instance is not stored in the context.
Joseph Carroll Messages: 174 Registered: May 2012 Location: Milwaukee, WI
The framework takes care of it. @Creatable is for resources not in the context *AND* not referenced in the running model. Your part class is referenced in your MPart from the running model. The framework automatically creates it for you.
Sopot Cela Messages: 597 Registered: December 2010
MParts usually are created by the framework (renderer). The creation involves instantiating the contribution object (the URI class), constructing the runtime representation of MPart and putting it to the context. This creation follows the lazy loading approach in that only parts that are visible are created, otherwise Eclipse would start in 10 minutes if it had to instantiate each and every view in the model (which is an MPart). So it creates only what is visible.
The 'one time visible' situation may happen because when you try to force the creation through @Creatable the contribution object is not created. Usually it is not a good idea to force the creation of parts when they are not visible yet, though it depends on the case. If you want to do some form of processing on the part you can register a listener (IEventBroker) on part creation and do your stuff there, and let the renderer (LazyStackRenderer) decide when to instantiate the part.
That said, @Creatable is used to do a CIF.make on a class and @Singleton is used to prevent multiple instances in a given scope.