name of the active bundle [message #1733633] |
Mon, 30 May 2016 10:28  |
Eclipse User |
|
|
|
In our, purely OSGi dynamic services based, services layer we are trying to access the name of the current bundle.
From the presentation layer we used to do bundleContext.getBundle().getSymbolicName() before, with bundleContext injected from the eclipse context:
@Inject
@Optional
private BundleContext bundleContext;
BundleContext lives in the org.osgi.framework package of org.eclipse.osgi, but sadly (for us) isn't a declarative service.
Can we access BundleContext from DS, or is there another way to find the name of the active bundle?
|
|
|
|
|
|
Re: name of the active bundle [message #1733731 is a reply to message #1733702] |
Tue, 31 May 2016 05:38   |
Eclipse User |
|
|
|
1) Let's start with the use case:
- Our e4 client has a JMS connector to a server application
- sometimes the server goes down, and then we land up in the 'onException' method of our connector
- there we want to show the user, in a message box, that the connection is lost
2) Technical challenges
- It seems logical that the jms connector is a service, and my present task is to convert it from a class in the eclipse context to a dynamic service
- The connector uses a 'GeneralErrorHandler' class (which was annotated with Creatable), invoking its handleException method to show the message to the user
- Before my task we used the eclipse context to inject the handler in the connector
- Because I'm using DS I'm also trying to convert the GeneralErrorHandler into a dynamic service
- Stumbling block: GeneralErrorHandler has an injected field of type BundleContext (NOT a dynamic service), with as only purpose to find a plug-in identifier
- That identifier is needed because in the end we use ErrorDialog.openError(activeShell, "Error", message, status)
- status is of type IStatus, which has a required field 'plug-in identifier'
3) current status
- Thanks to Christoph's contribution I succeeded in making GeneralErrorHandler a DS: the bundle id is dynamically obtained when constructing the status
- But we still have a 'code smell' here: the dynamic service GeneralErrorHandler wants to do something in the presentation layer
- So my current question is: how would you propagate a jms connection error message from the OSGi services layer to the presentation layer ?
|
|
|
|
Re: name of the active bundle [message #1733752 is a reply to message #1733743] |
Tue, 31 May 2016 08:14  |
Eclipse User |
|
|
|
Thanks Dirk! I'll certainly have a closer look at your blog post. We're already using the event bus somewhere in our code for similar stuff, so it's probably only a matter of making the overall error handling a bit more consistent (also handling the message translation in a uniform way) ...
|
|
|
Powered by
FUDForum. Page generated in 0.25219 seconds