Java Code Examples for org.osgi.framework.Bundle#equals()

The following examples show how to use org.osgi.framework.Bundle#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JBundleHistory.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public boolean removeBundle(Bundle b) {
  Component[] cl = panel.getComponents();
  for(int i = 0; i < cl.length; i++) {
    JBundle jb = (JBundle)cl[i];
    if(b.equals(jb.b)) {
      panel.remove(cl[i]);
      cl = panel.getComponents();
      if(cl.length > 0) {
        lastBundle = ((JBundle)cl[cl.length-1]).b;
      } else {
        lastBundle = null;
      }
      resizeBundles();
      return true;
    }
  }
  return false;
}
 
Example 2
Source File: GraphDisplayer.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void removeBundle(Bundle b) {
  if(b.equals(bundle)) {
    if(bundleHistory.removeBundle(b)) {
      final Bundle last = bundleHistory.getLastBundle();
      if(last != null) {
        setBundle(last);
      }
    }
  }
}
 
Example 3
Source File: TargetPlatformUtil.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Sets the target platform for tests (to be used in tycho mainly)
 * @param context any class of the test bundle to be able to determine the test bundle
 * @since 2.14
 */
public static void setTargetPlatform(Class<?> context) throws Exception {
	if (isPdeLaunch()) {
		return;
	}
	Bundle currentBundle = FrameworkUtil.getBundle(context);
	ITargetPlatformService tpService = TargetPlatformService.getDefault();
	ITargetDefinition targetDef = tpService.newTarget();
	targetDef.setName("Tycho platform");
	Bundle[] bundles = Platform.getBundle("org.eclipse.core.runtime").getBundleContext().getBundles();
	List<ITargetLocation> bundleContainers = new ArrayList<ITargetLocation>();
	Set<File> dirs = new HashSet<File>();
	for (Bundle bundle : bundles) {
		if (bundle.equals(currentBundle)) {
			// we skip the current bundle, otherwise the folder for the target platform
			// will include the absolute directory of the maven parent project
			// since the projects are nested in the parent project the result
			// would be that Java packages of our project will be available twice
			// and Java won't be able to find our classes leading in compilation
			// errors during our tests.
			continue;
		}
		EquinoxBundle bundleImpl = (EquinoxBundle) bundle;
		Generation generation = (Generation) bundleImpl.getModule().getCurrentRevision().getRevisionInfo();
		File file = generation.getBundleFile().getBaseFile();
		File folder = file.getParentFile();
		if ((file.isFile() || Platform.inDevelopmentMode()) && !dirs.contains(folder)) {
			dirs.add(folder);
			bundleContainers.add(tpService.newDirectoryLocation(folder.getAbsolutePath()));
		}
	}
	targetDef.setTargetLocations(bundleContainers.toArray(new ITargetLocation[bundleContainers.size()]));
	targetDef.setArch(Platform.getOSArch());
	targetDef.setOS(Platform.getOS());
	targetDef.setWS(Platform.getWS());
	targetDef.setNL(Platform.getNL());
	// targetDef.setJREContainer()
	tpService.saveTargetDefinition(targetDef);

	Job job = new LoadTargetDefinitionJob(targetDef);
	job.schedule();
	job.join();
}
 
Example 4
Source File: TargetPlatformUtil.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Sets the target platform for tests (to be used in tycho mainly)
 * @param context any class of the test bundle to be able to determine the test bundle
 * @since 2.14
 */
public static void setTargetPlatform(Class<?> context) throws Exception {
	if (isPdeLaunch()) {
		return;
	}
	Bundle currentBundle = FrameworkUtil.getBundle(context);
	ITargetPlatformService tpService = TargetPlatformService.getDefault();
	ITargetDefinition targetDef = tpService.newTarget();
	targetDef.setName("Tycho platform");
	Bundle[] bundles = Platform.getBundle("org.eclipse.core.runtime").getBundleContext().getBundles();
	List<ITargetLocation> bundleContainers = new ArrayList<ITargetLocation>();
	Set<File> dirs = new HashSet<File>();
	for (Bundle bundle : bundles) {
		if (bundle.equals(currentBundle)) {
			// we skip the current bundle, otherwise the folder for the target platform
			// will include the absolute directory of the maven parent project
			// since the projects are nested in the parent project the result
			// would be that Java packages of our project will be available twice
			// and Java won't be able to find our classes leading in compilation
			// errors during our tests.
			continue;
		}
		EquinoxBundle bundleImpl = (EquinoxBundle) bundle;
		Generation generation = (Generation) bundleImpl.getModule().getCurrentRevision().getRevisionInfo();
		File file = generation.getBundleFile().getBaseFile();
		File folder = file.getParentFile();
		if (!dirs.contains(folder)) {
			dirs.add(folder);
			bundleContainers.add(tpService.newDirectoryLocation(folder.getAbsolutePath()));
		}
	}
	targetDef.setTargetLocations(bundleContainers.toArray(new ITargetLocation[bundleContainers.size()]));
	targetDef.setArch(Platform.getOSArch());
	targetDef.setOS(Platform.getOS());
	targetDef.setWS(Platform.getWS());
	targetDef.setNL(Platform.getNL());
	// targetDef.setJREContainer()
	tpService.saveTargetDefinition(targetDef);

	Job job = new LoadTargetDefinitionJob(targetDef);
	job.schedule();
	job.join();
}
 
Example 5
Source File: CMDisplayer.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
static boolean isCmBundle(final Bundle bundle) {
  final Bundle cmBundle = cmTracker.getServiceReference().getBundle();
  return cmBundle != null ? cmBundle.equals(bundle)  : false;
}