org.osgi.framework.Bundle Java Examples

The following examples show how to use org.osgi.framework.Bundle. 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: StartupOrderResolver.java    From carbon-kernel with Apache License 2.0 6 votes vote down vote up
/**
 * Process supported manifest headers (Startup-Component and Provide-Capability).
 * <p>
 * Process Startup-Component headers and create StartupComponent instances.
 * <p>
 * Process Provide-Capability headers to calculate the expected number of required capabilities.
 * <p>
 * Process Provide-Capability headers to get a list of CapabilityProviders and RequiredCapabilityListeners.
 *
 * @param bundleList list of bundles to be scanned for Provide-Capability headers.
 */
private void processManifestHeaders(List<Bundle> bundleList) {
    Map<String, List<ManifestElement>> groupedManifestElements =
            bundleList.stream()
                    // Filter out all the bundles with the Carbon-Component manifest header.
                    .filter(StartupOrderResolverUtils::isCarbonComponentHeaderPresent)
                    // Process filtered manifest headers and get a list of ManifestElements.
                    .map(StartupOrderResolverUtils::getManifestElements)
                    // Merge all the manifest elements lists into a single list.
                    .flatMap(Collection::stream)
                    // Partition all the ManifestElements with the manifest header name.
                    .collect(Collectors.groupingBy(ManifestElement::getValue));

    if (groupedManifestElements.get(STARTUP_LISTENER_COMPONENT) != null) {
        processServiceComponents(groupedManifestElements);
    }

    if (groupedManifestElements.get(OSGI_SERVICE_COMPONENT) != null) {
        processCapabilityProviders(groupedManifestElements.get(OSGI_SERVICE_COMPONENT));
        processOSGiServices(groupedManifestElements.get(OSGI_SERVICE_COMPONENT));
    }

    // You can add logic to handle other types of provide capabilities here.
    // e.g. custom manifest headers, config files etc.
}
 
Example #2
Source File: KFLegacyMetaTypeParser.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Load a MetaTypeProvider from an XML file.
 */
public static MTP loadMTPFromURL(Bundle bundle, URL url) throws IOException {
  InputStream in = null;

  try {
    in = url.openStream();
    final IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
    final IXMLReader reader = new StdXMLReader(in);
    parser.setReader(reader);
    final XMLElement el = (XMLElement) parser.parse();
    return loadMTP(bundle, url, el);
  } catch (final Throwable t) {
    throw (IOException) new IOException("Failed to load " + url + " " + t)
        .initCause(t);
  } finally {
    try {
      in.close();
    } catch (final Exception ignored) {
    }
  }

}
 
Example #3
Source File: ResourceManager.java    From developer-studio with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an {@link URL} based on a {@link Bundle} and resource entry path.
 */
private static URL getPluginImageURL(String symbolicName, String path) {
	// try runtime plugins
	{
		Bundle bundle = Platform.getBundle(symbolicName);
		if (bundle != null) {
			return bundle.getEntry(path);
		}
	}
	// try design time provider
	if (m_designTimePluginResourceProvider != null) {
		return m_designTimePluginResourceProvider.getEntry(symbolicName, path);
	}
	// no such resource
	return null;
}
 
Example #4
Source File: Spin.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static Color getColor(int state) {
  switch(state) {
  case Bundle.INSTALLED:
    return installedColor;
  case Bundle.ACTIVE:
    return activeColor;
  case Bundle.RESOLVED:
    return resolvedColor;
  case Bundle.UNINSTALLED:
    return uninstalledColor;
  case Bundle.STARTING:
    return startingColor;
  case Bundle.STOPPING:
    return stoppingColor;
  }

  return Color.black;
}
 
Example #5
Source File: PackageAdminImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public Bundle[] getBundles(String symbolicName, String versionRange) {
  final VersionRange vr = versionRange != null ? new VersionRange(versionRange.trim()) :
      null;
  final List<BundleGeneration> bgs = fwCtx.bundles.getBundles(symbolicName, vr);
  final int size = bgs.size();
  if (size > 0) {
    final Bundle[] res = new Bundle[size];
    final Iterator<BundleGeneration> i = bgs.iterator();
    for (int pos = 0; pos < size;) {
      res[pos++] = i.next().bundle;
    }
    return res;
  } else {
    return null;
  }
}
 
