Skip to main content

[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


Hi BJ

Yes, that is one possible solution.   Of course I would also want the headless bundle to be started during development when I'm launching an Eclipse runtime workbench.  It is for this reason that I'd like the Eclipse platform to be able to take care of things.  Ideally the fact that the bundle needs to be started immediately would be specified in the bundle's metadata (plugin.xml, manifest.mf, etc.)  In this way, it would not be the responsibility of any other artifact (such as the feature) to know whether a bundle needs to start immediately.  Rather it would be the bundle's responsibility to know, which sounds right to me.

Thanks again,

Simon




BJ Hargrave/Austin/IBM@IBMUS
Sent by: equinox-dev-bounces@xxxxxxxxxxx

04/09/2006 07:22 PM

Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>

To
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>
cc
Subject
Re: [equinox-dev] Creating and Starting a BundleActivator when the        framework launches





It seems you want Eclipse Update Manager to install AND start you bundle.
I am not familiar enough with Update Manager to say if possible and then
how to do it. Perhaps someone else can help?

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-09 06:11 PM
Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>


To
equinox-dev@xxxxxxxxxxx
cc

Subject
Re: [equinox-dev] Creating and Starting a BundleActivator when the
framework launches







Hi Neil

Thanks for the response.  I am very familiar with all the tricks available
via the BundleContext, but until my bundle is started, and a BundleContext
provided to me, none are possible.  The point of my posting is exactly
this: My model-based bundle that registers a service is never started.  I
hope now that you understand my dilemma.

Regarding IStartup, that is in a UI plugin, and sadly the extension point
requires the BundleActivator to implement an interface in a UI plugin.  I
do not want to create an unholy dependency upon any UI plugin, since my
bundle is purely headless.  Requiring the Eclipse UI would be madness. All
I want is to build a bundle on the Eclipse platform that starts as soon as
it is installed; it's really as simple as that.

Your point regarding IPlatformRunnable is of interest to me.  If my bundle
is not yet started, how am I to make use of IPlatformRunnable?  Remember,
I'm asking for a solution to the problem of providing one (or more)
model-based bundles that simply register OSGi services.  OSGi services are
not widely used yet in the Eclipse community, so I'm likey one of the few
that is running into this problem.

Thanks

Simon



"Neil Bartlett" <neil@xxxxxxxxxxxxxx>
Sent by: equinox-dev-bounces@xxxxxxxxxxx
04/09/2006 05:33 PM

Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>


To
"Equinox development mailing list" <equinox-dev@xxxxxxxxxxx>
cc

Subject
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

Sent by: equinox-dev-bounces@xxxxxxxxxxx
04/08/2006 08:09 AM


Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>


To
Equinox development mailing list < equinox-dev@xxxxxxxxxxx>
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
_______________________________________________
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


Back to the top