Java 类org.osgi.framework.startlevel.BundleStartLevel 实例源码

项目:neoscada    文件:Activator.java   
private void setStartLevel ( final String symbolicName, final int startLevel ) throws BundleException
{
    final Bundle bundle = findBundle ( symbolicName );
    if ( bundle == null )
    {
        return;
    }
    final BundleStartLevel bundleStartLevel = bundle.adapt ( BundleStartLevel.class );
    if ( bundleStartLevel == null )
    {
        return;
    }

    bundleStartLevel.setStartLevel ( startLevel < 0 ? this.defaultStartLevel : startLevel );
    bundle.start ();
}
项目:osgi-richconsole    文件:UpgradeProcess.java   
/**
 * Uninstalling an existing bundle
 *
 * @param symbolicName
 *            The symbolicName of the bundle
 * @param version
 *            The version of the bundle, optional. In case this parameter is null, the first bundle with the given
 *            symbolic name will be uninstalled.
 */
public void uninstallBundle(final String symbolicName, final String version) {
    Bundle bundle = bundleDeployerService.getExistingBundleBySymbolicName(symbolicName, version, null);
    if (bundle != null) {
        stateChanged = true;
        Logger.info("Uninstalling bundle: " + bundle);
        BundleStartLevel bundleStartLevel = bundle.adapt(BundleStartLevel.class);
        if (bundleStartLevel.getStartLevel() < currentFrameworkStartLevelValue) {
            setFrameworkStartLevel(bundleStartLevel.getStartLevel());
        }
        try {
            bundle.uninstall();
        } catch (BundleException e) {
            Logger.error("Error during uninstalling bundle: " + bundle.toString(), e);
        }
    }
}
项目:eclipse.jdt.ls    文件:BundleUtils.java   
/**
 * @param array
 */
private static IStatus startBundles(Collection<Bundle> bundles) {
    final BundleContext context = JavaLanguageServerPlugin.getBundleContext();
    MultiStatus status = new MultiStatus(context.getBundle().getSymbolicName(), IStatus.OK, "Starting added bundles", null);
    for (Bundle bundle : bundles) {
        if (bundle.getState() == Bundle.UNINSTALLED) {
            status.add(new Status(IStatus.ERROR, context.getBundle().getSymbolicName(), "Could not start: " + bundle.getSymbolicName() + '(' + bundle.getLocation() + ':' + bundle.getBundleId() + ')' + ". It's state is uninstalled."));
            continue;
        }
        if (bundle.getState() == Bundle.STARTING) {
            continue;
        }
        if (bundle.getBundleId() == 0) {
            continue;
        }

        try {
            // set to the default value for osgi.bundles.defaultStartLevel
            bundle.adapt(BundleStartLevel.class).setStartLevel(4);
            bundle.start(Bundle.START_ACTIVATION_POLICY);
            JavaLanguageServerPlugin.logInfo("Started " + bundle.getLocation());
        } catch (BundleException e) {
            status.add(new Status(IStatus.ERROR, context.getBundle().getSymbolicName(), "Bundle startup failed " + bundle.getLocation(), e));
        }
    }
    return status;

}
项目:eclipse.darker.theme    文件:DarkerThemer.java   
private void hookDarkerCore() {
  Bundle bundle = FrameworkUtil.getBundle(DarkerWeavingHook.class);
  try {
    if (bundle.getState()==Bundle.RESOLVED)
      bundle.start();
  } catch (BundleException e) {
    // TODO use log in future
    e.printStackTrace();
  }
  bundle.adapt(BundleStartLevel.class).setStartLevel(1);
}
项目:everest    文件:BundleResource.java   
public int getStartLevel() {
    BundleStartLevel bundleStartLevel = m_bundle.adapt(BundleStartLevel.class);
    return bundleStartLevel.getStartLevel();
}
项目:everest    文件:BundleResource.java   
public void setStartLevel(int startLevel) {
    BundleStartLevel bundleStartLevel = m_bundle.adapt(BundleStartLevel.class);
    bundleStartLevel.setStartLevel(startLevel);
}