You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Elvy <pi...@gmail.com> on 2007/12/11 12:54:20 UTC

Install and start bundles from another bundle

Hi, 

I am developing a GUI application as a bundle. This GUI is somehow like
eclipse, it is a place where plugins can register to. Because it is Swing
based, I have to do all the GUI initialization from the EDT. I thus call an
InvokeAndWait() from my BundleActivator and do it all here (the
BundleActivator itself is the Runnable).

Logically, the start method will be blocked until init is finished... I know
it blocks the OSGi framework for quite a while, but what else can I do?

Now, I would like to seek for plugins (inside a folder, from a conf file,
...) and install and start them. Where should I do it? Inside the Activator,
after the InvokeAndWait? Inside the InvokeAndWait after GUI init? Inside an
InvokeLater? 

How would you guys recommend discovering and starting bundles at runtime,
from another Bundle, right after it is completely up and running?

-----
Tell me something you don't know!
-- 
View this message in context: http://www.nabble.com/Install-and-start-bundles-from-another-bundle-tp14272453p14272453.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Install and start bundles from another bundle

Posted by Elvy <pi...@gmail.com>.
This is exactly what I'm doing

Start my GUI with a ServiceTracker and react on add/remove/update of custom
plugins interfaces.

My interrogations come from the fact that I must be cautious about OSGi
framework calls from other threads (EDT or Custom) and deadlocks.

So you init you GUI and track services. Then how, and from where do you
launch your installing process while being certain that the OSGi framework
won't block?


Barron Logan wrote:
> 
> Hello Elvy,
> 
> I once created an application like this and it was a lot of fun...
> 
>>Now, I would like to seek for plugins (inside a folder, from a conf file,
> ...) and install and start them.
> 
> You may want to consider a dynamic approach to this.  Instead of
> installing
> plugins once after GUI initialization, maybe alow for plugins to be
> continually installed...
> 
> To acheive this, I used a mechanism similar to the following:
> 
> // in GUI Activator
> start(){
>     // invokeLater() or invokeAndWait() initialization of GUI with some
> default plugins
>     ...
>     // create ServiceListeners that will listen for new plugins and inject
> them into your GUI
>     ...
>     //  maybe kick off some process that will find, install and start
> plugins
>     ...
>   }
> 
> Presumeably your GUI will be able to handle plugins that implements some
> set
> of Services...  so the key is to just listen for that enumeration of
> Services and handle them appropriately.  In my app the services resided on
> various servers but my app knew only about a descriptor file on a
> particular
> server (for this i created Remote Bundle
> Installer<http://oscar-osgi.sourceforge.net/>
> ).
> 
> Consider using *listeners and events* for updating the GUI.  Consider
> doing
> this in an *asynchronous *manner.
> 
> Kind regards,
> 
> -Barron
> 
> 
> On Dec 11, 2007 6:54 AM, Elvy <pi...@gmail.com> wrote:
> 
>>
>> Hi,
>>
>> I am developing a GUI application as a bundle. This GUI is somehow like
>> eclipse, it is a place where plugins can register to. Because it is Swing
>> based, I have to do all the GUI initialization from the EDT. I thus call
>> an
>> InvokeAndWait() from my BundleActivator and do it all here (the
>> BundleActivator itself is the Runnable).
>>
>> Logically, the start method will be blocked until init is finished... I
>> know
>> it blocks the OSGi framework for quite a while, but what else can I do?
>>
>> Now, I would like to seek for plugins (inside a folder, from a conf file,
>> ...) and install and start them. Where should I do it? Inside the
>> Activator,
>> after the InvokeAndWait? Inside the InvokeAndWait after GUI init? Inside
>> an
>> InvokeLater?
>>
>> How would you guys recommend discovering and starting bundles at runtime,
>> from another Bundle, right after it is completely up and running?
>>
>> -----
>> Tell me something you don't know!
>> --
>> View this message in context:
>> http://www.nabble.com/Install-and-start-bundles-from-another-bundle-tp14272453p14272453.html
>> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
> 
> 
> -- 
> Your Friend   |   Barron C. Logan   |   678.656.5924
> 
> 


