Letting a custom class inject services [message #1691156] |
Thu, 02 April 2015 15:51 |
|
Dear experts,
I would like to let my class C of plugin P inject its own stuff.
Like explained in [1], I register a service which provides a org.eclipse.e4.core.services.log.Logger (via Activator, but I tried with a DS too: same thing), then inject my class in the bundle context.
I reproduced my scenario in a minimal project, which I hereby attach for volunteers.
It has an activator (Activator.java) and a command handler (FooHandler.java) which handles the Foo Item model button and triggers the instantiation of a Foo object, which is the guy who I want to inject whatever he wants.
The error I get is pasted in [2].
If I remove the injection of the IEventBroker, I get no error but the injected IEclipseContext is null.
[1] https://www.eclipse.org/forums/index.php?t=msg&th=370090&goto=904549&#msg_904549
[2] http://dpaste.com/3TVAZYW
I tried any sort of things, all day long, can't get rid of the Logger error.
Thanks for any help, I am that close to smashing my keyboard inside the screen and runaway screaming!
@see https://www.eclipse.org/forums/index.php?t=msg&th=389240&goto=956075&#msg_956075
@see https://www.eclipse.org/forums/index.php?t=msg&th=389240&goto=928693&#msg_928693
-
Attachment: TestOSGi.zip
(Size: 10.51KB, Downloaded 118 times)
|
|
|
Re: Letting a custom class inject services [message #1691169 is a reply to message #1691156] |
Thu, 02 April 2015 18:04 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Hi,
Why are you doing this stuff at the OSGi-Level? Maybe you should start
describing your use case.
Tom
On 02.04.15 17:51, Piero Campalani wrote:
> Dear experts,
> I would like to let my class C of plugin P inject its own stuff.
>
> Like explained in [1], I register a service which provides a org.eclipse.e4.core.services.log.Logger (via Activator, but I tried with a DS too: same thing), then inject my class in the bundle context.
>
> I reproduced my scenario in a minimal project, which I hereby attach for volunteers.
>
> It has an activator (Activator.java) and a command handler (FooHandler.java) which handles the Foo Item model button and triggers the instantiation of a Foo object, which is the guy who I want to inject whatever he wants.
>
> The error I get is pasted in [2].
> If I remove the injection of the IEventBroker, I get no error but the injected IEclipseContext is null.
>
> [1] https://www.eclipse.org/forums/index.php?t=msg&th=370090&goto=904549&#msg_904549
> [2] http://dpaste.com/3TVAZYW
>
> I tried any sort of things, all day long, can't get rid of the Logger error.
> Thanks for any help, I am that close to smashing my keyboard inside the screen and runaway screaming!
>
> @see https://www.eclipse.org/forums/index.php?t=msg&th=389240&goto=956075&#msg_956075
> @see https://www.eclipse.org/forums/index.php?t=msg&th=389240&goto=928693&#msg_928693
>
|
|
|
Re: Letting a custom class inject services [message #1691191 is a reply to message #1691169] |
Fri, 03 April 2015 04:58 |
|
Thank you Tom, sure.
Use case is: I have a plugin, a driver for a network card, which asynchronously listens to incoming frames. So I want this asynchronous listener to spread the word about incoming frames on the events bus so that my client plugins can react the way they want.
The first thing that came to my mind was then to give DI powers to my driver listener so that it could require an event broker and send/post stuff with it.
Is there some more convenient alternative?
Thanks Tom and anybody who is supporting and developing this powerful technology the FLOSS way.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04783 seconds