You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Elliot Huntington <el...@gmail.com> on 2010/04/22 17:40:54 UTC

OSGi newbie looking for pointers

Hi:

I just started researching OSGi this past week so I'm very new to it
and have never developed an application using it. But I am very
interested in learning this technology. In my research I've learned
that the different bundles can communicate with each other by
publishing/consuming services to/from the service registry. I am
confused though how this process works.

For example I want to create a bare bones OSGi GUI application. I want
this application to only manage the lifecycle of the gui (open the
main frame and handle the shutdown/closing of the program). Then, I
would like to create other projects (bundles) that provide all the
features for this application via plugins. I'm thinking that the best
way to do this would be to create the main GUI application with an
instance of embedded Felix.

Given this scenario, how would the different pluggins/bundles know how
to modify the main GUI and add functionality to it? Does the GUI
itself need to provide hooks into it and if so how does it do that?

If any of you have any example code or tutorials you could point me to
I would appreciate it.

Thanks,
Elliot

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


Re: OSGi newbie looking for pointers

Posted by Elliot Huntington <el...@gmail.com>.
Thanks for your comment Shrivallabh. I'll look into Eclipse RCP.

By the way, if your application is using the command line you might be
interested in something I discovered the other day. Its called args4j.
I thought it was interesting.

On Thu, Apr 22, 2010 at 2:12 PM, Shrivallabh Deshmukh
<sh...@gmail.com> wrote:
> Hi elliot,
>
> Eclipse is OSGI based. The OSGI platform used by eclipse is called Equinox.
>
> If you are targeting a GUI application, it might now be a bad idea to look
> at Eclipse RCP.
>
> If the exercise is to understand how OSGI works, then a GUI application
> might not be the most appropriate starting point.
>
> I am at the just one week ahead of where you are :D
>
> I am working on a stand alone application that integrates using command
> line.
>
> So do share you experience.
>
> Regards,
>
>
> Shrivallabh
>
> On Thu, Apr 22, 2010 at 9:10 PM, Elliot Huntington <
> elliot.huntington@gmail.com> wrote:
>
>> Hi:
>>
>> I just started researching OSGi this past week so I'm very new to it
>> and have never developed an application using it. But I am very
>> interested in learning this technology. In my research I've learned
>> that the different bundles can communicate with each other by
>> publishing/consuming services to/from the service registry. I am
>> confused though how this process works.
>>
>> For example I want to create a bare bones OSGi GUI application. I want
>> this application to only manage the lifecycle of the gui (open the
>> main frame and handle the shutdown/closing of the program). Then, I
>> would like to create other projects (bundles) that provide all the
>> features for this application via plugins. I'm thinking that the best
>> way to do this would be to create the main GUI application with an
>> instance of embedded Felix.
>>
>> Given this scenario, how would the different pluggins/bundles know how
>> to modify the main GUI and add functionality to it? Does the GUI
>> itself need to provide hooks into it and if so how does it do that?
>>
>> If any of you have any example code or tutorials you could point me to
>> I would appreciate it.
>>
>> Thanks,
>> Elliot
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>



-- 
Elliot

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


Re: OSGi newbie looking for pointers

Posted by Shrivallabh Deshmukh <sh...@gmail.com>.
Hi elliot,

Eclipse is OSGI based. The OSGI platform used by eclipse is called Equinox.

If you are targeting a GUI application, it might now be a bad idea to look
at Eclipse RCP.

If the exercise is to understand how OSGI works, then a GUI application
might not be the most appropriate starting point.

I am at the just one week ahead of where you are :D

I am working on a stand alone application that integrates using command
line.

So do share you experience.

Regards,


Shrivallabh

On Thu, Apr 22, 2010 at 9:10 PM, Elliot Huntington <
elliot.huntington@gmail.com> wrote:

> Hi:
>
> I just started researching OSGi this past week so I'm very new to it
> and have never developed an application using it. But I am very
> interested in learning this technology. In my research I've learned
> that the different bundles can communicate with each other by
> publishing/consuming services to/from the service registry. I am
> confused though how this process works.
>
> For example I want to create a bare bones OSGi GUI application. I want
> this application to only manage the lifecycle of the gui (open the
> main frame and handle the shutdown/closing of the program). Then, I
> would like to create other projects (bundles) that provide all the
> features for this application via plugins. I'm thinking that the best
> way to do this would be to create the main GUI application with an
> instance of embedded Felix.
>
> Given this scenario, how would the different pluggins/bundles know how
> to modify the main GUI and add functionality to it? Does the GUI
> itself need to provide hooks into it and if so how does it do that?
>
> If any of you have any example code or tutorials you could point me to
> I would appreciate it.
>
> Thanks,
> Elliot
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: OSGi newbie looking for pointers

