org.osgi.framework.Constants Java Examples

The following examples show how to use org.osgi.framework.Constants. 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: PropertiesDictionary.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
 public Object get(Object key) {
   if (key == Constants.OBJECTCLASS) {
     return (ocIndex >= 0) ? values[ocIndex] : null;
   } else if (key == Constants.SERVICE_ID) {
     return (sidIndex >= 0) ? values[sidIndex] : null;
   } else if (key == Constants.SERVICE_BUNDLEID) {
     return (sidIndex >= 0) ? values[sbidIndex] : null;
   } else if (key == Constants.SERVICE_SCOPE) {
     return (sidIndex >= 0) ? values[ssIndex] : null;
   }
   for (int i = size - 1; i >= 0; i--) {
     if (((String)key).equalsIgnoreCase(keys[i])) {
return values[i];
     }
   }
   return null;
 }
 
Example #2
Source File: InstallableUnitTest.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void fragmentSpecificPropertiesAddedToIU () throws Exception
{
    final boolean notOptional = false;
    final Boolean nullGreedyBoolean = null;
    final String noFilter = null;
    final String hostBundleName = "org.host.bundle";
    final String ownVersion = "1.0.7";
    final String hostVersionRange = "[1.0.1,2.0.0)";
    final VersionRangedName hostBundle = new VersionRangedName ( hostBundleName, VersionRange.valueOf ( hostVersionRange ) );
    final BundleInformation bi = new BundleInformation ();
    bi.setFragmentHost ( hostBundle );
    bi.setVersion ( Version.parseVersion ( ownVersion ) );
    final P2MetaDataInformation p2info = new P2MetaDataInformation ();

    final InstallableUnit iu = InstallableUnit.fromBundle ( bi, p2info );

    assertThat ( iu, hasProvided ( "osgi.fragment", hostBundleName, ownVersion ) );
    assertThat ( iu, hasRequired ( "osgi.bundle", hostBundleName, hostVersionRange, notOptional, nullGreedyBoolean, noFilter ) );
    final String fragmentHostEntry = Constants.FRAGMENT_HOST + ": " + hostBundleName + ";" + Constants.BUNDLE_VERSION_ATTRIBUTE + "=\"" + hostVersionRange + "\"";
    final Map<String, String> touchpointInstructions = iu.getTouchpoints ().get ( 0 ).getInstructions ();
    assertThat ( touchpointInstructions, hasEntry ( "manifest", containsString ( fragmentHostEntry ) ) );
}
 
Example #3
Source File: CommandTty.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void start(BundleContext bc) throws Exception {
  this.bc = bc;

  log(LogService.LOG_INFO, "Starting");

  // Get config
  Dictionary<String,String> p = new Hashtable<String,String>();
  p.put(Constants.SERVICE_PID, getClass().getName());
  bc.registerService(ManagedService.class, this, p);

  inStream  = new SystemIn(bc);
  outStream = System.out;
  errStream = System.err;

  cmdProcTracker = new ServiceTracker(bc, CommandProcessor.class, this);
  cmdProcTracker.open();

  logTracker = new ServiceTracker(bc, LogService.class, null);
  logTracker.open();

}
 
Example #4
Source File: Activator.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * (non-Javadoc)
 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
 * @param context
 * @throws Exception
 */
public void start(BundleContext context) throws Exception {
	plugin = this;
	bundleContext = context;
	// tracker the xml converter service
	String positiveFilter = new AndFilter(new EqFilter(Constants.OBJECTCLASS, Converter.class.getName()),
			new EqFilter(Converter.ATTR_TYPE, Xml2Xliff.TYPE_VALUE), new EqFilter(Converter.ATTR_DIRECTION,
					Converter.DIRECTION_POSITIVE)).toString();
	positiveTracker = new ServiceTracker(context, context.createFilter(positiveFilter), new XmlPositiveCustomizer());
	positiveTracker.open();

	String reverseFilter = new AndFilter(new EqFilter(Constants.OBJECTCLASS, Converter.class.getName()),
			new EqFilter(Converter.ATTR_TYPE, Xliff2Xml.TYPE_VALUE), new EqFilter(Converter.ATTR_DIRECTION,
					Converter.DIRECTION_REVERSE)).toString();
	reverseTracker = new ServiceTracker(context, context.createFilter(reverseFilter), new XmlReverseCustomize());
	reverseTracker.open();
}
 