Example #6
Source File: LargeIconsDisplayer.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void addBundle0(final Bundle[] bundles) {
  if (bundles != null) {
    for (final Bundle bundle : bundles) {
      if(null == getBundleComponent(bundle)) {
        final JLabel c = createJLabelForBundle(bundle);

        c.setToolTipText(Util.bundleInfo(bundle));
        c.setVerticalTextPosition(SwingConstants.BOTTOM);
        c.setHorizontalTextPosition(SwingConstants.CENTER);

        c.setPreferredSize(new Dimension(96, 64));
        c.setBorder(null);
        c.setFont(getFont());

        bundleMap.put(new Long(bundle.getBundleId()), c);

        updateBundleComp(bundle);
      }
    }
  }
  rebuildPanel();
}
 
Example #7
Source File: XMLParserActivator.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Creates a new XML Parser Factory object.
 * 
 * <p>
 * A unique XML Parser Factory object is returned for each call to this
 * method.
 * 
 * <p>
 * The returned XML Parser Factory object will be configured for validating
 * and namespace aware support as specified in the service properties of the
 * specified ServiceRegistration object.
 * 
 * This method can be overridden to configure additional features in the
 * returned XML Parser Factory object.
 * 
 * @param bundle The bundle using the service.
 * @param registration The <code>ServiceRegistration</code> object for the
 *        service.
 * @return A new, configured XML Parser Factory object or null if a
 *         configuration error was encountered
 */
public Object getService(Bundle bundle, ServiceRegistration registration) {
	ServiceReference sref = registration.getReference();
	String parserFactoryClassName = (String) sref
			.getProperty(FACTORYNAMEKEY);
	// need to set factory properties
	Object factory = getFactory(parserFactoryClassName);
	if (factory instanceof SAXParserFactory) {
		((SAXParserFactory) factory).setValidating(((Boolean) sref
				.getProperty(PARSER_VALIDATING)).booleanValue());
		((SAXParserFactory) factory).setNamespaceAware(((Boolean) sref
				.getProperty(PARSER_NAMESPACEAWARE)).booleanValue());
	}
	else {
		if (factory instanceof DocumentBuilderFactory) {
			((DocumentBuilderFactory) factory)
					.setValidating(((Boolean) sref
							.getProperty(PARSER_VALIDATING)).booleanValue());
			((DocumentBuilderFactory) factory)
					.setNamespaceAware(((Boolean) sref
							.getProperty(PARSER_NAMESPACEAWARE))
							.booleanValue());
		}
	}
	return factory;
}
 
Example #8
Source File: RelationalActivator.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
public RelationalActivator() {
    instance = this;
    //Make sure the JNDI plugin is active
    AccessController.doPrivileged( new PrivilegedAction<Void>() {
        public Void run() {
            try {
                Bundle bundle = Platform.getBundle( "com.ibm.pvc.jndi.provider.java"); // $NON-NLS-1$
                if(bundle!=null) { // Empty during the unit tests
                    bundle.start();
                }
            } catch (BundleException ex) {
                if(RelationalLogger.RELATIONAL.isErrorEnabled()) {
                    RelationalLogger.RELATIONAL.errorp(this, "RelationalActivator", ex, "Exception occured activating the JNDI plugin"); // $NON-NLS-1$ $NLE-RelationalActivator.ExceptionoccuredactivatingtheJNDI-2$
                }
            }
            return null;
        }
    });
}
 
Example #9
Source File: SyntheticBundleInstaller.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
private static List<String> collectFilesFrom(Bundle bundle, String bundlePath, String bundleName,
        Set<String> extensionsToInclude) throws Exception {
    List<String> result = new ArrayList<>();
    URL url = getBaseURL(bundle, bundleName);
    if (url != null) {
        String path = url.getPath();
        URI baseURI = url.toURI();

        List<URL> list = collectEntries(bundle, path, extensionsToInclude);
        for (URL entryURL : list) {
            String fileEntry = convertToFileEntry(baseURI, entryURL);
            result.add(fileEntry);
        }
    }
    return result;
}
 
