Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsDI & Auto-start
https://www.eclipse.org/forums/index.php/mv/msg/328976/843940/#msg_843940
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 :
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
]]>Pierre GAUTIER2012-04-13T14:22:54-00:00Re: DI & Auto-start
https://www.eclipse.org/forums/index.php/mv/msg/328976/844181/#msg_844181
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
>]]>Thomas Schindl2012-04-13T19:33:55-00:00Re: DI &amp; Auto-start
https://www.eclipse.org/forums/index.php/mv/msg/328976/846493/#msg_846493
Hi Tom,
First, thanks for your answer, I'll definitly use Addons.
Then, could you answer a few more questions ?
- Is what I want to do pure OSGI stuff ?
- Ain't it a way to obtain the behaviour descrbied with pure Eclipse 4 platform ? The Addons need the application to know the addon's plugin, I would prefer to avoid that.
- I want to learn and understand E4 platform deeply, should I go down to OSGI and buy a book or should I stay at E4 level and use what it provides ?
Thanks for your response, and thanks to you and all others for the E4 platform, it's great !
]]>Pierre GAUTIER2012-04-16T05:30:56-00:00Re: DI &amp;amp; Auto-start
https://www.eclipse.org/forums/index.php/mv/msg/328976/846529/#msg_846529
>
>
> Hi Tom,
>
>
> First, thanks for your answer, I'll definitly use Addons.
>
> Then, could you answer a few more questions ?
>
> - Is what I want to do pure OSGI stuff ?
Because OSGi has no idea of DI you can't use DI at the OSGi level
> - Ain't it a way to obtain the behaviour descrbied with pure Eclipse 4
> platform ? The Addons need the application to know the addon's plugin, I
> would prefer to avoid that.
No you can contribute addons through model fragments from any plugin.
> - I want to learn and understand E4 platform deeply, should I go down to
> OSGI and buy a book or should I stay at E4 level and use what it provides ?
>
If you want to understand e4 you need to understand OSGi (at least some
parts like OSGi-Services, ....)
Tom]]>Thomas Schindl2012-04-16T06:20:22-00:00Re: DI &amp;amp; Auto-start
https://www.eclipse.org/forums/index.php/mv/msg/328976/846621/#msg_846621
Thank you !]]>Pierre GAUTIER2012-04-16T09:39:04-00:00