Example #5
Source File: AbstractBundle.java    From concierge with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * remove all ServiceReferences for which the requesting bundle does not
 * have appropriate permissions
 * 
 * @param refs
 *            the references.
 * @return the permitted references.
 */
protected static final ServiceReference<?>[] checkPermissions(
		final ServiceReferenceImpl<?>[] refs) {
	final List<ServiceReferenceImpl<?>[]> results = new ArrayList<ServiceReferenceImpl<?>[]>(
			refs.length);
	final AccessControlContext controller = AccessController.getContext();
	for (int i = 0; i < refs.length; i++) {
		final String[] interfaces = (String[]) refs[i].properties
				.get(Constants.OBJECTCLASS);
		for (int j = 0; j < interfaces.length; j++) {
			try {
				controller.checkPermission(new ServicePermission(
						interfaces[j], ServicePermission.GET));
				results.add(refs);
				break;
			} catch (final SecurityException se) {
				// does not have the permission, try with the next interface
			}
		}
	}
	return results.toArray(new ServiceReference[results.size()]);
}
 
Example #6
Source File: ServicePojo.java    From concierge with Eclipse Public License 1.0 6 votes vote down vote up
public ServicePojo(final ServiceReference<?> sref) {
	id = ((Long) sref.getProperty(Constants.SERVICE_ID)).longValue();
	final Map<String, Object> props = new HashMap<String, Object>();
	for (final String key : sref.getPropertyKeys()) {
		props.put(key, sref.getProperty(key));
	}
	setProperties(props);

	setBundle(getBundleUri(sref.getBundle()));
	final List<String> usingBundlesList = new ArrayList<String>();

	if (sref.getUsingBundles() != null) {
		for (final Bundle using : sref.getUsingBundles()) {
			usingBundlesList.add(getBundleUri(using));
		}
	}
	setUsingBundles(usingBundlesList.toArray(new String[usingBundlesList.size()]));
}
 
Example #7
Source File: ResourceFilterImpl.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @param interfaces interface or class names
 * @return filter string which matches if the class implements one of the interfaces or the name of the class is
 *         contained in interfaces
 */
private String createFilter(String[] interfaces) {
    StringBuilder builder = new StringBuilder();
    builder.append("(&");
    builder.append("(|");
    List<String> whitelist = loadWhitelistExtension();
    if (whitelist == null) {
        logger.debug("No /res/whitelist.txt file found - scanning all unknown services");
        builder.append("(!(" + Constants.OBJECTCLASS + "=org.eclipse.smarthome.*))");
    } else {
        logger.debug("Whitelist /res/whitelist.txt file found - restricting scanning of services");
        whitelist.forEach(entry -> {
            builder.append("(" + Constants.OBJECTCLASS + "=" + entry + ")");
        });
    }
    for (String clazz : interfaces) {
        builder.append("(" + Constants.OBJECTCLASS + "=" + clazz + ")");
    }
    builder.append(")");
    builder.append("(!(" + PUBLISH + "=false)))");
    return builder.toString();
}
 
Example #8
Source File: NsToHtmlBundle.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public String toHTML(Requirement requirement)
{
  final StringBuffer sb = new StringBuffer(50);
  final String filter = requirement.getDirectives().get("filter");
  final String bundleName =
    Util.getFilterValue(filter, BundleRevision.BUNDLE_NAMESPACE);
  if (bundleName != null) {
    sb.append(bundleName);
    Util.appendVersion(sb, filter, Constants.BUNDLE_VERSION_ATTRIBUTE);
  } else {
    // Filter too complex to extract info from...
    sb.append(filter);
  }

  return sb.toString();
}
 
