Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » DI & Auto-start
DI & Auto-start [message #843940] Fri, 13 April 2012 14:22 Go to next message
Pierre GAUTIER is currently offline Pierre GAUTIERFriend
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 &amp; Auto-start [message #844181 is a reply to message #843940] Fri, 13 April 2012 19:33 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
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
>
Re: DI &amp; Auto-start [message #846493 is a reply to message #844181] Mon, 16 April 2012 05:30 Go to previous messageGo to next message
Pierre GAUTIER is currently offline Pierre GAUTIERFriend
Messages: 13
Registered: August 2010
Junior Member


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 !


Re: DI &amp;amp; Auto-start [message #846529 is a reply to message #846493] Mon, 16 April 2012 06:20 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 16.04.12 07:30, schrieb Missing name Mising name:
>
>
> 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
Re: DI &amp;amp; Auto-start [message #846621 is a reply to message #846529] Mon, 16 April 2012 09:39 Go to previous message
Pierre GAUTIER is currently offline Pierre GAUTIERFriend
Messages: 13
Registered: August 2010
Junior Member


Thank you !
Previous Topic:Open and close parts dynamically
Next Topic:RAP application with XWT
Goto Forum:
  


Current Time: Fri Apr 19 23:22:30 GMT 2024

Powered by FUDForum. Page generated in 0.03767 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top