-----
Tell me something you don't know!
-- 
View this message in context: http://www.nabble.com/Install-and-start-bundles-from-another-bundle-tp14272453p14277286.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Install and start bundles from another bundle

Posted by Logan Barron <ba...@gmail.com>.
Hello Elvy,

I once created an application like this and it was a lot of fun...

>Now, I would like to seek for plugins (inside a folder, from a conf file,
...) and install and start them.

You may want to consider a dynamic approach to this.  Instead of installing
plugins once after GUI initialization, maybe alow for plugins to be
continually installed...

To acheive this, I used a mechanism similar to the following:

// in GUI Activator
start(){
    // invokeLater() or invokeAndWait() initialization of GUI with some
default plugins
    ...
    // create ServiceListeners that will listen for new plugins and inject
them into your GUI
    ...
    //  maybe kick off some process that will find, install and start
plugins
    ...
  }

Presumeably your GUI will be able to handle plugins that implements some set
of Services...  so the key is to just listen for that enumeration of
Services and handle them appropriately.  In my app the services resided on
various servers but my app knew only about a descriptor file on a particular
server (for this i created Remote Bundle
Installer<http://oscar-osgi.sourceforge.net/>
).

Consider using *listeners and events* for updating the GUI.  Consider doing
this in an *asynchronous *manner.

Kind regards,

-Barron


On Dec 11, 2007 6:54 AM, Elvy <pi...@gmail.com> wrote:

>
> Hi,
>
> I am developing a GUI application as a bundle. This GUI is somehow like
> eclipse, it is a place where plugins can register to. Because it is Swing
> based, I have to do all the GUI initialization from the EDT. I thus call
> an
> InvokeAndWait() from my BundleActivator and do it all here (the
> BundleActivator itself is the Runnable).
>
> Logically, the start method will be blocked until init is finished... I
> know
> it blocks the OSGi framework for quite a while, but what else can I do?
>
> Now, I would like to seek for plugins (inside a folder, from a conf file,
> ...) and install and start them. Where should I do it? Inside the
> Activator,
> after the InvokeAndWait? Inside the InvokeAndWait after GUI init? Inside
> an
> InvokeLater?
>
> How would you guys recommend discovering and starting bundles at runtime,
> from another Bundle, right after it is completely up and running?
>
> -----
> Tell me something you don't know!
> --
> View this message in context:
> http://www.nabble.com/Install-and-start-bundles-from-another-bundle-tp14272453p14272453.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Your Friend   |   Barron C. Logan   |   678.656.5924

Re: Install and start bundles from another bundle

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Elvy wrote:
> I did check the example on Felix web site, the application with SimpleShapes
> (circle, triangle, rectangle,...). And the idea of invokeAndWait comes from
> this example!
>   

Yes, but this example doesn't install bundles via invokeAndWait() those 
are asynchronous events that happen outside of the application. Of 
course, there could be some UI to install bundles from within the 
application, such as a menu entry or something. Regardless, the 
invokeAndWait() is not strictly necessary in the example's 
Activator.start() method, that could be invokeLater(). I think all 
invokeAndWait() calls could be converted to invokeLater(), but were not 
since the calls were simple and didn't significantly delay the activator 
or the event thread, depending on the case.

Ultimately, for OSGi if you are going to take a long time in the 
activator, you should use a separate thread. For Swing if you are going 
to take a long time on a callback, then you should use invokeLater() or 
a SwingWorker.

> I can get the BundleContext and use it whenever and from whatever thread
> without risks of concurrency problems? Can I assume that Felix is able to
> deal with simultaneous requests from different BundleContexts?
>
> I think it does, but since I'm new to OSGi, I'm not certain yet...
>   

Yes, you can use your bundle context at any time from any thread.

-> richard

