|Re: @Inject calls context function but ContextInjectionFactory.make does not. Why? [message #1386282 is a reply to message #1386279]
||Mon, 16 June 2014 10:53
| Thomas Schindl
Registered: July 2009
On 16.06.14 12:46, Andreas Sewe wrote:|
>> You get what you asked for -
>> - requests to create an instance of IPrivacySettingsService. I suppose
>> what you wanted to make is an instance of an Object that retrieves the
>> If you really want to obtain an instance of IPrivacySettingsService
>> you'd simply do eclipseContext.get(IPrivacySettingsService.class).
> Of course! Thank you.
>> One more warning - the
>> EclipseContextFactory.getServiceContext(bundleContext) - will give you
>> different context instances for each BundleContext!
> Yes, but the OSGi service should be available in all of them, so I won't
> run into problems, I think.
> Anyways, what's the preferred way to obtain something from the Eclipse
> context from old E3 code? That's where I currently use
The preferred way is to grab the
org.eclipse.e4.ui.workbench.IWorkbench-Instance from the OSGi-Service
registry and/or to get the local IEclipseContext you can use
IServiceLocator s = ...;
IEclipseContext ctx = s.getService(IEclipseContext.class);
which IMHO is the best way because then you get the correct context for
your usage e.g. the one on the part, perspective, window, ... .
Powered by FUDForum
. Page generated in 0.01506 seconds