Example #9
Source File: GenericItemProvider.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
@Activate
public GenericItemProvider(final @Reference ModelRepository modelRepository,
        final @Reference GenericMetadataProvider genericMetadataProvider, Map<String, Object> properties) {
    this.modelRepository = modelRepository;
    this.genericMetaDataProvider = genericMetadataProvider;

    Object serviceRanking = properties.get(Constants.SERVICE_RANKING);
    if (serviceRanking instanceof Integer) {
        rank = (Integer) serviceRanking;
    } else {
        rank = 0;
    }

    itemFactorys.forEach(itemFactory -> dispatchBindingsPerItemType(null, itemFactory.getSupportedItemTypes()));

    // process models which are already parsed by modelRepository:
    for (String modelName : modelRepository.getAllModelNamesOfType("items")) {
        modelChanged(modelName, EventType.ADDED);
    }
    modelRepository.addModelRepositoryChangeListener(this);
}
 
Example #10
Source File: DependenciesCoreUtil.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
private static Collection<? extends ManifestItem> getManifestItems(Map<?, ?> map, String header) {
    final Object data = map.get(header);
    if (null != data) {
        final Collection<ManifestItem> list = new ArrayList<ManifestItem>();
        final String s = data.toString();
        if (!s.isEmpty()) {
            try {
                for (ManifestElement me : ManifestElement.parseHeader(header, data.toString())) {
                    final ManifestItem item = ManifestItem.newItem(header);
                    item.setName(me.getValue());
                    item.setVersion(me.getAttribute(item.getVersionAttribute()));
                    item.setOptional(Constants.RESOLUTION_OPTIONAL.equals(
                        me.getDirective(Constants.RESOLUTION_DIRECTIVE)));
                    item.setDescription(MessageFormat.format(Messages.DependenciesCoreUtil_userDefined, header));
                    list.add(item);
                }
            } catch (BundleException e) {
                ExceptionHandler.process(e);
            }
        }
        return list;
    }
    return null;
}
 
Example #11
Source File: JaxRsServiceTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static InputStream serviceBundle() {
    if (JavaUtils.isJava11Compatible()) {
        return TinyBundles.bundle()
              .add(AbstractServerActivator.class)
              .add(JaxRsTestActivator.class)
              .add(Book.class)
              .add(BookStore.class)
              .set(Constants.BUNDLE_ACTIVATOR, JaxRsTestActivator.class.getName())
              .set("Require-Capability", "osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version=11))\"")
              .build(TinyBundles.withBnd());
    } else {
        return TinyBundles.bundle()
            .add(AbstractServerActivator.class)
            .add(JaxRsTestActivator.class)
            .add(Book.class)
            .add(BookStore.class)
            .set(Constants.BUNDLE_ACTIVATOR, JaxRsTestActivator.class.getName())
            .build(TinyBundles.withBnd());
    }
}
 
Example #12
Source File: ServiceDiscoverer.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private synchronized void setup ()
{
    try
    {
        this.context.addServiceListener ( this, String.format ( "(%s=%s)", Constants.OBJECTCLASS, ConnectionService.class.getName () ) );
        final ServiceReference<?>[] refs = this.context.getAllServiceReferences ( ConnectionService.class.getName (), null );
        if ( refs != null )
        {
            for ( final ServiceReference<?> ref : refs )
            {
                addReference ( ref );
            }
        }
    }
    catch ( final InvalidSyntaxException e )
    {
        logger.warn ( "Invalid syntax when setting up filter", e );
        return;
    }

}
 
Example #13
Source File: SystemBundle.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * If the extension has an extension activator header process it.
 *
 * @param extension the extension bundle to process.
 */
