org.osgi.framework.Bundle.start()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中org.osgi.framework.Bundle.start()方法的一些代码示例,展示了Bundle.start()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.start()方法的具体详情如下:
包路径:org.osgi.framework.Bundle
类名称:Bundle
方法名:start

Bundle.start介绍

[英]Starts this bundle with no options.

This method performs the same function as calling start(0).
[中]启动此捆绑包时没有任何选项。
此方法执行与调用start(0)相同的函数。

代码示例

代码示例来源:origin: gocd/gocd

private Bundle getBundle(GoPluginDescriptor pluginDescriptor, File bundleLocation) {
  Bundle bundle = null;
  try {
    bundle = framework.getBundleContext().installBundle("reference:" + bundleLocation.toURI());
    pluginDescriptor.setBundle(bundle);
    bundle.start();
    if (pluginDescriptor.isInvalid()) {
      handlePluginInvalidation(pluginDescriptor, bundleLocation, bundle);
      return bundle;
    }
    IterableUtils.forEach(pluginChangeListeners, notifyPluginLoadedEvent(pluginDescriptor));
    return bundle;
  } catch (Exception e) {
    pluginDescriptor.markAsInvalid(asList(e.getMessage()), e);
    LOGGER.error("Failed to load plugin: {}", bundleLocation, e);
    handlePluginInvalidation(pluginDescriptor, bundleLocation, bundle);
    throw new RuntimeException("Failed to load plugin: " + bundleLocation, e);
  }
}

代码示例来源:origin: org.eclipse.core/runtime

public static void start(Bundle bundle) throws BundleException {
    int originalState = bundle.getState();
    if ((originalState & Bundle.ACTIVE) != 0)
      return; // bundle is already active
    try {
      // attempt to activate the bundle
      bundle.start(Bundle.START_TRANSIENT);
    } catch (BundleException e) {
      if ((originalState & Bundle.STARTING) != 0 && (bundle.getState() & Bundle.STARTING) != 0)
        // This can happen if the bundle was in the process of being activated on this thread, just return
        return;
      throw e;
    }
  }
}

代码示例来源:origin: spring-projects/spring-roo

public void start(String bundleSymbolicName) throws BundleException, InvalidSyntaxException {
 Bundle currentBundle = getBundle(bundleSymbolicName);
 System.out.println("Starting " + bundleSymbolicName + "; id: " + currentBundle.getBundleId()
   + " ...");
 currentBundle.start();
 System.out.println("Started!");
}

代码示例来源:origin: spring-projects/spring-roo

if (b != null)
  b.start();

代码示例来源:origin: spring-projects/spring-roo

((Bundle) startBundleList.get(i)).start();

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

public void startAll(List<Bundle> bundles) throws BundleException {
  for (Bundle b : bundles) {
    b.start();
  }
}

代码示例来源:origin: org.glassfish.hk2/osgi-adapter

public Object run() throws BundleException
  {
    bundle.start(Bundle.START_TRANSIENT);
    return null;
  }
});

代码示例来源:origin: apache/karaf

@Override
public void startBundle(Bundle bundle) throws BundleException {
  if (bundle != this.ourBundle || bundle.getState() != Bundle.STARTING) {
    bundle.start();
  }
}

代码示例来源:origin: stackoverflow.com

List<Bundle> installedBundles = new ArrayList<Bundle>();
for (URL url : urls) {
  installedBundles.add(context.installBundle(url.toString()));
}
for (Bundle bundle : installedBundles) {
  bundle.start();
}

代码示例来源:origin: apache/karaf

public void installBundle(String bundleLocation, boolean start) throws Exception {
  Bundle bundle = bundleContext.installBundle(bundleLocation);
  if (start) {
    bundle.start();
  }
}

代码示例来源:origin: org.motechproject/motech-osgi-platform

private void startBundle(Bundle bundle, BundleType bundleType) throws BundleException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Starting {} {}", new String[]{bundleType.name(), bundle.getSymbolicName()});
  }
  bundle.start();
}

代码示例来源:origin: apache/felix

public void startService(Long [] id) {
  try {
   bc.getBundle(id[0].longValue()).start();
  } catch (BundleException e) {
   e.printStackTrace();
  }
 }

代码示例来源:origin: org.eclipse/osgi

private static void startBundle(Bundle bundle, int options) {
  try {
    bundle.start(options);
  } catch (BundleException e) {
    if ((bundle.getState() & Bundle.RESOLVED) != 0) {
      // only log errors if the bundle is resolved
      FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_FAILED_START, bundle.getLocation()), 0, e, null);
      log.log(entry);
    }
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.osgi

private static void startBundle(Bundle bundle, int options) {
  try {
    bundle.start(options);
  } catch (BundleException e) {
    if ((bundle.getState() & Bundle.RESOLVED) != 0) {
      // only log errors if the bundle is resolved
      FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_FAILED_START, bundle.getLocation()), 0, e, null);
      log.log(entry);
    }
  }
}

代码示例来源:origin: apache/karaf

public long install(String url, boolean start) throws MBeanException {
  try {
    Bundle bundle = bundleContext.installBundle(url, null);
    if (start) {
      bundle.start();
    }
    return bundle.getBundleId();
  } catch (Exception e) {
    throw new MBeanException(null, e.toString());
  }
}

代码示例来源:origin: apache/karaf

public void start(String bundleId) throws MBeanException {
  try {
    List<Bundle> bundles = selectBundles(bundleId);
    for (Bundle bundle : bundles) {
      bundle.start();
    }
  } catch (Exception e) {
    throw new MBeanException(null, e.toString());
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.console

private void startBundle(String bsn, boolean required) throws BundleException {
  PackageAdmin pa = packageAdminTracker.getService();
  if (pa != null) {
    @SuppressWarnings("deprecation")
    Bundle[] shells = pa.getBundles(bsn, null);
    if (shells != null && shells.length > 0) {
      shells[0].start(Bundle.START_TRANSIENT);
    } else if (required) {
      throw new BundleException("Missing required bundle: " + bsn);
    }
  }
}

代码示例来源:origin: apache/karaf

public void restart(String bundleId) throws MBeanException {
  try {
    List<Bundle> bundles = selectBundles(bundleId);
    for (Bundle bundle : bundles) {
      bundle.stop();
      bundle.start();
    }
  } catch (Exception e) {
    throw new MBeanException(null, e.toString());
  }
}

代码示例来源:origin: org.apache.karaf.bundle/org.apache.karaf.bundle.core

public void restart(String bundleId) throws MBeanException {
  try {
    List<Bundle> bundles = selectBundles(bundleId);
    for (Bundle bundle : bundles) {
      bundle.stop();
      bundle.start();
    }
  } catch (Exception e) {
    throw new MBeanException(null, e.toString());
  }
}

代码示例来源:origin: org.aperteworkflow/integration

@Override
public void enablePlugin(PluginMetadata pluginMetadata) {
  try {
    felix.getBundleContext().getBundle(pluginMetadata.getId()).start();
    logger.warning("Started bundle " + pluginMetadata.getName());
  } catch (BundleException e) {
    logger.log(Level.SEVERE, "Failed to start plugin " + pluginMetadata.getName(), e);
    throw new PluginManagementException(e);
  }
}

相关文章