Example #10
Source File: Deconstructor.java    From vespa with Apache License 2.0 6 votes vote down vote up
@Override
public void deconstruct(Collection<Object> components, Collection<Bundle> bundles) {
    Collection<AbstractComponent> destructibleComponents = new ArrayList<>();
    for (var component : components) {
        if (component instanceof AbstractComponent) {
            AbstractComponent abstractComponent = (AbstractComponent) component;
            if (abstractComponent.isDeconstructable()) {
                destructibleComponents.add(abstractComponent);
            }
        } else if (component instanceof Provider) {
            // TODO Providers should most likely be deconstructed similarly to AbstractComponent
            log.log(FINE, () -> "Starting deconstruction of provider " + component);
            ((Provider<?>) component).deconstruct();
            log.log(FINE, () -> "Finished deconstruction of provider " + component);
        } else if (component instanceof SharedResource) {
            log.log(FINE, () -> "Releasing container reference to resource " + component);
            // No need to delay release, as jdisc does ref-counting
            ((SharedResource) component).release();
        }
    }
    if (! destructibleComponents.isEmpty() || ! bundles.isEmpty())
        executor.schedule(new DestructComponentTask(destructibleComponents, bundles),
                          delay.getSeconds(), TimeUnit.SECONDS);
}
 
Example #11
Source File: XdsResourcesUpdater.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @param installedUpdatesRegistry 
 * @param dirWithUpdatesPath directory where updates are
 * @param updateDirSubdirWithResource relative path where update is
 * @param newResourceName update resource name
 * @throws IOException
 * @throws FileNotFoundException
 * @return true if the resource was updated
 */
private boolean updateResource(InstalledUpdatesRegistry installedUpdatesRegistry, Bundle resourcesBundle, String dirWithUpdatesPath, Update update) {
	String newResourceRelativePath = update.newResourceLocation;
	String existingResourceRelativePath = update.existingResourceLocation;
	String xmlSchemaRelativePath = update.xmlSchemaLocation;
	Version version = update.version;
	File resourceFolderFile = null;
	try {
		resourceFolderFile = FileLocator.getBundleFile(resourcesBundle);
	} catch (IOException e) {
		LogHelper.logError(e);
		return false;
	}
	
	return updateResource(installedUpdatesRegistry, dirWithUpdatesPath,
			newResourceRelativePath, resourceFolderFile,
			existingResourceRelativePath, xmlSchemaRelativePath, version, true);
}
 
Example #12
Source File: BundleStartLevelResource.java    From concierge with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Representation put(final Representation value,
		final Variant variant) {
	try {
		final Bundle bundle = getBundleFromKeys(RestService.BUNDLE_ID_KEY);
		if (bundle == null) {
			return ERROR(Status.CLIENT_ERROR_NOT_FOUND);
		}
		final BundleStartLevelPojo sl = fromRepresentation(value, value.getMediaType());
		final BundleStartLevel bsl = bundle.adapt(BundleStartLevel.class);
		bsl.setStartLevel(sl.getStartLevel());

		return getRepresentation(new BundleStartLevelPojo(bsl), variant);
	} catch (final Exception e) {
		return ERROR(e, variant);
	}
}
 
Example #13
Source File: BundleHttpContext.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * DOCUMENT ME!
 *
 * @param name DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
public URL getResource(String name) {
    name = name.substring(1);

    String temp = name.substring(0, name.lastIndexOf("/"));
    String packageName = temp.replace('/', '.');

    for (int i = 0; i < exportedPackages.size(); i++) {
        Bundle b = ((Bundle) exportedPackages.get(i));
        ExportedPackage[] exp = packageAdmin.getExportedPackages(b);

        if (exp != null) {
            for (int j = 0; j < exp.length; j++) {
                if (exp[j].getName().equals(packageName)) {
                    return b.getResource(name);
                }
            }
        }
    }

    return null;
}
 