private BundleActivator handleExtensionActivator(final BundleGeneration extension) throws BundleException {
  String extActivatorName =
    extension.archive.getAttribute(Constants.EXTENSION_BUNDLE_ACTIVATOR);
  extActivatorName = null!=extActivatorName ? extActivatorName.trim() : null;

  if (null != extActivatorName && extActivatorName.length() > 0) {
    fwCtx.log("Create bundle activator for extension: " + extension.symbolicName
              + ":" +extension.version + " using: " +extActivatorName);
    try {
      final Class<BundleActivator> c = (Class<BundleActivator>)Class.forName(extActivatorName);
      return c.newInstance();
    } catch (Throwable t) {
      final String msg = "Failed to instanciate extension activator " + extActivatorName + ", " + extension.bundle;
      fwCtx.log(msg, t);
      throw new BundleException(msg, BundleException.ACTIVATOR_ERROR, t);
    }
  }
  return null;
}
 
Example #14
Source File: Archive.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Check that we have a valid manifest.
 *
 * @exception IllegalArgumentException if we have a broken manifest.
 */
private void checkManifest() {
  final Attributes a = manifest.getMainAttributes();
  Util.parseManifestHeader(Constants.EXPORT_PACKAGE,
                           a.getValue(Constants.EXPORT_PACKAGE), false, true,
                           false);
  Util.parseManifestHeader(Constants.IMPORT_PACKAGE,
                           a.getValue(Constants.IMPORT_PACKAGE), false, true,
                           false);
  if (ba.storage.isReadOnly() && !file.isDirectory() && needUnpack(a)) {
    throw new IllegalArgumentException("Framework is in read-only mode, we can not " +
                                       "install bundles that needs to be downloaded " +
                                       "(e.g. has native code or an internal Bundle-ClassPath)");
  }
  // NYI, more checks?
}
 
Example #15
Source File: RepositoryCommandGroup.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void printRepos(PrintWriter out, SortedSet<RepositoryInfo> rs, String heading, boolean verbose) {
  out.println(heading != null ? heading : "E  Id Rank  Description");
  out.println("------------------------");
  final RepositoryManager rm = getRepositoryManager();
  for (RepositoryInfo ri : rs) {
    final String desc = (String) ri.getProperty(Constants.SERVICE_DESCRIPTION);
    final long id = ri.getId();
    out.print(rm.isEnabled(ri) ? '*' : ' ');
    out.print(Util.showRight(4, Long.toString(id)));
    out.print(" ");
    out.print(Util.showRight(4, Integer.toString(ri.getRank())));
    out.print("  ");
    out.println(desc);
    if (verbose) {
      out.println();
    }
  }
}
 
Example #16
Source File: MasterFactory.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Entry<MasterItemImpl> createService ( final UserInformation userInformation, final String configurationId, final BundleContext context, final Map<String, String> parameters ) throws Exception
{
    final MasterItemImpl service = new MasterItemImpl ( this.executor, context, configurationId, this.objectPoolTracker );

    service.update ( parameters );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( Constants.SERVICE_PID, configurationId );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( Constants.SERVICE_DESCRIPTION, "Master Data Item" );

    this.dataSourcePool.addService ( configurationId, service, properties );
    this.masterItemPool.addService ( configurationId, service, properties );

    return new Entry<MasterItemImpl> ( configurationId, service );
}
 
Example #17
Source File: Activator.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private void registerService ( final String id, final String uri, final ConnectionService service )
{
    final Dictionary<String, Object> properties = new Hashtable<String, Object> ();
    properties.put ( Constants.SERVICE_PID, id );
    properties.put ( ConnectionService.CONNECTION_URI, uri );

    final Class<?>[] clazzes = service.getSupportedInterfaces ();

    final String[] clazzStr = new String[clazzes.length];
    for ( int i = 0; i < clazzes.length; i++ )
    {
        clazzStr[i] = clazzes[i].getName ();
    }

    final ServiceRegistration<?> handle = getBundle ().getBundleContext ().registerService ( clazzStr, service, properties );
    this.registrations.add ( handle );
}
 