Posted by Elliot Huntington <el...@gmail.com>.
Thank you Stijn and Richard for your comments. I appreciate all the
support from everyone and continue to welcome additional pointers as I
am still very new to this. All the help I have thus received has been
very helpful and much appreciated.

Elliot

On Fri, Apr 23, 2010 at 7:15 AM, Stijn de Witt <st...@planon.nl> wrote:
> Ok, I didn't know that.
>
> However, the main point stands that if you need access to other packages
> than the default ones, you can add them using that property. :)
>
> -----Original Message-----
> From: Richard S. Hall [mailto:heavy@ungoverned.org]
> Sent: vrijdag 23 april 2010 15:02
> To: users@felix.apache.org
> Subject: Re: OSGi newbie looking for pointers
>
> On 4/23/10 8:58, Richard S. Hall wrote:
>> On 4/23/10 4:38, Stijn de Witt wrote:
>>> If you need access to Swing / AWT etc in your bundles, you should
>>> Instruct Felix to expose these classes to your bundles by placing
>>> Their package names in a list passed to Felix using
>>>
>>> Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA
>>
>> All JRE packages are exported by the system bundle by default, so you
>> should just have to import them in your bundles with no other
>> necessary actions.
>
> I should have added: since framework 2.0.0...
>
> -> richard
>
>>
>> -> richard
>>
>>> Good luck!
>>>
>>> -Stijn
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: Elliot Huntington [mailto:elliot.huntington@gmail.com]
>>> Sent: donderdag 22 april 2010 17:41
>>> To: users@felix.apache.org
>>> Subject: OSGi newbie looking for pointers
>>>
>>> Hi:
>>>
>>> I just started researching OSGi this past week so I'm very new to it
>>> and have never developed an application using it. But I am very
>>> interested in learning this technology. In my research I've learned
>>> that the different bundles can communicate with each other by
>>> publishing/consuming services to/from the service registry. I am
>>> confused though how this process works.
>>>
>>> For example I want to create a bare bones OSGi GUI application. I
> want
>>> this application to only manage the lifecycle of the gui (open the
>>> main frame and handle the shutdown/closing of the program). Then, I
>>> would like to create other projects (bundles) that provide all the
>>> features for this application via plugins. I'm thinking that the best
>>> way to do this would be to create the main GUI application with an
>>> instance of embedded Felix.
>>>
>>> Given this scenario, how would the different pluggins/bundles know
> how
>>> to modify the main GUI and add functionality to it? Does the GUI
>>> itself need to provide hooks into it and if so how does it do that?
>>>
>>> If any of you have any example code or tutorials you could point me
> to
>>> I would appreciate it.
>>>
>>> Thanks,
>>> Elliot
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>



-- 
Elliot

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


RE: OSGi newbie looking for pointers

Posted by Stijn de Witt <st...@planon.nl>.
Ok, I didn't know that.

However, the main point stands that if you need access to other packages
than the default ones, you can add them using that property. :)

-----Original Message-----
From: Richard S. Hall [mailto:heavy@ungoverned.org] 
Sent: vrijdag 23 april 2010 15:02
To: users@felix.apache.org
Subject: Re: OSGi newbie looking for pointers

On 4/23/10 8:58, Richard S. Hall wrote:
> On 4/23/10 4:38, Stijn de Witt wrote:
>> If you need access to Swing / AWT etc in your bundles, you should
>> Instruct Felix to expose these classes to your bundles by placing
>> Their package names in a list passed to Felix using
>>
>> Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA
>
> All JRE packages are exported by the system bundle by default, so you 
> should just have to import them in your bundles with no other 
> necessary actions.

I should have added: since framework 2.0.0...

-> richard

>
> -> richard
>
>> Good luck!
>>
>> -Stijn
>>
>>
>>
>> -----Original Message-----
>> From: Elliot Huntington [mailto:elliot.huntington@gmail.com]
>> Sent: donderdag 22 april 2010 17:41
>> To: users@felix.apache.org
>> Subject: OSGi newbie looking for pointers
>>
>> Hi:
>>
>> I just started researching OSGi this past week so I'm very new to it
>> and have never developed an application using it. But I am very
>> interested in learning this technology. In my research I've learned
>> that the different bundles can communicate with each other by
>> publishing/consuming services to/from the service registry. I am
>> confused though how this process works.
>>
>> For example I want to create a bare bones OSGi GUI application. I
want
>> this application to only manage the lifecycle of the gui (open the
>> main frame and handle the shutdown/closing of the program). Then, I
>> would like to create other projects (bundles) that provide all the
>> features for this application via plugins. I'm thinking that the best
>> way to do this would be to create the main GUI application with an
>> instance of embedded Felix.
>>
>> Given this scenario, how would the different pluggins/bundles know
how
>> to modify the main GUI and add functionality to it? Does the GUI
>> itself need to provide hooks into it and if so how does it do that?
>>
>> If any of you have any example code or tutorials you could point me
to
>> I would appreciate it.
>>
>> Thanks,
>> Elliot
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

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


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


