Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Extensions & Services
Extensions & Services [message #94631] Wed, 08 August 2007 20:44 Go to next message
Brett Humphreys is currently offline Brett HumphreysFriend
Messages: 17
Registered: July 2009
Junior Member
All,
I'm currently working with equinox embedded in my J2SE environment. I've moved nearly everything
over to bundles and things are working well. I end up only picking and choosing parts of
equinox/eclipse to use. The extension registry happens to be one of those. My question is, how do
most extension acquire a service? Do they normally start with the package admin service available
through the OSGIUtils class or normally is a bundle context handed to them by the extension point (I
should say their instantiator) and then they just use that bundle context to retrieve services for
their lifetime?

I have a solution to this problem, which I don't love, so I wanted to know how everyone else, or
just eclipse solves this problem. Since OSGIUtils is in the o.e.core.internal.registry.osgi package
it made me think that use of this class by extensions was discouraged.

Thoughts?

Thanks a lot

-Brett
Re: Extensions & Services [message #94646 is a reply to message #94631] Wed, 08 August 2007 22:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

Usually, one bundle will scan for the extensions contributed by others, and invoke 'createExecutableExtension' for the things that it wants. That performs the magic to link the bundle wanting the extension to the bundle needing the extension. Most 'Eclipse' clients just use extensions.

However, you don't have to just constrain yourself to using extensions if you want to use OSGi services instead. That's also possible. And, since the extension registry is itself an OSGi bundle that can run on other OSGi environments, then there's no reason you can't ship that as well as your application.

You might like to read:

http://www.eclipsezone.com/eclipse/forums/t97608.rhtml
(and its precursor, if you don't know what it is) as well as
http://www.eclipsezone.com/articles/extensions-vs-services/

Alex.
Re: Extensions & Services [message #94660 is a reply to message #94631] Thu, 09 August 2007 06:33 Go to previous messageGo to next message
Markus Wolf is currently offline Markus WolfFriend
Messages: 153
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Thoughts?
>
You could also use DeclarativeServices to receive your service
references. That would be the OSGi way not the eclipse way.

Markus Wolf
- --
>
> emedia-solutions wolf web: http://www.emedia-solutions-wolf.de
> Eimsbüttler Straße 115 mail: markus@emedia-solutions-wolf.de
> 22769 Hamburg pgp: http://wwwkeys.de.pgp.net
> +49 40 432 635 83 taxid: 57 / 126 / 16123
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGurUeYuGbqyQxpHcRAl3fAKCFrCxPHJ1FVZ4EaacwwCe3AHRhNgCg qXoQ
iGL+rd34mvtAK8ElwtrmQPU=
=fjri
-----END PGP SIGNATURE-----
Re: Extensions & Services [message #94674 is a reply to message #94660] Thu, 09 August 2007 09:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

> You could also use DeclarativeServices to receive your service
> references. That would be the OSGi way not the eclipse way.

Whilst I agree on your point about using DS (the linked article earlier looks into that) bear in mind that the extension registry bundle is an OSGi bundle and can be used in other OGSi environments. It's not necessarily specific to Eclipse.

Alex.
Re: Extensions & Services [message #94689 is a reply to message #94646] Thu, 09 August 2007 13:52 Go to previous messageGo to next message
Brett Humphreys is currently offline Brett HumphreysFriend
Messages: 17
Registered: July 2009
Junior Member
Sorry, I don't think I was very clear. I'm using the equinox extension registry to create my
extensions (using the createExecutableExtension mechanism). My extensions are being created just
fine and things are working well.

However it seems to me that extensions and services serve two different purposes and I wanted to
leverage them both. Specifically I was looking for a (clean) way for code instantiated via
"createExecutableExtension" to be able to acquire a reference to a service.

I could use DS, however its status is still red, and I'd really rather go with something more stable.

The solution I've come up with is write some static OSGi Utility methods which can get a bundle from
a given class (possibly an instantiated extension class), from it, get the bundle's context, and
then acquire resources from the service registry. This seems like an acceptable solution to me, but
wondered how other people were solving this issue.

It sounds like the eclipse platform just doesn't deal with the issue at all, and strictly uses
extensions?

-Brett



Alex Blewitt wrote:
> Usually, one bundle will scan for the extensions contributed by others, and invoke 'createExecutableExtension' for the things that it wants. That performs the magic to link the bundle wanting the extension to the bundle needing the extension. Most 'Eclipse' clients just use extensions.
>
> However, you don't have to just constrain yourself to using extensions if you want to use OSGi services instead. That's also possible.. And, since the extension registry is itself an OSGi bundle that can run on other OSGi environments, then there's no reason you can't ship that as well as your application.
>
> You might like to read:
>
> http://www.eclipsezone.com/eclipse/forums/t97608.rhtml
> (and its precursor, if you don't know what it is) as well as
> http://www.eclipsezone.com/articles/extensions-vs-services/
>
> Alex.
Re: Extensions & Services [message #94704 is a reply to message #94689] Thu, 09 August 2007 14:33 Go to previous message
Danail Nachev is currently offline Danail NachevFriend
Messages: 36
Registered: July 2009
Member
Hi, Brett

I'm not aware of all the possible ways to solve this. I think that the
most common way is to set activator to the bundle where extension class
is lives (the class which is instantiated via
createExecutableExtension()). The instantiated class will reference the
activator class directly and communicate with the framework.

You can always initialize the extension via some defined method and pass
the service (or bundle context object). However, you this means that you
have to get hold of the bundle context object, which means that you need
to find out the bundle which contributed the extension.

I think that the first option is much better, IMHO:)

Danail

Brett Humphreys wrote:
> Sorry, I don't think I was very clear. I'm using the equinox extension
> registry to create my extensions (using the createExecutableExtension
> mechanism). My extensions are being created just fine and things are
> working well.
>
> However it seems to me that extensions and services serve two different
> purposes and I wanted to leverage them both. Specifically I was looking
> for a (clean) way for code instantiated via "createExecutableExtension"
> to be able to acquire a reference to a service.
>
> I could use DS, however its status is still red, and I'd really rather
> go with something more stable.
>
> The solution I've come up with is write some static OSGi Utility methods
> which can get a bundle from a given class (possibly an instantiated
> extension class), from it, get the bundle's context, and then acquire
> resources from the service registry. This seems like an acceptable
> solution to me, but wondered how other people were solving this issue.
>
> It sounds like the eclipse platform just doesn't deal with the issue at
> all, and strictly uses extensions?
>
> -Brett
>
>
>
> Alex Blewitt wrote:
>> Usually, one bundle will scan for the extensions contributed by
>> others, and invoke 'createExecutableExtension' for the things that it
>> wants. That performs the magic to link the bundle wanting the
>> extension to the bundle needing the extension. Most 'Eclipse' clients
>> just use extensions.
>>
>> However, you don't have to just constrain yourself to using extensions
>> if you want to use OSGi services instead. That's also possible.. And,
>> since the extension registry is itself an OSGi bundle that can run on
>> other OSGi environments, then there's no reason you can't ship that as
>> well as your application.
>>
>> You might like to read:
>>
>> http://www.eclipsezone.com/eclipse/forums/t97608.rhtml
>> (and its precursor, if you don't know what it is) as well as
>> http://www.eclipsezone.com/articles/extensions-vs-services/
>>
>> Alex.
Previous Topic:PDE MANIFEST.MF editor import-package error
Next Topic:LDAP Filter using Declarative Services
Goto Forum:
  


Current Time: Thu Apr 25 08:10:15 GMT 2024

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

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

Back to the top