Example #14
Source File: BindingInfoXmlProvider.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
public BindingInfoXmlProvider(Bundle bundle, XmlBindingInfoProvider bindingInfoProvider,
        AbstractXmlConfigDescriptionProvider configDescriptionProvider) throws IllegalArgumentException {
    if (bundle == null) {
        throw new IllegalArgumentException("The Bundle must not be null!");
    }

    if (bindingInfoProvider == null) {
        throw new IllegalArgumentException("The XmlBindingInfoProvider must not be null!");
    }

    if (configDescriptionProvider == null) {
        throw new IllegalArgumentException("The XmlConfigDescriptionProvider must not be null!");
    }

    this.bundle = bundle;

    this.bindingInfoProvider = bindingInfoProvider;
    this.configDescriptionProvider = configDescriptionProvider;
}
 
Example #15
Source File: ZoomOutToolEntry.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private static ImageDescriptor findIconImageDescriptor(String iconPath) {
    String pluginId = "org.eclipse.gmf.runtime.diagram.ui.providers";
    Bundle bundle = Platform.getBundle(pluginId);
    try
    {
        if (iconPath != null) {
            URL fullPathString = FileLocator.find(bundle, new Path(iconPath), null);
            fullPathString = fullPathString != null ? fullPathString : new URL(iconPath);
            if (fullPathString != null) {
                return ImageDescriptor.createFromURL(fullPathString);
            }
        }
    }
    catch (MalformedURLException e)
    {
        Trace.catching(DiagramUIPlugin.getInstance(),
            DiagramUIDebugOptions.EXCEPTIONS_CATCHING,
            DefaultPaletteProvider.class, e.getLocalizedMessage(), e); 
        Log.error(DiagramUIPlugin.getInstance(),
            DiagramUIStatusCodes.RESOURCE_FAILURE, e.getMessage(), e);
    }
    
    return null;
}
 
Example #16
Source File: Activator.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 6 votes vote down vote up
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;

    if (Display.getCurrent() != null && PlatformUI.isWorkbenchRunning()) {
        Bundle bundle = Platform.getBundle(PLUGIN_ID);
  
        // for quick outline, add icons from YEdit
        bundle = Platform.getBundle(org.dadacoalition.yedit.Activator.PLUGIN_ID);
        addImage(bundle, Icons.outline_document.name(), "icons/outline_document.gif");
        addImage(bundle, Icons.outline_mapping.name(), "icons/outline_mapping.gif");
        addImage(bundle, Icons.outline_scalar.name(), "icons/outline_scalar.gif");
        addImage(bundle, Icons.outline_mapping_scalar.name(), "icons/outline_mappingscalar.gif");
        addImage(bundle, Icons.outline_sequence.name(), "icons/outline_sequence.png");
    }
}
 
Example #17
Source File: PackageManager.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Get the specified header name from a bundle and parse the value as package
 * names (ignoring all parameters and directives).
 *
 * @return a collection of strings
 */
protected Collection<String> getPackageNames(final Bundle b,
                                             final String headerName)
{
  final Set<String> res = new TreeSet<String>();
  final String v = b.getHeaders().get(headerName);

  if (v != null && v.length() > 0) {
    // Uses the manifest entry parser from the KF-framework
    try {
      for (final HeaderEntry he : org.knopflerfish.framework.Util
          .parseManifestHeader(headerName, v, false, false, false)) {
        res.addAll(he.getKeys());
      }
    } catch (final IllegalArgumentException iae) {
    }
  }
  return res;
}
 
Example #18
Source File: PackageManager.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Get the RequiredBundle object for this bundle.
 *
 * @param rbl
 *          List of required bundles as returend by package admin.
 * @param bundle
 *          The bundle to get requiring bundles for.
 * @return The RequiredBundle object for the given bundle or <tt>null</tt> if
 *         the bundle is not required.
 */