>
>
> Richard S. Hall wrote:
>   
>> Elvy wrote:
>>     
>>> Hi, 
>>>
>>> I am developing a GUI application as a bundle. This GUI is somehow like
>>> eclipse, it is a place where plugins can register to. Because it is Swing
>>> based, I have to do all the GUI initialization from the EDT. I thus call
>>> an
>>> InvokeAndWait() from my BundleActivator and do it all here (the
>>> BundleActivator itself is the Runnable).
>>>
>>> Logically, the start method will be blocked until init is finished... I
>>> know
>>> it blocks the OSGi framework for quite a while, but what else can I do?
>>>   
>>> Now, I would like to seek for plugins (inside a folder, from a conf file,
>>> ...) and install and start them. Where should I do it? Inside the
>>> Activator,
>>> after the InvokeAndWait? Inside the InvokeAndWait after GUI init? Inside
>>> an
>>> InvokeLater? 
>>>
>>> How would you guys recommend discovering and starting bundles at runtime,
>>> from another Bundle, right after it is completely up and running?
>>>   
>>>       
>> It sounds like the main steps you need are:
>>
>>    1. Initialize GUI
>>    2. Install available plugins.
>>
>> It doesn't sound like step (1) needs to be performed in the start() 
>> method, so simply do it in an invokeLater() instead of an 
>> invokeAndWait(). It sounds like the only thing you need from start() is 
>> the BundleContext, so get it, do an invokeLater() and let the framework 
>> get on with its business.
>>
>> Then, once you have completed step (1) you are free to move onto step 
>> (2) in the same invokeLater(), no? In truth, it doesn't seem like 
>> installing the plugins needs to be done on the event thread, since the 
>> act of installing bundles should generate events that will update your 
>> GUI state. So you could install plugins in a different thread, perhaps.
>>
>> If you haven't already done so, you might want to check out the example 
>> paint application on the Felix web site.
>>
>> -> richard
>>
>>     
>>> -----
>>> Tell me something you don't know!
>>>   
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>>
>>     
>
>
> -----
> Tell me something you don't know!
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Install and start bundles from another bundle

Posted by Elvy <pi...@gmail.com>.
I did check the example on Felix web site, the application with SimpleShapes
(circle, triangle, rectangle,...). And the idea of invokeAndWait comes from
this example!

I can get the BundleContext and use it whenever and from whatever thread
without risks of concurrency problems? Can I assume that Felix is able to
deal with simultaneous requests from different BundleContexts?

I think it does, but since I'm new to OSGi, I'm not certain yet...



Richard S. Hall wrote:
> 
> Elvy wrote:
>> Hi, 
>>
>> I am developing a GUI application as a bundle. This GUI is somehow like
>> eclipse, it is a place where plugins can register to. Because it is Swing
>> based, I have to do all the GUI initialization from the EDT. I thus call
>> an
>> InvokeAndWait() from my BundleActivator and do it all here (the
>> BundleActivator itself is the Runnable).
>>
>> Logically, the start method will be blocked until init is finished... I
>> know
>> it blocks the OSGi framework for quite a while, but what else can I do?
>>   
>> Now, I would like to seek for plugins (inside a folder, from a conf file,
>> ...) and install and start them. Where should I do it? Inside the
>> Activator,
>> after the InvokeAndWait? Inside the InvokeAndWait after GUI init? Inside
>> an
>> InvokeLater? 
>>
>> How would you guys recommend discovering and starting bundles at runtime,
>> from another Bundle, right after it is completely up and running?
>>   
> 
> It sounds like the main steps you need are:
> 
>    1. Initialize GUI
>    2. Install available plugins.
> 
> It doesn't sound like step (1) needs to be performed in the start() 
> method, so simply do it in an invokeLater() instead of an 
> invokeAndWait(). It sounds like the only thing you need from start() is 
> the BundleContext, so get it, do an invokeLater() and let the framework 
> get on with its business.
> 
> Then, once you have completed step (1) you are free to move onto step 
> (2) in the same invokeLater(), no? In truth, it doesn't seem like 
> installing the plugins needs to be done on the event thread, since the 
> act of installing bundles should generate events that will update your 
> GUI state. So you could install plugins in a different thread, perhaps.
> 
> If you haven't already done so, you might want to check out the example 
> paint application on the Felix web site.
> 
> -> richard
> 
>> -----
>> Tell me something you don't know!
>>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 
> 
> 


