|DI & Auto-start [message #843940]
||Fri, 13 April 2012 10:22
| Pierre GAUTIER
Registered: August 2010
I'm starting an Eclipse 4 Application and am currently learning about the new platform features.
I want the application to work with or without the optionnal plugins without any modification in the code but only a different product configuration. So I've decided to articulate everything around the IEventBroker.
I want to build plugins which :
- if registered in the .product file, start, register their manager to the IEventBroker and listen,
- if not, are not started, etc.
I've hit a problem and can't find a solution.
Let's say I have a main plugin project called 'application' with 'application.e4xmi' and 'application.product' based on features, I have also 2 plugins 'sound' and 'logger'.
In the 2 plugins there's a Manager which has @Inject'ed fields, subscribes an EventHandler to the IEventBroker and listen for events to be posted on it.
With start level and auto start configuration in the .product file I can start the plugins in the good order, logger then sound and finally application.
In the application project I've defined a StartupHandler with @PostContextCreate, @Inject'ed fields and defined in the product extension as below :
<property name="lifeCycleURI" value="bundleclass://xxx/application.StartupHandler"></property>
This class is executed when I want it to be and the DI component works well there.
The SoundManager (in the sound project) has @Inject'ed fields so I can't and don't want to instantiate and build it myself instead I need the DI component to do it.
To do so, I've put in my sound.Activator, which is executed before the application.Activator an @Inject private SoundManager soundManager.
My problem is : the SoundManager is never instantiated, not injected in my sound.Activator, and is not listening when the application start and post a SoundRequestEvent !
To be simple : I want the DI component to build managers when the corresponding plugin is started and can't achieve it.
I hope I've been clear enough, and some could help me.
Tell me if you need more information,
Thanks by advance,