Re: OSGi newbie looking for pointers

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 4/23/10 8:58, Richard S. Hall wrote:
> On 4/23/10 4:38, Stijn de Witt wrote:
>> If you need access to Swing / AWT etc in your bundles, you should
>> Instruct Felix to expose these classes to your bundles by placing
>> Their package names in a list passed to Felix using
>>
>> Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA
>
> All JRE packages are exported by the system bundle by default, so you 
> should just have to import them in your bundles with no other 
> necessary actions.

I should have added: since framework 2.0.0...

-> richard

>
> -> richard
>
>> Good luck!
>>
>> -Stijn
>>
>>
>>
>> -----Original Message-----
>> From: Elliot Huntington [mailto:elliot.huntington@gmail.com]
>> Sent: donderdag 22 april 2010 17:41
>> To: users@felix.apache.org
>> Subject: OSGi newbie looking for pointers
>>
>> Hi:
>>
>> I just started researching OSGi this past week so I'm very new to it
>> and have never developed an application using it. But I am very
>> interested in learning this technology. In my research I've learned
>> that the different bundles can communicate with each other by
>> publishing/consuming services to/from the service registry. I am
>> confused though how this process works.
>>
>> For example I want to create a bare bones OSGi GUI application. I want
>> this application to only manage the lifecycle of the gui (open the
>> main frame and handle the shutdown/closing of the program). Then, I
>> would like to create other projects (bundles) that provide all the
>> features for this application via plugins. I'm thinking that the best
>> way to do this would be to create the main GUI application with an
>> instance of embedded Felix.
>>
>> Given this scenario, how would the different pluggins/bundles know how
>> to modify the main GUI and add functionality to it? Does the GUI
>> itself need to provide hooks into it and if so how does it do that?
>>
>> If any of you have any example code or tutorials you could point me to
>> I would appreciate it.
>>
>> Thanks,
>> Elliot
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

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


Re: OSGi newbie looking for pointers

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 4/23/10 4:38, Stijn de Witt wrote:
> If you need access to Swing / AWT etc in your bundles, you should
> Instruct Felix to expose these classes to your bundles by placing
> Their package names in a list passed to Felix using
>
> Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA
>    

All JRE packages are exported by the system bundle by default, so you 
should just have to import them in your bundles with no other necessary 
actions.

-> richard

> Good luck!
>
> -Stijn
>
>
>
> -----Original Message-----
> From: Elliot Huntington [mailto:elliot.huntington@gmail.com]
> Sent: donderdag 22 april 2010 17:41
> To: users@felix.apache.org
> Subject: OSGi newbie looking for pointers
>
> Hi:
>
> I just started researching OSGi this past week so I'm very new to it
> and have never developed an application using it. But I am very
> interested in learning this technology. In my research I've learned
> that the different bundles can communicate with each other by
> publishing/consuming services to/from the service registry. I am
> confused though how this process works.
>
> For example I want to create a bare bones OSGi GUI application. I want
> this application to only manage the lifecycle of the gui (open the
> main frame and handle the shutdown/closing of the program). Then, I
> would like to create other projects (bundles) that provide all the
> features for this application via plugins. I'm thinking that the best
> way to do this would be to create the main GUI application with an
> instance of embedded Felix.
>
> Given this scenario, how would the different pluggins/bundles know how
> to modify the main GUI and add functionality to it? Does the GUI
> itself need to provide hooks into it and if so how does it do that?
>
> If any of you have any example code or tutorials you could point me to
> I would appreciate it.
>
> Thanks,
> Elliot
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>    

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


RE: OSGi newbie looking for pointers

Posted by Stijn de Witt <st...@planon.nl>.
Hi Elliot,

Depending on the amount of coupling between the bundles and your main 
application that you like, I think there are basically two options:

1) Push: Expose windows etc. through some service your framework places 
   in the registry, so bundles can add elements to it
2) Pull: Have your bundle expose elements they want to add to the GUI 
   through some service they publish and let the application actually 
   add them to the GUI

Push is more straightforward to implement I think. You would have your
main application publish a service with methods like:

Window getMainWindow();
Window getSearchDialog();
Etc.

The bundles would request this service, call the methods to get to the
windows and then add their GUI elements to it. This implies a high(er)
coupling between your application and the bundles though, because the
bundles would have to be aware of the layout of the GUI, which windows
are available etc.

Then there is pull. Your bundles would publish a service with methods
like:

Panel getMainPanel();
Panel[] getPopupPanels();
Etc.