public RequiredBundle getRequiredBundle(final RequiredBundle[] rbl,
                                        final Bundle b)
{
  final RequiredBundle rb = requiredBundleMap.get(b);
  if (rb != null) {
    return rb;
  }
  for (int i = 0; rbl != null && i < rbl.length; i++) {
    final Bundle rbb = rbl[i].getBundle();
    if (rbb != null && rbb.getBundleId() == b.getBundleId()) {
      requiredBundleMap.put(b, rbl[i]);
      return rbl[i];
    }
  }
  requiredBundleMap.put(b, null);
  return null;
}
 
Example #19
Source File: Bundles.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get removal pending bundles.
 *
 * @return A Bundle array with bundles.
 */
void getRemovalPendingBundles(Collection<Bundle> res) {
  synchronized (bundles) {
    for (BundleImpl b : bundles.values()) {
      if (b.hasZombies()) {
        res.add(b);
      }
    }
    res.addAll(zombies);
  }
}
 
Example #20
Source File: WebJarControllerTest.java    From wisdom with Apache License 2.0 5 votes vote down vote up
@Test
public void testOnBundleWithWebJarsDirButEmpty() throws MalformedURLException {
    ApplicationConfiguration configuration = mock(ApplicationConfiguration.class);
    Crypto crypto = mock(Crypto.class);
    root = new File("target/wisdom-test");
    when(configuration.getBaseDir()).thenReturn(root);

    Bundle bundle = mock(Bundle.class);
    when(bundle.findEntries(WebJarController.WEBJAR_LOCATION, "*", true)).thenReturn(
            Iterators.asEnumeration(ImmutableList.of(new URL("file://61/" + WebJarController.WEBJAR_LOCATION))
                    .iterator())
    );

    WebJarController controller = new WebJarController(crypto, configuration, "assets/libs");
    List<BundleWebJarLib> libs = controller.addingBundle(bundle, null);
    assertThat(libs).isEmpty();
    assertThat(controller.indexSize()).isEqualTo(0);
    assertThat(controller.libs().size()).isEqualTo(0);

    // Same but with some junks.

    when(bundle.findEntries(WebJarController.WEBJAR_LOCATION, "*", true)).thenReturn(
            Iterators.asEnumeration(ImmutableList.of(
                    new URL("file://61/" + WebJarController.WEBJAR_LOCATION),
                    new URL("file://61/" + WebJarController.WEBJAR_LOCATION + "foo/"),
                    new URL("file://61/" + WebJarController.WEBJAR_LOCATION + "foo.txt")
            ).iterator())
    );

    controller = new WebJarController(crypto, configuration, "assets/libs");
    libs = controller.addingBundle(bundle, null);
    assertThat(libs).isEmpty();
    assertThat(controller.indexSize()).isEqualTo(0);
    assertThat(controller.libs().size()).isEqualTo(0);
}
 
Example #21
Source File: HttpClientFactory.java    From roboconf-platform with Apache License 2.0 5 votes vote down vote up
/**
 * The method to use when all the dependencies are resolved.
 * <p>
 * It means iPojo guarantees that both the manager and the HTTP
 * service are not null.
 * </p>
 *
 * @throws Exception
 */
public void start() throws Exception {

	// Is the DM part of the distribution?
	boolean found = false;
	for( Bundle b : this.bundleContext.getBundles()) {
		if( "net.roboconf.dm".equals( b.getSymbolicName())) {
			found = true;
			break;
		}
	}

	// If we are on an agent, we have nothing to do.
	// Otherwise, we must register a servlet.
	if( found ) {
		this.logger.fine( "iPojo registers a servlet for HTTP messaging." );

		Hashtable<String,String> initParams = new Hashtable<String,String> ();
		initParams.put( "servlet-name", "Roboconf DM (HTTP messaging)" );

		DmWebSocketServlet messagingServlet = new DmWebSocketServlet( this );
		this.httpService.registerServlet( HttpConstants.DM_SOCKET_PATH, messagingServlet, initParams, null );

	} else {
		this.logger.warning( "Roboconf's DM bundle was not found. No servlet will be registered." );
	}
}
 
