|
|
|
|
|
Re: E4 DI best practices [message #840793 is a reply to message #834695] |
Tue, 10 April 2012 10:14  |
Eclipse User |
|
|
|
Hi,
No you can't get access to applications IEclipseContext in an
OSGi-Service. The problem is that while in a desktop environment there's
(very likely a 1:1 relationship between a running OSGi and Application)
but as soon as you e.g. think about RAP this 1:1 relations is not true
any more.
The question now is why you are using the OSGi-Service to interact with
your application?
Tom
Am 02.04.12 11:18, schrieb Laura V:
> Lars, Tom, a question
> I tried the code in your tutorial, seems logic but in my case it doesn't
> work.
>
> I need to use my PartHelper class in an OSGI Service.
> My PartHelper class needs the following injected variables:
> @Inject private EModelService modelService;
> @Inject private MApplication application; @Inject private
> EPartService partService;
>
> Tried to put this code in my service:
>
> Bundle bundle = FrameworkUtil.getBundle(getClass());
> BundleContext bundleContext = bundle.getBundleContext();
> IEclipseContext eclipseCtx =
> EclipseContextFactory.getServiceContext(bundleContext);
> ContextInjectionFactory.make(PartHelper.class, eclipseCtx);
>
> The MAKE doesn't work, it can't inject the parts obviously because I am
> in the wrong context. How can I access the application context from
> here? Is there a way to do it at all?
> Thanks
>
> Laura
>
|
|
|
Powered by
FUDForum. Page generated in 0.04335 seconds