Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Using standalone OSGI bundles in Eclipse
Using standalone OSGI bundles in Eclipse [message #48788] Thu, 14 July 2005 13:00 Go to next message
Eclipse UserFriend
Originally posted by: USERjimirwin.DOMAINacm.org

My application is being written to run in the Eclipse workbench, but we
have future plans to split off parts that will run on remote servers. One
of the things we need to do is allow third parties to write addins to our
application.

I would like to allow third parties to write OSGi bundles to implement a
service interface that we specify, for instance to allow third parties to
write import services that transform their proprietary data formats into
our data model specification. I don't want to ask the third parties to re-
implement their addins for another non-Eclipse environment, so I would like
to be able to use addins that are not Eclipse dependent.

In phase 1 of our application which runs within Eclipse as a plugin, I
would like to have Eclipse install the third party OSGi bundles and make
them available to our application.

It appears that the problem is to get Eclipse to start the bundles and
allow them to register their services. Ideally, I would like to have that
under the control of my application, for instance to wait until the user
selects a particular import type before starting the bundle -- in other
words, lazy startup under the control of my application.

Finally, I would like to deploy the third-party addins within my plugin's
directory, for instance in eclipse/plugins/com.me.myapp_1.0.0/addins. It
appears that Eclipse 3.1 automatically discovers those bundles and installs
them, but doesn't start them. That means they don't get a chance to
register their services, and I can't discover their presence.

One workaround that might work is to get all bundles from my BundleContext,
and then walk through the list to find out if they came from my addin
directory, and then examine some property from the manifest to see if they
advertise support for my application, and then start them if I need to use
them.

This seems a little unwieldy. Is there a better way to accomplish it that
I overlooked or failed to find?

Thanks.

--
Jim Irwin
http://www.holoscenes.com
Re: Using standalone OSGI bundles in Eclipse [message #49079 is a reply to message #48788] Mon, 08 August 2005 15:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jeff_nospam_mcaffer.ca.ibm.com

Jim,

Sorry for the delay in answering this. Much of the team has been on holiday
etc. See embedded comments...

"jimirwin" <USERjimirwin@DOMAINacm.org> wrote in message
news:Xns96935B9ADD530jrixnews@206.191.52.34...
> In phase 1 of our application which runs within Eclipse as a plugin, I
> would like to have Eclipse install the third party OSGi bundles and make
> them available to our application.
>
> It appears that the problem is to get Eclipse to start the bundles and
> allow them to register their services. Ideally, I would like to have that
> under the control of my application, for instance to wait until the user
> selects a particular import type before starting the bundle -- in other
> words, lazy startup under the control of my application.

This is in fact the standard "Eclipse way". run no code before its time.
If you look at standard Eclipse bundles they all have Eclipse-Autostart:
true in the MANIFEST.MF. This is a signal to the runtime that this bundle
should be automatically started if someone attempts to load a class that it
supplies. The entire Eclipse UI (which is just an OSGi based application)
works this way. Click on a menu entry and the act of running the Action
causes the action to get loaded and the supplying plugin to be activated.

> Finally, I would like to deploy the third-party addins within my plugin's
> directory, for instance in eclipse/plugins/com.me.myapp_1.0.0/addins. It
> appears that Eclipse 3.1 automatically discovers those bundles and
installs
> them, but doesn't start them. That means they don't get a chance to
> register their services, and I can't discover their presence.

Ok, this is a bit different then what you are talking about above. If you
want the services registered, you have to start the bundles. That is the
way OSGi works. Declarative services are coming in R4 but not yet...

> One workaround that might work is to get all bundles from my
BundleContext,
> and then walk through the list to find out if they came from my addin
> directory, and then examine some property from the manifest to see if they
> advertise support for my application, and then start them if I need to use
> them.
>
> This seems a little unwieldy. Is there a better way to accomplish it that
> I overlooked or failed to find?

It is a little unwieldy but not all that unnatural. In effect that is what
the Eclipse Extension Registry and the OSGi Declarative services mechanisms
do. Check out EclipseBundleListener. It listens for bundles to become
resovled and then looks at them to see if they have a plugin.xml file. If
they do it parses the file and adds contents to the extension registry.

Jeff
Re: Using standalone OSGI bundles in Eclipse [message #49163 is a reply to message #49079] Mon, 08 August 2005 13:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: USERjimirwin.DOMAINacm.org

Thanks for your answer. I discovered that most of the difficulties were
due to my development/test runtime environment.

Since I was developing prototype addins along with the main application in
the same workspace, the addins were automatically installed from their
project directories every time I ran a test from within the IDE. When my
application attempted to install the addin bundles from its addin
directory, the class loader threw exceptions that the bundles had already
been installed from different locations. This prevented my application
from obtaining the bundles and starting them, and led me to think that the
only way to obtain the addin bundles was to walk the list of all installed
bundles.

When I discovered that I could override the runtime behavior so that
Eclipse didn't automatically load the addins from their project
directories, then my app could successfully install them from the addin
directory. If the bundle had already been installed there was no longer an
exception, and my app received the addin bundle and could start if it had
not already been started.

When the app is deployed, all addins will be deployed only into my app's
addin directory, and so the conflicting installation locations that occured
in the development environment will not occur.

--
Jim Irwin
http://www.holoscenes.com
Re: Using standalone OSGI bundles in Eclipse [message #53681 is a reply to message #49079] Tue, 29 November 2005 08:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kai.klesatschke.netallied.de

Jeff McAffer wrote:
> resovled and then looks at them to see if they have a plugin.xml file. If
> they do it parses the file and adds contents to the extension registry.

Hey Jeff,

I'm a beginner in using pure osgi and I wondered how to manual parse a
plugin.xml. Where can I find the facilities to parse plugin.xml and
manifest.mf?

Regards, Kai
Re: Using standalone OSGI bundles in Eclipse [message #53928 is a reply to message #53681] Fri, 02 December 2005 01:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jeff_nospam_mcaffer.ca.ibm.com

Gadzooks Kai! why would you want to manually parse these things? The
registry parses the plugin.xml for you and the framework parses the
manifest. Do you have a usecase for this or is it more curiosity? If it is
the former, please tell us more. If its the latter, we can point you to the
code but it certainly is not API.

Jeff

"Kai Klesatschke" <kai.klesatschke@netallied.de> wrote in message
news:dmh3b6$k87$1@news.eclipse.org...
> Jeff McAffer wrote:
> > resovled and then looks at them to see if they have a plugin.xml file.
If
> > they do it parses the file and adds contents to the extension registry.
>
> Hey Jeff,
>
> I'm a beginner in using pure osgi and I wondered how to manual parse a
> plugin.xml. Where can I find the facilities to parse plugin.xml and
> manifest.mf?
>
> Regards, Kai
Re: Using standalone OSGI bundles in Eclipse [message #54032 is a reply to message #53928] Fri, 02 December 2005 08:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kai.klesatschke.netallied.de

Jeff McAffer wrote:
> Gadzooks Kai!

Ups, did I ask about a no-no?

> why would you want to manually parse these things?

The idea:
I thought about using a runtime configuration for some sort of a "core"
plugin. The config (xml) sets the preferences for each bundle it needs
to run properly. The definition of the config elements for a specific
bundle should be defined by a schema (exsd like) provided by the
corresponding bundle.

Why the question:
The extension point schema is similar to my approach and I wanted to
have a look at equinox if there is some reuseable code.
Re: Using standalone OSGI bundles in Eclipse [message #54659 is a reply to message #54032] Mon, 12 December 2005 23:00 Go to previous message
Eclipse UserFriend
Originally posted by: jeff_nospam_mcaffer.ca.ibm.com

Ah, sure there are several parsers etc. Check out the parser code in the
new org.eclipse.equinox.registry bundle.

Jeff

"Kai Klesatschke" <kai.klesatschke@netallied.de> wrote in message
news:dmp0k1$hdp$1@news.eclipse.org...
> Jeff McAffer wrote:
> > Gadzooks Kai!
>
> Ups, did I ask about a no-no?
>
> > why would you want to manually parse these things?
>
> The idea:
> I thought about using a runtime configuration for some sort of a "core"
> plugin. The config (xml) sets the preferences for each bundle it needs
> to run properly. The definition of the config elements for a specific
> bundle should be defined by a schema (exsd like) provided by the
> corresponding bundle.
>
> Why the question:
> The extension point schema is similar to my approach and I wanted to
> have a look at equinox if there is some reuseable code.
Previous Topic:Knopflerfish to Equinox migration
Next Topic:Problems on OSX
Goto Forum:
  


Current Time: Wed Apr 24 16:45:26 GMT 2024

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

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

Back to the top