Constructor of Part is being called twice [message #1358295] |
Thu, 15 May 2014 22:55 |
Fernando Paz Messages: 22 Registered: May 2014 |
Junior Member |
|
|
I'm creating a very simple e4 RCP application for study purposes. Therefore, I'm facing a weird behaviour in the platform.
What I want to achieve:
A view that is capable of loading widgets (clock, weather forecast, feed, etc.) in runtime.
What I think I should do:
Each widget has to be a bundle that offers the same base service (i.e. IWidget). A view would lookup for all widgets and add/remove them whenever they are installed/uninstalled in the OSGi container. I would be able to achieve this through Declarative Services (DS).
What I currently have:
I have 4 bundles in different projects:
- Widget bundle, which has just an interface IWidget with a method getName() only;
- Clock Widget, an implementation of IWidget;
- Main View Part, which has a constructor (that currently does nothing), a @PostConstruct method and bind methods (addWidget(IWidget) and removeWidget(IWidget)) used by the DS.
- Application, that contains a e4xmi with a Part referencing the MainViewPart class.
A class diagram can be found here: i.imgur.com/TD8JRSv.jpg
What my issue is:
When I ran my application I noticed that the MainViewPart constructor is being called twice. Here are the outputs:
1. MainViewPart - Constructor
2. ClockWidget - Constructor
3. MainViewPart - Adding widget ClockWidget
4. MainViewPart - Constructor
5. MainViewPart - @PostConstruct
6. MainViewPart - Removing widget ClockWidget
As you can see, the MainViewPart constructor is called first time. Then the ClockWidget is instantiated and after that the MainViewPart constructor is called again (line 4.). This behaviour brings a terrible limitation to what I'm trying to do. I haven't found people complaining about this on the web, so I suppose it is something expected, or maybe I should try another approach. I'm not following any specific tutorial, just trying to do something with the experience earned so far.
Any help is appreciated
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02097 seconds