In this variation the coupling between the main application and the 
bundles is lower. The bundles don't really 'know' what the main
application's GUI looks like, they just inform the application of
the GUI elements they provide and leave it up to the app itself to
decide where these elements should go.

In both variations you can either directly expose Swing / AWT etc
classes, or you can make a more abstract API that hides such
implementation details, for example using methods like:

List<Action> getActions()

Where Action is some class you define. Then the application would
decide whether to translate these actions to items in the main
menu, items in a context menu, push buttons or whatever.

If you need maximum flexibility and don't mind high coupling,
Push is probably most straightforward to implement and has the 
advantage that bundles can do unforeseen things.

If you need access to Swing / AWT etc in your bundles, you should
Instruct Felix to expose these classes to your bundles by placing
Their package names in a list passed to Felix using

Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA

Good luck!

-Stijn



-----Original Message-----
From: Elliot Huntington [mailto:elliot.huntington@gmail.com] 
Sent: donderdag 22 april 2010 17:41
To: users@felix.apache.org
Subject: OSGi newbie looking for pointers

Hi:

I just started researching OSGi this past week so I'm very new to it
and have never developed an application using it. But I am very
interested in learning this technology. In my research I've learned
that the different bundles can communicate with each other by
publishing/consuming services to/from the service registry. I am
confused though how this process works.

For example I want to create a bare bones OSGi GUI application. I want
this application to only manage the lifecycle of the gui (open the
main frame and handle the shutdown/closing of the program). Then, I
would like to create other projects (bundles) that provide all the
features for this application via plugins. I'm thinking that the best
way to do this would be to create the main GUI application with an
instance of embedded Felix.

Given this scenario, how would the different pluggins/bundles know how
to modify the main GUI and add functionality to it? Does the GUI
itself need to provide hooks into it and if so how does it do that?

If any of you have any example code or tutorials you could point me to
I would appreciate it.

Thanks,
Elliot

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


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


Re: OSGi newbie looking for pointers

Posted by Elliot Huntington <el...@gmail.com>.
Thank you Richard for your quick response. I think this article and
the examples in it will be very useful.

Elliot

On Thu, Apr 22, 2010 at 9:54 AM, Richard S. Hall <he...@ungoverned.org> wrote:
> On 4/22/10 11:40, Elliot Huntington wrote:
>>
>> Hi:
>>
>> I just started researching OSGi this past week so I'm very new to it
>> and have never developed an application using it. But I am very
>> interested in learning this technology. In my research I've learned
>> that the different bundles can communicate with each other by
>> publishing/consuming services to/from the service registry. I am
>> confused though how this process works.
>>
>> For example I want to create a bare bones OSGi GUI application. I want
>> this application to only manage the lifecycle of the gui (open the
>> main frame and handle the shutdown/closing of the program). Then, I
>> would like to create other projects (bundles) that provide all the
>> features for this application via plugins. I'm thinking that the best
>> way to do this would be to create the main GUI application with an
>> instance of embedded Felix.
>>
>
> I don't think you need an embedded framework instance...you could just as
> easily create the main GUI as a bundle and probably the better approach.
> Check out the paint program example, which works both ways:
>
>    http://felix.apache.org/site/apache-felix-application-demonstration.html
>
> -> richard
>
>> Given this scenario, how would the different pluggins/bundles know how
>> to modify the main GUI and add functionality to it? Does the GUI
>> itself need to provide hooks into it and if so how does it do that?
>>
>> If any of you have any example code or tutorials you could point me to
>> I would appreciate it.
>>
>> Thanks,
>> Elliot
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>



-- 
Elliot

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


Re: OSGi newbie looking for pointers

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 4/22/10 11:40, Elliot Huntington wrote:
> Hi:
>
> I just started researching OSGi this past week so I'm very new to it
> and have never developed an application using it. But I am very
> interested in learning this technology. In my research I've learned
> that the different bundles can communicate with each other by
> publishing/consuming services to/from the service registry. I am
> confused though how this process works.
>
> For example I want to create a bare bones OSGi GUI application. I want
> this application to only manage the lifecycle of the gui (open the
> main frame and handle the shutdown/closing of the program). Then, I
> would like to create other projects (bundles) that provide all the
> features for this application via plugins. I'm thinking that the best
> way to do this would be to create the main GUI application with an
> instance of embedded Felix.
>    

I don't think you need an embedded framework instance...you could just 
as easily create the main GUI as a bundle and probably the better 
approach. Check out the paint program example, which works both ways:

     
http://felix.apache.org/site/apache-felix-application-demonstration.html

-> richard

> Given this scenario, how would the different pluggins/bundles know how
> to modify the main GUI and add functionality to it? Does the GUI
> itself need to provide hooks into it and if so how does it do that?
>
> If any of you have any example code or tutorials you could point me to
> I would appreciate it.
>
> Thanks,
> Elliot
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>    

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