Example #18
Source File: Activator.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.instance = this;
    this.context = context;

    this.executor = Executors.newSingleThreadExecutor ( new NamedThreadFactory ( context.getBundle ().getSymbolicName () ) );
    this.factory = new SumSourceFactory ( context, this.executor );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "A summary data source" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( ConfigurationAdministrator.FACTORY_ID, context.getBundle ().getSymbolicName () );

    context.registerService ( ConfigurationFactory.class.getName (), this.factory, properties );
}
 
Example #19
Source File: JdbcAuthenticationServiceFactory.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Entry<JdbcAuthenticationService> createService ( final UserInformation userInformation, final String configurationId, final BundleContext context, final Map<String, String> parameters ) throws Exception
{
    logger.debug ( "Creating new service: {}", configurationId );
    final JdbcAuthenticationService service = new JdbcAuthenticationService ( context, configurationId );
    service.update ( parameters );

    final Dictionary<String, Object> properties = new Hashtable<String, Object> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "JDBC based authenticator" );
    properties.put ( Constants.SERVICE_PID, configurationId );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );

    final ServiceRegistration<?> handle;

    if ( service.isUserManager () )
    {
        handle = context.registerService ( new String[] { AuthenticationService.class.getName () }, service, properties );
    }
    else
    {
        handle = context.registerService ( new String[] { AuthenticationService.class.getName (), UserManagerService.class.getName () }, service, properties );
    }

    return new Entry<JdbcAuthenticationService> ( configurationId, service, handle );
}
 
Example #20
Source File: AbstractYamlTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
public static void addCatalogItemsAsOsgiInUsualWay(ManagementContext mgmt, String catalogYaml, VersionedName bundleName, boolean force) {
    try {
        BundleMaker bundleMaker = new BundleMaker(mgmt);
        File bf = bundleMaker.createTempZip("test", MutableMap.of(
            new ZipEntry(BasicBrooklynCatalog.CATALOG_BOM), new ByteArrayInputStream(catalogYaml.getBytes())));
        if (bundleName!=null) {
            bf = bundleMaker.copyAddingManifest(bf, MutableMap.of(
                "Manifest-Version", "2.0",
                Constants.BUNDLE_SYMBOLICNAME, bundleName.getSymbolicName(),
                Constants.BUNDLE_VERSION, bundleName.getOsgiVersion().toString()));
        }
        ReferenceWithError<OsgiBundleInstallationResult> b = ((ManagementContextInternal)mgmt).getOsgiManager().get().install(
            new FileInputStream(bf) );

        b.checkNoError();
        
    } catch (Exception e) {
        throw Exceptions.propagate(e);
    }
}
 
Example #21
Source File: Activator.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.context = context;
    this.scheduler = ScheduledExportedExecutorService.newSingleThreadExportedScheduledExecutor ( context.getBundle ().getSymbolicName () + ".scheduler" );
    this.factory = new MovingAverageDataSourceFactory ( context, this.scheduler );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "An averaging data source over time" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( ConfigurationAdministrator.FACTORY_ID, context.getBundle ().getSymbolicName () );

    context.registerService ( ConfigurationFactory.class.getName (), this.factory, properties );
}
 
Example #22
Source File: HSDBItemController.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public HSDBItemController ( final String id, final ScheduledExecutorService executor, final BundleContext context, final HSDBValueSource source )
{
    this.source = source;

    final Map<String, Variant> properties = new HashMap<String, Variant> ();

    final HistoricalItemInformation information = new HistoricalItemInformation ( id, properties );
    this.item = new HSDBHistoricalItem ( executor, source, information );

    final Dictionary<String, Object> serviceProperties = new Hashtable<String, Object> ();
    serviceProperties.put ( Constants.SERVICE_PID, id );
    serviceProperties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    this.handle = context.registerService ( HistoricalItem.class, this.item, serviceProperties );
}
 
