If you want to create an instance of a class by yourself but want to inject stuff from e4 then you can use stuff like
YourClass instance = ContextInjectionFactory.make(YourClass.class, context);
The context is most of the time the inject
@Inject private IEclipseContext context;
But some classes have the need to have some values passed to the constructor or injected into the fields which are not part of the IEclipseContext instance.
You can pass an additional context to the
YourClass instance = ContextInjectionFactory.make(Yourclass.class, context, additionalContext);
But where to get this additional context? Eclipse e4 provides a
EclipseContextFactory class which lets you create fresh new context instances or new context instances based on existing contexts.
IEclipseContext additionalContext = EclipseContextFactory.create();
Now you can put your values into the context with the
Default is to lookup the injected object by its class if your are plainly using
If you have to inject multiple objects with the same class or want to be sure that you get a specific object injected you can use the
@Named annotation. You add the value to the context with
@Inject @Named("inputUri") private String inputUri;