Example #22
Source File: XmlDocumentBundleTracker.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private XmlDocumentProvider<T> acquireXmlDocumentProvider(Bundle bundle) {
    if (bundle == null) {
        return null;
    }

    XmlDocumentProvider<T> xmlDocumentProvider = bundleDocumentProviderMap.get(bundle);
    if (xmlDocumentProvider == null) {
        xmlDocumentProvider = xmlDocumentProviderFactory.createDocumentProvider(bundle);
        logger.trace("Create an empty XmlDocumentProvider for the module '{}'.", bundle.getSymbolicName());
        bundleDocumentProviderMap.put(bundle, xmlDocumentProvider);
    }
    return xmlDocumentProvider;
}
 
Example #23
Source File: I18nProviderImpl.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public @Nullable String getText(@Nullable Bundle bundle, @Nullable String key, @Nullable String defaultText,
        @Nullable Locale locale, @Nullable Object @Nullable... arguments) {
    String text = getText(bundle, key, defaultText, locale);

    if (text != null) {
        return MessageFormat.format(text, arguments);
    }

    return text;
}
 
Example #24
Source File: XmlBindingInfoProvider.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected BindingInfo localize(Bundle bundle, BindingInfo bindingInfo, Locale locale) {
    if (this.bindingI18nUtil == null) {
        return null;
    }

    String name = this.bindingI18nUtil.getName(bundle, bindingInfo.getUID(), bindingInfo.getName(), locale);
    String description = this.bindingI18nUtil.getDescription(bundle, bindingInfo.getUID(),
            bindingInfo.getDescription(), locale);

    return new BindingInfo(bindingInfo.getUID(), name, description, bindingInfo.getAuthor(),
            bindingInfo.getServiceId(), bindingInfo.getConfigDescriptionURI());
}
 
Example #25
Source File: BundleUpgradeParserTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
protected void checkParseUpgrades2(Bundle bundle) {
    Supplier<Iterable<RegisteredType>> typeSupplier = Suppliers.ofInstance(ImmutableList.of(
        new BasicRegisteredType(null, "bar", "2", null),
        new BasicRegisteredType(null, "bub", "2", null)));
    CatalogUpgrades upgrades = BundleUpgradeParser.parseBundleManifestForCatalogUpgrades(bundle, typeSupplier);
    
    assertFalse(upgrades.isEmpty());
    
    assertBundleUpgrade(upgrades, "foo", "0.1", "bun", "2.0.0");
    assertBundleUpgrade(upgrades, "foo", "9-bogus", "bun", "2.0.0");
    assertBundleUpgrade(upgrades, "foo", "1.5", "bun", "2.0.0");
    assertBundleUpgrade(upgrades, "foo", "3", null, null);
    
    assertBundleUpgrade(upgrades, "bun", "1", "bun", "2.0.0");
    assertBundleUpgrade(upgrades, "bun", "3", null, null);
    
    assertTypeUpgrade(upgrades, "foo", "1", "foo", "3");
    assertTypeUpgrade(upgrades, "foo", "2.2", null, null);
    assertTypeUpgrade(upgrades, "foo", "9-bogus", "foo", "3");
    
    assertTypeUpgrade(upgrades, "bar", "1", "bar", "2.0.0");
    assertTypeUpgrade(upgrades, "bar", "8", "bar", "2.0.0");
    assertTypeUpgrade(upgrades, "bar", "2-SNAPSHOT", "bar", "2.0.0");
    assertTypeUpgrade(upgrades, "bar", "2.0.0.SNAPSHOT", "bar", "2.0.0");
    
    assertTypeUpgrade(upgrades, "bub", "1", "bub", "2.0.0");
    assertTypeUpgrade(upgrades, "bub", "8", "bub", "2.0.0");
    assertTypeUpgrade(upgrades, "bub", "2-SNAPSHOT", null, null);
    
    assertTypeUpgrade(upgrades, "bar", "9-bogus-one", "foo9", "10.bogus");
    assertTypeUpgrade(upgrades, "bar", "9.bogus", "foo9", "10.bogus");
    assertTypeUpgrade(upgrades, "baz", "9-bogus-one", null, null);
    assertTypeUpgrade(upgrades, "bar", "9-bogut", null, null);
    assertTypeUpgrade(upgrades, "bar", "9.bogut", null, null);
}
 