Example #23
Source File: ConfigurationService.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
private @Nullable Configuration toConfiguration(Dictionary<String, Object> dictionary) {
    if (dictionary == null) {
        return null;
    }
    Map<String, Object> properties = new HashMap<>(dictionary.size());
    Enumeration<String> keys = dictionary.keys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        if (!Constants.SERVICE_PID.equals(key)) {
            properties.put(key, dictionary.get(key));
        }
    }
    return new Configuration(properties);
}
 
Example #24
Source File: CMCommands.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Filter tryToCreateFilterFromPidContainingWildcards(String pidContainingWildcards)
    throws Exception
{
  return tryToCreateFilterFromLdapExpression("(" + Constants.SERVICE_PID
                                             + "=" + pidContainingWildcards
                                             + ")");
}
 
Example #25
Source File: Concierge.java    From concierge with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked" })
protected <T> T getService(final Class<T> cls, final Version version) {
	final List<ServiceReference<?>> refs = serviceRegistry
			.lookup(cls.getName());
	for (final ServiceReference<?> ref : refs) {
		final Version other = (Version) ref
				.getProperty(Constants.VERSION_ATTRIBUTE);
		if (other != null && other.compareTo(version) == 0) {
			return (T) ((ServiceReferenceImpl<?>) ref).service;
		}
	}
	return null;
}
 
Example #26
Source File: HttpServiceUtilTest.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
private ServiceReference<?>[] getSecureHttpServiceReferences() {
    ServiceReference<?> ref1 = mock(ServiceReference.class);
    when(ref1.getProperty(HTTP_PORT_SECURE)).thenReturn("48081");
    when(ref1.getProperty(Constants.SERVICE_RANKING)).thenReturn("1");

    ServiceReference<?> ref2 = mock(ServiceReference.class);
    when(ref2.getProperty(HTTP_PORT_SECURE)).thenReturn("48080");
    when(ref2.getProperty(Constants.SERVICE_RANKING)).thenReturn("2");

    return new ServiceReference[] { ref1, ref2 };
}
 
Example #27
Source File: ServiceRestartCountCalculator.java    From sling-whiteboard with Apache License 2.0 5 votes vote down vote up
private void recordUnknownServiceUnregistration(ServiceEvent event) {
    String[] classNames = (String[]) event.getServiceReference().getProperty(Constants.OBJECTCLASS);
    synchronized (unidentifiedRegistrationsByClassName) {
        for ( String className : classNames )
            unidentifiedRegistrationsByClassName.compute(className, (k,v) -> v == null ? 1 : ++v);
    }
}
 
Example #28
Source File: Activator.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void start(BundleContext bc) throws Exception { 
  System.out.println(bc.getBundle().getHeaders()
                     .get(Constants.BUNDLE_NAME) + 
                     " starting..."); 
  Activator.bc = bc; 
  ServiceReference reference = 
    bc.getServiceReference(DateService.class.getName()); 

  DateService service = (DateService)bc.getService(reference); 
  System.out.println("Using DateService: formatting date: " + 
                     service.getFormattedDate(new Date())); 
  bc.ungetService(reference); 
}
 
Example #29
Source File: BundleInformationParser.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private void attachLocalization ( final BundleInformation result, final Attributes ma ) throws IOException
{
    String loc = ma.getValue ( Constants.BUNDLE_LOCALIZATION );
    if ( loc == null )
    {
        loc = Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME;
    }
    else
    {
        result.setBundleLocalization ( loc );
    }

    result.setLocalization ( ParserHelper.loadLocalization ( this.file, loc ) );
}
 
Example #30
Source File: StorageImpl.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public StorageImpl ( final BundleContext context, final File file, final DataFilePool pool, final ScheduledExecutorService queryExecutor, final ScheduledExecutorService eventExecutor ) throws Exception
{
    super ( file, pool, queryExecutor, eventExecutor );

    // register with OSGi
    final Dictionary<String, Object> properties = new Hashtable<String, Object> ( 2 );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( Constants.SERVICE_PID, this.id );
    this.handle = context.registerService ( HistoricalItem.class, this, properties );
}