-----
Tell me something you don't know!
-- 
View this message in context: http://www.nabble.com/Install-and-start-bundles-from-another-bundle-tp14272453p14277686.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Install and start bundles from another bundle

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Elvy wrote:
> Hi, 
>
> I am developing a GUI application as a bundle. This GUI is somehow like
> eclipse, it is a place where plugins can register to. Because it is Swing
> based, I have to do all the GUI initialization from the EDT. I thus call an
> InvokeAndWait() from my BundleActivator and do it all here (the
> BundleActivator itself is the Runnable).
>
> Logically, the start method will be blocked until init is finished... I know
> it blocks the OSGi framework for quite a while, but what else can I do?
>   
> Now, I would like to seek for plugins (inside a folder, from a conf file,
> ...) and install and start them. Where should I do it? Inside the Activator,
> after the InvokeAndWait? Inside the InvokeAndWait after GUI init? Inside an
> InvokeLater? 
>
> How would you guys recommend discovering and starting bundles at runtime,
> from another Bundle, right after it is completely up and running?
>   

It sounds like the main steps you need are:

   1. Initialize GUI
   2. Install available plugins.

It doesn't sound like step (1) needs to be performed in the start() 
method, so simply do it in an invokeLater() instead of an 
invokeAndWait(). It sounds like the only thing you need from start() is 
the BundleContext, so get it, do an invokeLater() and let the framework 
get on with its business.

Then, once you have completed step (1) you are free to move onto step 
(2) in the same invokeLater(), no? In truth, it doesn't seem like 
installing the plugins needs to be done on the event thread, since the 
act of installing bundles should generate events that will update your 
GUI state. So you could install plugins in a different thread, perhaps.

If you haven't already done so, you might want to check out the example 
paint application on the Felix web site.

-> richard

> -----
> Tell me something you don't know!
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Install and start bundles from another bundle

Posted by Elvy <pi...@gmail.com>.
>Did you have a look at Peter's FileInstall bundle?
>
>http://www.aqute.biz/Code/FileInstall
>
>regards,
>
>Karl

FileInstall looks interesting but there's one thing I don't understand about
the configuration? Where is configuration file supposed to be? What is its
name?

In the long term I fear to lose control over bundle installation... but, for
the moment, I guess I can skip this.

-----
Tell me something you don't know!
-- 
View this message in context: http://www.nabble.com/Install-and-start-bundles-from-another-bundle-tp14272453p14274102.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Install and start bundles from another bundle

Posted by Karl Pauls <ka...@gmail.com>.
> Hi,
>
> I am developing a GUI application as a bundle. This GUI is somehow like
> eclipse, it is a place where plugins can register to. Because it is Swing
> based, I have to do all the GUI initialization from the EDT. I thus call an
> InvokeAndWait() from my BundleActivator and do it all here (the
> BundleActivator itself is the Runnable).
>
> Logically, the start method will be blocked until init is finished... I know
> it blocks the OSGi framework for quite a while, but what else can I do?

invokeLater() ?

> Now, I would like to seek for plugins (inside a folder, from a conf file,
> ...) and install and start them. Where should I do it? Inside the Activator,
> after the InvokeAndWait? Inside the InvokeAndWait after GUI init? Inside an
> InvokeLater?
>
> How would you guys recommend discovering and starting bundles at runtime,
> from another Bundle, right after it is completely up and running?

Did you have a look at Peter's FileInstall bundle?

http://www.aqute.biz/Code/FileInstall

regards,

Karl

> -----
> Tell me something you don't know!
> --
> View this message in context: http://www.nabble.com/Install-and-start-bundles-from-another-bundle-tp14272453p14272453.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org