How to inject a service, which has the IEventBroker injected in it, in an Eclipse part [message #1005772] |
Mon, 28 January 2013 11:45  |
Eclipse User |
|
|
|
I want to inject a service into my Eclipse part. In itself this is not a problem, I can use a declarative OSGi service for this. The problem arises when I inject the IEventBroker in my service by means of an Eclipse addon. The addon has a hookListeners method which makes an instance of my service and sets it in the Eclipse context. The service that is injected in my Eclipse part is however another instance with a null IEventBroker. How can I make sure that the service instance which is set in the Eclipse context by the addon, is injected in my Eclipse part? Or is there a better way of achieving the above?
|
|
|
|
|
Re: How to inject a service, which has the IEventBroker injected in it, in an Eclipse part [message #1005959 is a reply to message #1005947] |
Tue, 29 January 2013 07:10  |
Eclipse User |
|
|
|
Yes, and IIRC further more the interface used as a key is transformed internally to a string and put in the context as X.getClass.getName(). The context is string based and you can also put and retrieve keys using custom strings like context.put("CoolInterface",interfaceImpl); and retreive it with context.get or @Inject @Named("CoolInterface"). This idea is implemented in the selection retreival @Inject @Named(IServiceConstants.ACTIVE_SELECTION). the ISC.ACTIVE_SELECTION is just a custom string like CoolInterface.
|
|
|
Powered by
FUDForum. Page generated in 0.05249 seconds