Home » Eclipse Projects » Eclipse 4 » DI & Auto-start
DI & Auto-start [message #843940] |
Fri, 13 April 2012 14:22 |
Pierre GAUTIER Messages: 13 Registered: August 2010 |
Junior Member |
|
|
Hi,
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.
But ...
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,
Pierre GAUTIER
|
|
|
Re: DI & Auto-start [message #844181 is a reply to message #843940] |
Fri, 13 April 2012 19:33 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
What you describe is not going to work - OSGi is operating below the DI
level. You can install your 2 components as so call addons and then the
application framework will create an instances of the them using DI at
the very moment the framework boots up.
Tom
Am 13.04.12 16:22, schrieb Missing name Mising name:
> Hi,
>
>
> 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.
>
> But ...
>
> 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,
>
>
> Pierre GAUTIER
>
|
|
| | | |
Goto Forum:
Current Time: Thu Apr 25 06:31:06 GMT 2024
Powered by FUDForum. Page generated in 0.02595 seconds
|