|
Re: default autostart [message #125457 is a reply to message #125415] |
Tue, 03 February 2009 15:29 |
|
Erdal,
A known workaround is to have a bundle (which must be autostarted, of
course) listening to new RESOLVED bundle and automagically starting
them. See the code below (from the Toast project ;-)).
However, you may want to check if your problem couldn't be solved
autostarting only a very few strategic bundles (e.g.
org.eclipse.equinox.ds, even if PDE will now automatically set it to
autostart), and have dependencies automatically handle the starting of
other bundles....
Cheers,
Ben
Erdal Karaca a écrit :
> There is a setting in the equinox launcher to set the default autostart
> to true.
> Is there a matching setting which can be placed in the config.ini file?
>
> I found osgi.bundles.defaultStartLevel,
> but osgi.bundles.defaultAutoStart does not work.
>
> Is this an osgi param, or does the equinox launcher do this on its own?
>
/*********************************************************** ********************
* Copyright (c) 2008 Paul Vanderlei, Simon Archer, Jeff McAffer and
others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Toast is an Equinox/OSGi system developed for the book
* Eclipse, Equinox and OSGi -
* Creating Highly Modular Java Applications
* See http://equinoxosgi.org
*
* Contributors:
* Paul Vanderlei, Simon Archer and Jeff McAffer - initial API and
implementation
************************************************************ *******************/
package org.eclipse.equinox.internal.autostart;
import org.osgi.framework.*;
public class Autostarter implements BundleActivator, BundleListener {
public void start(BundleContext context) throws Exception {
context.addBundleListener(this);
Bundle[] bundles = context.getBundles();
for (int i = 0; i < bundles.length; i++)
start(bundles[i]);
}
private void start(Bundle bundle) {
boolean isFragment = bundle.getHeaders().get(Constants.FRAGMENT_HOST)
!= null;
if (!isFragment && bundle.getState() == Bundle.RESOLVED)
try {
bundle.start();
} catch (BundleException e) {
// TODO do nothing for now
}
}
public void stop(BundleContext context) throws Exception {
context.removeBundleListener(this);
}
public void bundleChanged(BundleEvent event) {
if (event.getType() == BundleEvent.RESOLVED)
start(event.getBundle());
}
}
My blog: http://blog.benjamin-cabe.com
|
|
|
|
Powered by
FUDForum. Page generated in 0.03088 seconds