[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [equinox-dev] Creating and Starting a BundleActivator when the framework launches
|
Simon,
Maybe I misunderstood your problem, but there are a number of easy
solutions and I don't really see why you've dismissed all of them.
Firstly, why can't you get the Bundle object? You seem to be under the
impression that the Bundle object is only available within the bundle
that it describes. Actually any bundle can get the Bundle object for
any other bundle just by calling getBundle(id) or getBundles() on its
own BundleContext. You could even write a bundle that uses a
BundleListener to listen for Bundle Installed events, checks the value
of some header you define eg "Bundle-EarlyActivation", and immediately
starts those bundles.
If that's no good, what's wrong with IStartup? That works in any
Eclipse application that uses the Workbench. Is your application
entirely headless?
Finally, if your application is headless (or if it isn't), you can get the Bundle and start it from the IPlatformRunnable.
Regards,
Neil
On 4/9/06, Simon J Archer <sarcher@xxxxxxxxxx> wrote:
So my choices are:
- Call the Bundle object's start() method,
or
- Update a configuration file in the
local filesystem.
Hmmm, neither of these seem to be what
I'm looking for: Calling the Bundle's start() method assumes that I can
get the Bundle object for my bundle, which I usually do through the BundleContext,
which is not created until the BundleActivator's start has been called.
The configuration file is not really feasible since I'm talking about
building a bundle that is available for installation from an update site.
I would imagine that updating the config.ini is something you need
to do by hand before Eclipse is started.
Here's my scenario, in a nutshell:
"I wish to write a bundle that
can be installed into Eclipse from a update site. The bundle is "pure
model" (no UI) and has a BundleActivator that simply creates an instance
of the model class and registers it as a service with the OSGi framework.
To do this I shall be using the traditional BundleContext APIs, and
NOT declarative services. Other bundles will acquire the imported
service from the OSGi framework and therefore will never touch any of the
bundle's classes directly. Even the service interface used to implement
the service might be defined by another bundle, for which import/export
package dependencies will exist."
So far I'm stumped. Surely this
simple scenario should be supported by the Eclipse platform. Here
are some possible ways that Eclipse could be enhanced to help:
1. Add a manifest header that
informs the platform that this bundle should be started as soon as it is
installed. Even broadening the legal values for Eclipse-LazyStart
might suffice.
2. Add an extension point to the
platform (not UI) that causes the bundle to be started as soon as it is
installed.
3. Enhance the platform so that
when a bundle with a BundleActivator and an Export-Service header is installed
it is automatically started. This is probably my least favorite of
the 3, since an Export-Service header is purely informational and therefore
optional.
I'm happy to file a feature request
in bugzilla for this. Comments? Suggestions?
Thanks
Simon
BJ Hargrave/Austin/IBM@IBMUS
|
To
| |
cc
|
|
Subject
| Re: [equinox-dev] Creating and Starting
a BundleActivator when the framework
launches |
|
If you start the bundle with Bundle.start(), then
the framework will
persistently mark it started and will restart each time the framework is
started.
If you launch the framework with -console, you can follow that with
"install some://bundle/url start" to install and start a bundle.
You can also mark it to be started in the configuration/config.ini file.
See the osgi.bundles key:
# The comma-separated list of bundles which are automatically installed
and optionally started
# once the system is up and running. Each entry if of the form
# <URL | simple bundle location>[@ [<startlevel>]
[":start"]]
# If the startlevel is omitted then the framework will use the default
start level for the bundle.
# If the "start" tag is added then the bundle will be marked
as started
after being installed.
# Simple bundle locations are interepreted as relative to the framework's
parent directory.
# The startlevel indicates the OSGi start level at which the bundle should
run.
# If this value is not set, the system computes an appropriate default.
osgi.bundles=org.eclipse.equinox.common@2:start,
org.eclipse.update.configurator@3:start, org.eclipse.core.runtime@start
BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance
hargrave@xxxxxxxxxx
Office: +1 407 849 9117 Mobile: +1 386 848 3788
Simon J Archer/Raleigh/IBM@IBMUS
Sent by: equinox-dev-bounces@xxxxxxxxxxx
2006-04-08 07:24 AM
Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>
To
equinox-dev@xxxxxxxxxxx
cc
Subject
[equinox-dev] Creating and Starting a BundleActivator when the framework
launches
It is my understanding that simply having a BundleActivator class and a
Bundle-Activator header in the MANIFEST.MF is not enough to force the
bundle's activator to be created and started by Equinox when the framework
is launched.
I have learned that adding Eclipse-LazyStart: true to the MANIFEST.MF is
the way ensure that the bundle's activator is started when one of its
classes is first touched by another bundle.
But how am I to create a bundle that has a BundleActivator that is created
and started when the OSGi framework is launched? I am aware of the
org.eclipse.ui.startup extension point and accompanying IStartup class,
but I do not want to use that when my bundle is "pure model",
since they
reside in an Eclipse UI plug-in. I don't want to couple my model
to
anything UI related.
I'm building plugins that will run in the Eclipse IDE rather than pure
OSGi bundles, so I'm using an "Eclipse Application" launch configuration.
It is curious that only the "Equinox OSGi Framework" launch configurations
allow you to specify the default start level for a bundle and whether it
will start automatically when the framework launches.
While I understand that the early creation and starting of a bundle
activator is considered a bad thing by many Eclipse developers, it should
still be possible and should not be this hard.
Thanks
Simon
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev
--
Neil Bartlett
Senior Technical Consultant, Integility Ltd
Tel: +44 (0) 20 7043 8328
Fax: +44 (0) 20 7043 8329
LinkedIn Profile:
https://www.linkedin.com/in/neilbartlett