Example #26
Source File: CXFExtensionBundleListener.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void register(final Bundle bundle) {
    Enumeration<?> e = bundle.findEntries("META-INF/cxf/", "bus-extensions.txt", false);
    while (e != null && e.hasMoreElements()) {
        List<Extension> orig = new TextExtensionFragmentParser(null).getExtensions((URL)e.nextElement());
        addExtensions(bundle, orig);
    }
}
 
Example #27
Source File: HtmlFolder.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public static File getFile(Bundle bundle, String page) {
	if (!isValid(bundle))
		return null;
	File file = new File(getDir(bundle), page);
	if (!file.exists()) {
		log.error("the requested file {} does not exist", file);
		return null;
	}
	return file;
}
 
Example #28
Source File: SectionDescriptor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handle the section error when an issue is found loading from the
 * configuration element.
 *
 * @param exception
 *            an optional CoreException
 */
private void handleSectionError(CoreException exception) {
	String pluginId = getConfigurationElement().getDeclaringExtension()
			.getContributor().getName();
	String message = TabbedPropertyMessages.SectionDescriptor_Section_error;
	if (exception == null) {
		message = MessageFormat.format(TabbedPropertyMessages.SectionDescriptor_Section_error, pluginId);
	} else {
		message = MessageFormat.format(TabbedPropertyMessages.SectionDescriptor_class_not_found_error, pluginId);
	}
	IStatus status = new Status(IStatus.ERROR, pluginId,
			TabbedPropertyViewStatusCodes.SECTION_ERROR, message, exception);
	Bundle bundle = FrameworkUtil.getBundle(SectionDescriptor.class);
	Platform.getLog(bundle).log(status);
}
 
Example #29
Source File: WorkspaceModelsManager.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
static public void setValuesProjectDescription(final IProject proj, final boolean builtin, final boolean inPlugin,
	final boolean inTests, final Bundle bundle) {
	/* Modify the project description */
	IProjectDescription desc = null;
	try {

		final List<String> ids = new ArrayList<>();
		ids.add(XTEXT_NATURE);
		ids.add(GAMA_NATURE);
		if ( inTests ) {
			ids.add(TEST_NATURE);
		} else if ( inPlugin ) {
			ids.add(PLUGIN_NATURE);
		} else if ( builtin ) {
			ids.add(BUILTIN_NATURE);
		}
		desc = proj.getDescription();
		desc.setNatureIds(ids.toArray(new String[ids.size()]));
		// Addition of a special nature to the project.
		if ( inTests && bundle == null ) {
			desc.setComment("user defined");
		} else if ( (inPlugin || inTests) && bundle != null ) {
			String name = bundle.getSymbolicName();
			final String[] ss = name.split("\\.");
			name = ss[ss.length - 1] + " plugin";
			desc.setComment(name);
		} else {
			desc.setComment("");
		}
		proj.setDescription(desc, IResource.FORCE, null);
		// Addition of a special persistent property to indicate that the project is built-in
		if ( builtin ) {
			proj.setPersistentProperty(BUILTIN_PROPERTY,
				Platform.getProduct().getDefiningBundle().getVersion().toString());
		}
	} catch (final CoreException e) {
		e.printStackTrace();
	}
}
 
Example #30
Source File: AbstractXmlBasedProvider.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Adds a {@link Collection} of objects to the internal list associated with the specified module.
 * <p>
 * This method returns silently, if any of the parameters is {@code null}.
 *
 * @param bundle the module to which the object is to be added
 * @param objectList the objects to be added
 */
public final synchronized void addAll(Bundle bundle, Collection<T_OBJECT> objectList) {
    if (objectList == null || objectList.isEmpty()) {
        return;
    }
    List<T_OBJECT> objects = acquireObjects(bundle);
    if (objects == null) {
        return;
    }
    objects.addAll(objectList);
    for (T_OBJECT object : objectList) {
        // just make sure no old entry remains in the cache
        removeCachedEntries(object);
    }
}