Java Code Examples for org.osgi.framework.Constants

The following examples show how to use org.osgi.framework.Constants. These examples are extracted from open source projects. 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
@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 Project: brooklyn-server   Source File: AbstractYamlTest.java    License: 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 3
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 4
Source Project: cxf   Source File: JaxRsServiceTest.java    License: 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 5
Source Project: openhab-core   Source File: GenericItemProvider.java    License: 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 6
@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 7
Source Project: smarthome   Source File: ResourceFilterImpl.java    License: 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 Project: concierge   Source File: ServicePojo.java    License: 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 9
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 10
Source Project: tmxeditor8   Source File: Activator.java    License: 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 11
Source Project: tesb-studio-se   Source File: DependenciesCoreUtil.java    License: 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 12
Source Project: neoscada   Source File: ServiceDiscoverer.java    License: 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
/**
 * 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 Project: neoscada   Source File: Activator.java    License: 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 15
Source Project: neoscada   Source File: Activator.java    License: 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 16
Source Project: packagedrone   Source File: InstallableUnitTest.java    License: 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 17
Source Project: concierge   Source File: AbstractBundle.java    License: 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 18
Source Project: neoscada   Source File: MasterFactory.java    License: 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 19
/**
 * 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 20
@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 21
Source Project: openhab-core   Source File: HttpServiceUtilTest.java    License: 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 22
Source Project: packagedrone   Source File: Activator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void start ( final BundleContext context ) throws Exception
{
    final Path path = initPath ( context );
    if ( path != null )
    {
        this.manager = new AddonManagerImpl ( path );
        final Dictionary<String, Object> properties = new Hashtable<> ();
        properties.put ( Constants.SERVICE_DESCRIPTION, "Addon manager" );
        properties.put ( Constants.SERVICE_VENDOR, "Eclipse Package Drone" );
        this.handle = context.registerService ( AddonManager.class, this.manager, properties );
    }
}
 
Example 23
Source Project: smarthome   Source File: ConfigurationService.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private 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 (!key.equals(Constants.SERVICE_PID)) {
            properties.put(key, dictionary.get(key));
        }
    }
    return new Configuration(properties);
}
 
Example 24
Source Project: neoscada   Source File: Activator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void start ( final BundleContext context ) throws Exception
{
    this.executor = Executors.newSingleThreadExecutor ( new NamedThreadFactory ( context.getBundle ().getSymbolicName () ) );

    this.factory = new ProxyEventQueryFactory ( context, this.executor );

    final Hashtable<String, Object> properties = new Hashtable<String, Object> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA Proxy Event Query" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( ConfigurationAdministrator.FACTORY_ID, ProxyEventQueryFactory.FACTORY_ID );
    this.handle = context.registerService ( ConfigurationFactory.class, this.factory, properties );
}
 
Example 25
Source Project: netbeans   Source File: Activator.java    License: Apache License 2.0 5 votes vote down vote up
public @Override void start(final BundleContext context) throws Exception {
        if (System.getProperty("netbeans.home") != null) {
            throw new IllegalStateException("Should not be run from inside regular NetBeans module system");
        }
        String storage = context.getProperty(Constants.FRAMEWORK_STORAGE);
        if (storage != null) {
            System.setProperty("netbeans.user", storage);
        }
        System.setProperty("TopSecurityManager.disable", "true");
        NbBundle.setBranding(System.getProperty("branding.token"));
        OSGiMainLookup.initialize(context);
        queue = new DependencyQueue<String,Bundle>();
        this.context = context;
        framework = ((Framework) context.getBundle(0));
        if (framework.getState() == Bundle.STARTING) {
            LOG.fine("framework still starting");
            final AtomicReference<FrameworkListener> frameworkListener = new AtomicReference<FrameworkListener>();
            frameworkListener.set(new FrameworkListener() {
                public @Override void frameworkEvent(FrameworkEvent event) {
                    if (event.getType() == FrameworkEvent.STARTED) {
//                        System.err.println("framework started");
                        context.removeFrameworkListener(frameworkListener.get());
                        context.addBundleListener(Activator.this);
                        processLoadedBundles();
                    }
                }
            });
            context.addFrameworkListener(frameworkListener.get());
        } else {
            LOG.fine("framework already started");
            context.addBundleListener(this);
            processLoadedBundles();
        }
    }
 
Example 26
@Override
public int compare(ServiceReference<?> ref1, ServiceReference<?> ref2)
{
  final Long l1 = (Long) ref1.getProperty(Constants.SERVICE_ID);
  final Long l2 = (Long) ref2.getProperty(Constants.SERVICE_ID);
  return l1.compareTo(l2);
}
 
Example 27
Source Project: openhab-core   Source File: ThreadPoolManager.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected void modified(Map<String, Object> properties) {
    for (Entry<String, Object> entry : properties.entrySet()) {
        if (Constants.SERVICE_PID.equals(entry.getKey()) || ComponentConstants.COMPONENT_ID.equals(entry.getKey())
                || ComponentConstants.COMPONENT_NAME.equals(entry.getKey())) {
            continue;
        }
        String poolName = entry.getKey();
        Object config = entry.getValue();
        if (config == null) {
            configs.remove(poolName);
        }
        if (config instanceof String) {
            try {
                Integer poolSize = Integer.valueOf((String) config);
                configs.put(poolName, poolSize);
                ThreadPoolExecutor pool = (ThreadPoolExecutor) pools.get(poolName);
                if (pool instanceof ScheduledThreadPoolExecutor) {
                    pool.setCorePoolSize(poolSize);
                    LOGGER.debug("Updated scheduled thread pool '{}' to size {}", poolName, poolSize);
                } else if (pool instanceof QueueingThreadPoolExecutor) {
                    pool.setMaximumPoolSize(poolSize);
                    LOGGER.debug("Updated queuing thread pool '{}' to size {}", poolName, poolSize);
                }
            } catch (NumberFormatException e) {
                LOGGER.warn("Ignoring invalid configuration for pool '{}': {} - value must be an integer", poolName,
                        config);
                continue;
            }
        }
    }
}
 
Example 28
Source Project: orion.server   Source File: AboutHandler.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected PluginDetails pluginDetails(Bundle bundle) {
	String[] values = new String[] { getResourceString(bundle, Constants.BUNDLE_VENDOR), getResourceString(bundle, Constants.BUNDLE_NAME),
			getResourceString(bundle, Constants.BUNDLE_VERSION), bundle.getSymbolicName() };
	PluginDetails details = new PluginDetails(values);

	return details;
}
 
Example 29
Source Project: packagedrone   Source File: InstallableUnit.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private static String transformBundleName ( final String systemBundleAlias, final String id )
{
    if ( id.equals ( Constants.SYSTEM_BUNDLE_SYMBOLICNAME ) )
    {
        return systemBundleAlias;
    }
    else
    {
        return id;
    }
}
 
Example 30
public RepositoryInfo(ServiceReference<Repository> sr) {
  this.id = ((Long)sr.getProperty(Constants.SERVICE_ID)).longValue();
  Object r = sr.getProperty(Constants.SERVICE_RANKING);
  if (r != null && r instanceof Integer) {
    this.rank = ((Integer)r).intValue();
  } else {
    this.rank = 0;
  }
  this.sr = sr;
}