Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Using OSGI DS in an Eclipse 3.6 bundle.
Using OSGI DS in an Eclipse 3.6 bundle. [message #657576] Thu, 03 March 2011 10:37 Go to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hello there,

I have a trivial question, but can't seem to get the answer on this.

Most of the bundles I create, I would select "Eclipse Version 3.6" as
the target platform.

So I understand, If I want to use Declared Services, I would need to
select an OSGI framework like Equinox. But let's say, I still want to
use DS on a Eclipse 3.6 bundle. Would this be possible? Is it simply a
matter of adding a dependency to the OSGI framework (org.osgi.framework) ?

What is the difference anyway? (Besides the dependency, the activator
base is the same BundleActivator).

Empty Eclipse 3.6 MANIFEST.MF

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test_
Bundle-SymbolicName: test_
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: test_.Activator
Require-Bundle: org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Empty Equinox MANIFEST.MF

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test
Bundle-SymbolicName: test
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: test.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.osgi.framework;version="1.3.0"


many thanks, Christophe
Re: Using OSGI DS in an Eclipse 3.6 bundle. [message #657620 is a reply to message #657576] Thu, 03 March 2011 13:46 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 03/03/2011 05:37 AM, Christophe Bouhier wrote:
> So I understand, If I want to use Declared Services, I would need to
> select an OSGI framework like Equinox. But let's say, I still want to
> use DS on a Eclipse 3.6 bundle. Would this be possible? Is it simply a
> matter of adding a dependency to the OSGI framework (org.osgi.framework) ?

Yes, DS in a standard eclipse plugin works fine. After all, and eclipse
plugin is an OSGi bundle (but there are a number of implied services
already available).

You can just create a new DS component in an eclipse plugin.

It just looks like:
http://dev.eclipse.org/viewcvs/viewvc.cgi/e4/org.eclipse.e4. ui/bundles/org.eclipse.e4.ui.services/META-INF/MANIFEST.MF?v iew=co
with the appropriate header:

Service-Component: OSGI-INF/eventBroker.xml

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Using OSGI DS in an Eclipse 3.6 bundle. [message #657622 is a reply to message #657576] Thu, 03 March 2011 13:55 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
You may get a better response on the PDE forum. The main difference between selecting Eclipse vs Equinox/OSGi as the target has nothing really to do with DS.

When selecting Eclipse the PDE tooling assumes you are going to be creating extensions or extension points (specified in plugin.xml) which will extend the eclipse platform using the eclipse extension registry. By default this enables the manifest editor with the extensions and extension points tab for editing the plugin.xml.

Now I cannot really explain why they use Require-Bundle vs. Import-Package depending on which one you choose. In my opinion both options should default to using Import-Package, but that is up for debate. The other thing that happens when you select Eclipse as your platform is some other options for contributing to the UI etc. Depending on what you choose this will change what class your bundle activator extends or implements. These are simply defaults that the tooling is choosing for you. None of it is really required in order to define extensions or extension points in eclipse. All your bundle needs for that is a plugin.xml file.

As I said earlier, none of this has anything to do with DS. Your bundle can define DS components no matter what target you choose. It is also worth pointing out that you do not necessarily need a bundle activator to define DS components. In fact one of the best practices in OSGi is to eliminate the bundle activator. The easiest way to get started with DS is to pick Equinox/OSGi as your target and then use the Declarative Services Example template when creating your project. I also recommend you uncheck the box to create an activator. You can add an activator later if your find you really need one.

HTH
Tom.
Re: Using OSGI DS in an Eclipse 3.6 bundle. [message #657668 is a reply to message #657622] Thu, 03 March 2011 15:46 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Thanks, that clarifies.

On 03-03-11 14:55, Thomas Watson wrote:
> You may get a better response on the PDE forum. The main difference
> between selecting Eclipse vs Equinox/OSGi as the target has nothing
> really to do with DS.
>
> When selecting Eclipse the PDE tooling assumes you are going to be
> creating extensions or extension points (specified in plugin.xml) which
> will extend the eclipse platform using the eclipse extension registry.
> By default this enables the manifest editor with the extensions and
> extension points tab for editing the plugin.xml.
>
> Now I cannot really explain why they use Require-Bundle vs.
> Import-Package depending on which one you choose. In my opinion both
> options should default to using Import-Package, but that is up for
> debate. The other thing that happens when you select Eclipse as your
> platform is some other options for contributing to the UI etc. Depending
> on what you choose this will change what class your bundle activator
> extends or implements. These are simply defaults that the tooling is
> choosing for you. None of it is really required in order to define
> extensions or extension points in eclipse. All your bundle needs for
> that is a plugin.xml file.
>
> As I said earlier, none of this has anything to do with DS. Your bundle
> can define DS components no matter what target you choose. It is also
> worth pointing out that you do not necessarily need a bundle activator
> to define DS components. In fact one of the best practices in OSGi is to
> eliminate the bundle activator. The easiest way to get started with DS
> is to pick Equinox/OSGi as your target and then use the Declarative
> Services Example template when creating your project. I also recommend
> you uncheck the box to create an activator. You can add an activator
> later if your find you really need one.
>
> HTH
> Tom.
>
Re: Using OSGI DS in an Eclipse 3.6 bundle. [message #657669 is a reply to message #657620] Thu, 03 March 2011 15:46 Go to previous message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Thank You, very useful.

On 03-03-11 14:46, Paul Webster wrote:
> On 03/03/2011 05:37 AM, Christophe Bouhier wrote:
>> So I understand, If I want to use Declared Services, I would need to
>> select an OSGI framework like Equinox. But let's say, I still want to
>> use DS on a Eclipse 3.6 bundle. Would this be possible? Is it simply a
>> matter of adding a dependency to the OSGI framework
>> (org.osgi.framework) ?
>
> Yes, DS in a standard eclipse plugin works fine. After all, and eclipse
> plugin is an OSGi bundle (but there are a number of implied services
> already available).
>
> You can just create a new DS component in an eclipse plugin.
>
> It just looks like:
> http://dev.eclipse.org/viewcvs/viewvc.cgi/e4/org.eclipse.e4. ui/bundles/org.eclipse.e4.ui.services/META-INF/MANIFEST.MF?v iew=co
> with the appropriate header:
>
> Service-Component: OSGI-INF/eventBroker.xml
>
> PW
>
>
Previous Topic:Moving from Export to Headless
Next Topic:Headless self-update issue
Goto Forum:
  


Current Time: Tue Apr 23 16:20:35 GMT 2024

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

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

Back to the top