Java 类org.osgi.framework.Constants 实例源码

项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    this.poolTracker = new ObjectPoolTracker<MasterItem> ( context, MasterItem.class );
    this.poolTracker.open ();

    this.mapperPoolTracker = new ObjectPoolTracker<ValueMapper> ( context, ValueMapper.class );
    this.mapperPoolTracker.open ();

    this.factory = new MapperHandlerFactoryImpl ( context, this.poolTracker, this.mapperPoolTracker, 1001 /* after manual */);
    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "A value mapper master handler" );
    properties.put ( ConfigurationAdministrator.FACTORY_ID, MapperHandlerFactoryImpl.FACTORY_ID );
    context.registerService ( ConfigurationFactory.class.getName (), this.factory, properties );

}
项目:patternlab-for-sling    文件:ExtensionRegistryService.java   
@Reference(
        policy = ReferencePolicy.DYNAMIC,
        service = RuntimeExtension.class,
        cardinality = ReferenceCardinality.MULTIPLE
)
@SuppressWarnings("unused")
protected synchronized void bindExtensionService(RuntimeExtension extension, Map<String, Object> properties) {
    Integer newPriority = PropertiesUtil.toInteger(properties.get(Constants.SERVICE_RANKING), 0);
    String extensionName = PropertiesUtil.toString(properties.get(RuntimeExtension.NAME), "");
    Integer priority = PropertiesUtil.toInteger(mappingPriorities.get(extensionName), 0);
    if (newPriority > priority) {
        mapping = Collections.unmodifiableMap(add(mapping, extension, extensionName));
        mappingPriorities.put(extensionName, newPriority);
    } else {
        if (!mapping.containsKey(extensionName)) {
            mapping = Collections.unmodifiableMap(add(mapping, extension, extensionName));
            mappingPriorities.put(extensionName, newPriority);
        }
    }

}
项目:gemini.blueprint    文件:AbstractOnTheFlyBundleCreatorTests.java   
private void installAndStartBundle(BundleContext context, Resource resource) throws Exception {
    // install & start
    Bundle bundle = context.installBundle("[onTheFly-test-bundle]" + ClassUtils.getShortName(getClass()) + "["
            + hashCode() + "]", resource.getInputStream());

    String bundleString = OsgiStringUtils.nullSafeNameAndSymName(bundle);
    boolean debug = logger.isDebugEnabled();

    if (debug) {
        logger.debug("Test bundle [" + bundleString + "] successfully installed");
           logger.debug(Constants.FRAMEWORK_BOOTDELEGATION + " = " + context.getProperty(Constants.FRAMEWORK_BOOTDELEGATION));
       }
    bundle.start();
    if (debug) {
        logger.debug("Test bundle [" + bundleString + "] successfully started");
       }
}
项目:gemini.blueprint    文件:OsgiSingleServiceProxyFactoryBeanTest.java   
public void testGetObjectWithFilterOnly() throws Exception {
    this.serviceFactoryBean.setBundleContext(new MockBundleContext());
    this.serviceFactoryBean.setInterfaces(new Class<?>[] { Serializable.class });
    String filter = "(beanName=myBean)";
    this.serviceFactoryBean.setFilter(filter);

    MockServiceReference ref = new MockServiceReference();
    Dictionary dict = new Hashtable();
    dict.put(Constants.OBJECTCLASS, new String[] { Serializable.class.getName() });
    ref.setProperties(dict);

    serviceFactoryBean.setBeanClassLoader(getClass().getClassLoader());
    serviceFactoryBean.afterPropertiesSet();

    Object proxy = serviceFactoryBean.getObject();
    assertTrue(proxy instanceof Serializable);
    assertTrue("should be proxied", proxy instanceof SpringProxy);
}
项目:gemini.blueprint    文件:OsgiServiceDynamicInterceptorListenerTest.java   
public void testStickinessWhenServiceGoesDown() throws Exception {
    interceptor.setSticky(true);
    interceptor.afterPropertiesSet();

    ServiceListener sl = (ServiceListener) bundleContext.getServiceListeners().iterator().next();

    Dictionary props = new Hashtable();
    // increase service ranking
    props.put(Constants.SERVICE_RANKING, 10);

    ServiceReference higherRankingRef = new MockServiceReference(null, props, null);
    refs = new ServiceReference[] { new MockServiceReference(), higherRankingRef };

    assertTrue(Arrays.equals(bundleContext.getServiceReferences((String)null, null), refs));

    assertEquals(1, SimpleTargetSourceLifecycleListener.BIND);
    assertEquals(0, SimpleTargetSourceLifecycleListener.UNBIND);

    sl.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING, refs[0]));

    assertEquals(2, SimpleTargetSourceLifecycleListener.BIND);
    assertEquals(0, SimpleTargetSourceLifecycleListener.UNBIND);

    assertSame("incorrect backing reference selected", higherRankingRef, ((ServiceReferenceProxy) interceptor
            .getServiceReference()).getTargetServiceReference());
}
项目:neoscada    文件:ConfigurationManagerImpl.java   
@Override
public Configuration getConfiguration ()
{
    final List<ConfigurationGroup> groups = new LinkedList<ConfigurationGroup> ();

    Long lastRanking = null;
    ConfigurationGroupImpl lastGroup = null;

    for ( final Map.Entry<ServiceReference<AuthenticationService>, AuthenticationService> entry : this.tracker.getTracked ().entrySet () )
    {
        final Object o = entry.getKey ().getProperty ( Constants.SERVICE_RANKING );
        final long ranking = o instanceof Number ? ( (Number)o ).longValue () : 0;

        if ( lastRanking == null || lastRanking != ranking )
        {
            lastGroup = new ConfigurationGroupImpl ();
            groups.add ( lastGroup );
            lastRanking = ranking;
        }

        lastGroup.add ( entry.getValue () );
    }

    return new ConfigurationImpl ( groups );
}
项目:neoscada    文件:Starter.java   
private Bundle readFromManifest ( final String location, final Manifest m ) throws IOException
{
    final Object sn = m.getMainAttributes ().getValue ( Constants.BUNDLE_SYMBOLICNAME );
    if ( ! ( sn instanceof String ) )
    {
        return null;
    }

    final Object version = m.getMainAttributes ().getValue ( Constants.BUNDLE_VERSION );
    if ( ! ( version instanceof String ) )
    {
        return null;
    }

    String symName = (String)sn;
    symName = symName.split ( ";", 2 )[0];

    return new Bundle ( symName, new Version ( (String)version ), location );
}
项目:neoscada    文件:ServiceDiscoverer.java   
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;
    }

}
项目:neoscada    文件:Activator.java   
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 );
}
项目:gemini.blueprint    文件:OsgiPlatformDetector.java   
private static boolean determinePlatform(BundleContext context, String[] labels) {
    Assert.notNull(context);
    Assert.notNull(labels);

    String vendorProperty = context.getProperty(Constants.FRAMEWORK_VENDOR);
    if (vendorProperty == null) {
        return false; // might be running outside of container
    } else {
        // code defensively here to allow for variation in vendor name over
        // time
        if (containsAnyOf(vendorProperty, labels)) {
            return true;
        }
    }
    return false;
}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    this.executor = ExportedExecutorService.newSingleThreadExportedExecutor ( context.getBundle ().getSymbolicName () );

    this.dataSourceTracker = new ObjectPoolTracker<DataSource> ( context, DataSource.class );
    this.dataSourceTracker.open ();

    this.factory = new DeltaDataSourceFactory ( context, this.executor, this.dataSourceTracker );

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

    this.registration = context.registerService ( ConfigurationFactory.class, this.factory, properties );
}
项目:gemini.blueprint    文件:MockBundleContext.java   
public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
    // Some jiggery-pokery to get round the fact that we don't ever use the clazz
    if (clazz == null) {
        if (filter != null) {
            // flatten filter since the constants might be case insensitive
            String flattenFilter = filter.toLowerCase();
            int i = flattenFilter.indexOf(Constants.OBJECTCLASS.toLowerCase() + "=");
            if (i > 0) {
                clazz = filter.substring(i + Constants.OBJECTCLASS.length() + 1);
                clazz = clazz.substring(0, clazz.indexOf(")"));
            }
        } else {
            clazz = Object.class.getName();
           }
       }
    return new ServiceReference[] { new MockServiceReference(getBundle(), new String[] { clazz }) };
}
项目:neoscada    文件:Activator.java   
@Override
public void serviceChange ( final ServiceReference<Service> reference, final Service service )
{
    if ( Activator.this.localHdServerServiceRegistration != null )
    {
        Activator.this.localHdServerServiceRegistration.unregister ();
    }
    if ( service != null )
    {
        final Dictionary<String, Object> props = new Hashtable<String, Object> ();
        props.put ( Constants.SERVICE_RANKING, 20 );
        try
        {
            Activator.this.localHttpExporter = new LocalHttpExporter ( service );
            Activator.this.localHdServerServiceRegistration = context.registerService ( HttpExporter.class, Activator.this.localHttpExporter, props );
        }
        catch ( final Exception e )
        {
            logger.warn ( "Failed to handle service change", e );
        }
    }
}
项目:neoscada    文件:ProxyDataSource.java   
private int getPriority ( final String id, final Dictionary<?, ?> properties )
{
    final Object o = properties.get ( Constants.SERVICE_RANKING );

    if ( o == null )
    {
        return getDefaultPriority ( id );
    }

    if ( o instanceof Number )
    {
        return ( (Number)o ).intValue ();
    }

    try
    {
        return Integer.parseInt ( o.toString () );
    }
    catch ( final NumberFormatException e )
    {
        return getDefaultPriority ( id );
    }
}
项目:gemini.blueprint    文件:AbstractOnTheFlyBundleCreatorTests.java   
/**
 * Creates the default manifest in case none if found on the disk. By
 * default, the imports are synthetised based on the test class bytecode.
 * 
 * @return default manifest for the jar created on the fly
 */
protected Manifest createDefaultManifest() {
    Manifest manifest = new Manifest();
    Attributes attrs = manifest.getMainAttributes();

    // manifest versions
    attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
    attrs.putValue(Constants.BUNDLE_MANIFESTVERSION, "2");

    String description = getName() + "-" + getClass().getName();
    // name/description
    attrs.putValue(Constants.BUNDLE_NAME, "TestBundle-" + description);
    attrs.putValue(Constants.BUNDLE_SYMBOLICNAME, "TestBundle-" + description);
    attrs.putValue(Constants.BUNDLE_DESCRIPTION, "on-the-fly test bundle");

    // activator
    attrs.putValue(Constants.BUNDLE_ACTIVATOR, JUnitTestActivator.class.getName());

    // add Import-Package entry
    addImportPackage(manifest);

    if (logger.isDebugEnabled()) {
        logger.debug("Created manifest:" + manifest.getMainAttributes().entrySet());
       }
    return manifest;
}
项目:gemini.blueprint    文件:OsgiUtils.java   
public static String getPlatformName(BundleContext bundleContext) {
    String vendorProperty = bundleContext.getProperty(Constants.FRAMEWORK_VENDOR);
    String frameworkVersion = bundleContext.getProperty(Constants.FRAMEWORK_VERSION);

    // get system bundle
    Bundle bundle = bundleContext.getBundle(0);
    String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
    String version = (String) bundle.getHeaders().get(Constants.BUNDLE_VERSION);
    String symName = bundle.getSymbolicName();

    StringBuilder buf = new StringBuilder();
    buf.append(name);
    buf.append(" ");
    buf.append(symName);
    buf.append("|");
    buf.append(version);
    buf.append("{");
    buf.append(frameworkVersion);
    buf.append(" ");
    buf.append(vendorProperty);
    buf.append("}");

    return buf.toString();
}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.instance = this;

    if ( !Boolean.getBoolean ( "org.eclipse.scada.core.client.ngp.disableSharedProcessor" ) )
    {
        this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
    }
    this.factory = new DriverFactoryImpl ( this.processor );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( org.eclipse.scada.core.client.DriverFactory.INTERFACE_NAME, "hd" );
    properties.put ( org.eclipse.scada.core.client.DriverFactory.DRIVER_NAME, "ngp" );
    properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA HD NGP Adapter" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    this.handle = context.registerService ( org.eclipse.scada.core.client.DriverFactory.class, this.factory, properties );
}
项目:gemini.blueprint    文件:OsgiServiceDynamicInterceptorListenerTest.java   
public void testStickinessWhenABetterServiceIsAvailable() throws Exception {
    interceptor.setSticky(true);
    interceptor.afterPropertiesSet();

    ServiceListener sl = (ServiceListener) bundleContext.getServiceListeners().iterator().next();

    Dictionary props = new Hashtable();
    // increase service ranking
    props.put(Constants.SERVICE_RANKING, 10);

    ServiceReference ref = new MockServiceReference(null, props, null);
    ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, ref);

    assertEquals(1, SimpleTargetSourceLifecycleListener.BIND);
    assertEquals(0, SimpleTargetSourceLifecycleListener.UNBIND);

    sl.serviceChanged(event);

    assertEquals("the proxy is not sticky", 1, SimpleTargetSourceLifecycleListener.BIND);
    assertEquals(0, SimpleTargetSourceLifecycleListener.UNBIND);
}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    this.executor = ScheduledExportedExecutorService.newSingleThreadExportedScheduledExecutor ( context.getBundle ().getSymbolicName () );

    this.eventProcessor = new EventProcessor ( context );
    this.eventProcessor.open ();

    this.factory = new ScriptSourceFactory ( context, this.executor, this.eventProcessor );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "A scripting 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 );
}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.instance = this;

    if ( !Boolean.getBoolean ( "org.eclipse.scada.core.client.ngp.disableSharedProcessor" ) )
    {
        this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
    }
    this.factory = new DriverFactoryImpl ( this.processor );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( org.eclipse.scada.core.client.DriverFactory.INTERFACE_NAME, "ae" );
    properties.put ( org.eclipse.scada.core.client.DriverFactory.DRIVER_NAME, "ngp" );
    properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA AE NGP Adapter" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    this.handle = context.registerService ( org.eclipse.scada.core.client.DriverFactory.class, this.factory, properties );
}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    plugin = this;

    logger.info ( "Starting up..." );

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

    this.monitorPoolTracker = new ObjectPoolTracker<MonitorService> ( context, MonitorService.class );
    this.monitorPoolTracker.open ();

    this.dataSourcePool = new ObjectPoolImpl<DataSource> ();
    this.dataSourcePoolHandler = ObjectPoolHelper.registerObjectPool ( context, this.dataSourcePool, DataSource.class );

    this.factory = new InfoServiceFactory ( context, this.executor, this.monitorPoolTracker, this.dataSourcePool );
    final Dictionary<String, String> properties = new Hashtable<String, String> ( 2 );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( Constants.SERVICE_DESCRIPTION, "An aggregator for all monitor states" );
    properties.put ( ConfigurationAdministrator.FACTORY_ID, InfoServiceFactory.FACTORY_ID );

    this.factoryHandle = context.registerService ( ConfigurationFactory.class, this.factory, properties );
}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext bundleContext ) throws Exception
{
    Activator.context = bundleContext;

    this.itemPool = new ObjectPoolImpl<DataItem> ();

    this.itemPoolHandle = ObjectPoolHelper.registerObjectPool ( context, this.itemPool, DataItem.class );

    this.executor = ExportedExecutorService.newSingleThreadExportedExecutor ( context.getBundle ().getSymbolicName () );

    this.service = new ConfigurationFactoryImpl ( context, this.itemPool, this.executor );

    {
        final Dictionary<String, Object> properties = new Hashtable<String, Object> ();
        properties.put ( ConfigurationAdministrator.FACTORY_ID, "org.eclipse.scada.da.server.arduino.device" );
        properties.put ( Constants.SERVICE_DESCRIPTION, "Arduino Eclipse SCADA Device" );
        this.factoryHandle = context.registerService ( ConfigurationFactory.class, this.service, properties );
    }

}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    this.eventProcessor = new EventProcessor ( context );
    this.eventProcessor.open ();

    this.monitorServicePool = new ObjectPoolImpl<MonitorService> ();
    this.monitorServicePoolHandler = ObjectPoolHelper.registerObjectPool ( context, this.monitorServicePool, MonitorService.class );

    this.executor = ExportedExecutorService.newSingleThreadExportedExecutor ( context.getBundle ().getSymbolicName () + "/" + context.getBundle ().getBundleId () );

    // register factory
    this.factory = new EventMonitorFactory ( context, this.executor, this.monitorServicePool, this.eventProcessor );
    final Hashtable<String, Object> properties = new Hashtable<String, Object> ();
    properties.put ( ConfigurationAdministrator.FACTORY_ID, EventMonitorFactory.FACTORY_ID );
    properties.put ( Constants.SERVICE_DESCRIPTION, "Filter based event monitor" );
    this.factoryServiceHandle = context.registerService ( new String[] { ConfigurationFactory.class.getName (), AknHandler.class.getName () }, this.factory, properties );

    if ( this.manager == null )
    {
        this.manager = new EventInjectorManager ( this.factory );
        this.manager.start ();
    }
}
项目:Core    文件:OSGiUtils.java   
/**
 * Disable component if property "enabled" is set to false
 *
 * @param ctx component context
 */
private static void disableIfNeeded(Object obj, ComponentContext ctx) {
    OptionalComponent oc = obj.getClass().getAnnotation(OptionalComponent.class);

    if (oc == null) {
        return;
    }

    boolean enabled = PropertiesUtil.toBoolean(ctx.getProperties().get(oc.propertyName()), true);

    if (!enabled) {
        String pid = (String) ctx.getProperties().get(Constants.SERVICE_PID);
        LOG.info("disabling component {}", pid);

        // at this point this is the only way to reliably disable a component
        // it's going to show up as "unsatisfied" in Felix console.
        throw new ComponentException(format("Component %s is intentionally disabled", pid));
    }
}
项目:neoscada    文件:ProxyEventQueryFactory.java   
@Override
protected Entry<ProxyEventQuery> createService ( final UserInformation userInformation, final String configurationId, final BundleContext context, final Map<String, String> parameters ) throws Exception
{
    logger.info ( "Creating new proxy query: {}", configurationId );

    final ConfigurationDataHelper cfg = new ConfigurationDataHelper ( parameters );

    final int poolSize = cfg.getIntegerChecked ( "poolSize", "'poolSize' must be set" );
    if ( poolSize <= 0 )
    {
        throw new IllegalArgumentException ( "'poolSize' must be a positive integer greater zero" );
    }

    final ProxyEventQuery service = new ProxyEventQuery ( context, this.executor, poolSize, parameters );

    final Hashtable<String, Object> properties = new Hashtable<String, Object> ();
    properties.put ( Constants.SERVICE_PID, configurationId );
    final ServiceRegistration<EventQuery> handle = context.registerService ( EventQuery.class, service, properties );

    return new Entry<ProxyEventQuery> ( configurationId, service, handle );
}
项目:gemini.blueprint    文件:BeanNameServicePropertiesResolver.java   
public Map getServiceProperties(String beanName) {
    Map p = new MapBasedDictionary();
    if (StringUtils.hasText(beanName)) {
        p.put(BEAN_NAME_PROPERTY_KEY, beanName);
        p.put(SPRING_DM_BEAN_NAME_PROPERTY_KEY, beanName);
        p.put(BLUEPRINT_COMP_NAME, beanName);
    }

    String name = getSymbolicName();
    if (StringUtils.hasLength(name)) {
        p.put(Constants.BUNDLE_SYMBOLICNAME, name);
    }
    String version = getBundleVersion();
    if (StringUtils.hasLength(version)) {
        p.put(Constants.BUNDLE_VERSION, version);
    }
    return p;
}
项目:neoscada    文件:DefaultStorageHandlerFactory.java   
public DefaultStorageHandlerFactory ( final BundleContext context )
{
    this.serviceProperties.put ( Constants.SERVICE_DESCRIPTION, "Default storage handler" );
    this.serviceProperties.put ( EventHandlerFactory.FACTORY_ID, "defaultStorage" );

    this.context = context;
    this.tracker = new SingleServiceTracker<EventService> ( context, EventService.class, new SingleServiceListener<EventService> () {

        @Override
        public void serviceChange ( final ServiceReference<EventService> reference, final EventService service )
        {
            handleServiceChange ( service );
        }
    } );
    this.tracker.open ();
}
项目:gemini.blueprint    文件:OsgiServiceFactoryBean.java   
private Dictionary mergeServiceProperties(Map serviceProperties, String beanName) {
    MapBasedDictionary props = new MapBasedDictionary();

    // add service properties
    if (serviceProperties != null)
        props.putAll(serviceProperties);

    // eliminate any property that might clash with the official ones
    props.remove(OsgiServicePropertiesResolver.BEAN_NAME_PROPERTY_KEY);
    props.remove(OsgiServicePropertiesResolver.SPRING_DM_BEAN_NAME_PROPERTY_KEY);
    props.remove(OsgiServicePropertiesResolver.BLUEPRINT_COMP_NAME);
    props.remove(Constants.SERVICE_RANKING);

    // override any user property that might clash with the official ones
    props.putAll(propertiesResolver.getServiceProperties(beanName));

    if (ranking != 0) {
        props.put(Constants.SERVICE_RANKING, Integer.valueOf(ranking));
    }

    return props;
}
项目:neoscada    文件:HistoricalItemImpl.java   
public HistoricalItemImpl ( final HistoricalItemInformation itemInformation, final String masterId, final BundleContext context ) throws InvalidSyntaxException
{
    this.itemInformation = itemInformation;
    this.dataSourceId = masterId;

    this.valueBuffer = new LinkedList<DataItemValue> ();

    this.storageTracker = new SingleServiceTracker<StorageHistoricalItem> ( context, FilterUtil.createAndFilter ( StorageHistoricalItem.class.getName (), new MapBuilder<String, String> ().put ( Constants.SERVICE_PID, itemInformation.getItemId () ).getMap () ), new SingleServiceListener<StorageHistoricalItem> () {

        @Override
        public void serviceChange ( final ServiceReference<StorageHistoricalItem> reference, final StorageHistoricalItem service )
        {
            HistoricalItemImpl.this.setStorage ( service );
        }
    } );
    this.poolTracker = new ObjectPoolTracker<DataSource> ( context, DataSource.class );
}
项目:gemini.blueprint    文件:OsgiPlatformDetectorTest.java   
public void testEquinoxDetection() {
    props.put(Constants.FRAMEWORK_VENDOR,"Eclipse");
    BundleContext bc = new MockBundleContext(mockBundle,props);
    assertTrue("Detected as Equinox",OsgiPlatformDetector.isEquinox(bc));
    assertFalse(OsgiPlatformDetector.isKnopflerfish(bc));
    assertFalse(OsgiPlatformDetector.isFelix(bc));
}
项目:magic-bundle    文件:Activator.java   
private void unsetServiceReference(ServiceReference<Object> reference) {
    String objectClass = ((String[]) reference.getProperty(Constants.OBJECTCLASS))[0]; // TODO: 16.03.2017 when will this array have more than one element?

    if (RandomStringGenerator.class.getName().equals(objectClass))
        randomStringGeneratorServiceReference = null;
    else if (RandomNumberGenerator.class.getName().equals(objectClass))
        randomNumberGeneratorServiceReference = null;
}
项目:gemini.blueprint    文件:DefaultBundleContextProperties.java   
protected void initProperties() {
    put(Constants.FRAMEWORK_VERSION, getVersion());
    put(Constants.FRAMEWORK_VENDOR, "SpringSource");
    put(Constants.FRAMEWORK_LANGUAGE, System.getProperty("user.language"));
    put(Constants.FRAMEWORK_OS_NAME, System.getProperty("os.name"));
    put(Constants.FRAMEWORK_OS_VERSION, System.getProperty("os.version"));
    put(Constants.FRAMEWORK_PROCESSOR, System.getProperty("os.arch"));
}
项目:incubator-netbeans    文件:Activator.java   
static Set<String> provides(Dictionary<?,?> headers) {
    Set<String> deps = new TreeSet<String>(splitTokens((String) headers.get("OpenIDE-Module-Provides")));
    String name = (String) headers.get(Constants.BUNDLE_SYMBOLICNAME);
    if (name != null) {
        name = name.replaceFirst(";.+", "");
        deps.add("cnb." + name);
        if (name.equals("org.openide.modules")) {
            CoreBridge.defineOsTokens(deps);
        }
    }
    return deps;
}
项目:AgentWorkbench    文件:BundleEvaluator.java   
/**
 * Returns the bundle class path entries conform to the URL pattern (starting with a slash).
 * @param bundle the bundle
 * @return the bundle class path entries
 */
private Vector<String> getBundleClassPathEntries(Bundle bundle) {

    String bundleClassPath = bundle.getHeaders().get(Constants.BUNDLE_CLASSPATH);
    if (bundleClassPath==null) return null;

    Vector<String> bundleClassPathEntries = new Vector<>(Arrays.asList(bundleClassPath .split(",")));
    for (int i = 0; i < bundleClassPathEntries.size(); i++) {
        String bundleClassPathEntry = bundleClassPathEntries.get(i);
        if (bundleClassPathEntry.startsWith("/")==false) {
            bundleClassPathEntries.set(i, "/" + bundleClassPathEntry);
        }
    }
    return bundleClassPathEntries;
}
项目:neoscada    文件:AbstractConfigurationAdministrator.java   
private String getDescription ( final ServiceReference<?> reference )
{
    String description;
    if ( reference.getProperty ( Constants.SERVICE_DESCRIPTION ) instanceof String )
    {
        description = (String)reference.getProperty ( Constants.SERVICE_DESCRIPTION );
    }
    else
    {
        description = null;
    }
    return description;
}
项目:neoscada    文件:Console.java   
public synchronized void enableDummyAuthentication ()
{
    if ( this.authnHandle != null )
    {
        return;
    }

    final Dictionary<String, Object> properties = new Hashtable<String, Object> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "A dummy authentication service" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( Constants.SERVICE_RANKING, this.authenticationPriority );

    System.out.println ( String.format ( "Injecting dummy authentication service with priority: %s", this.authenticationPriority ) );
    this.authnHandle = this.context.registerService ( AuthenticationService.class, this.authenticationService, properties );
}
项目:neoscada    文件:Console.java   
public synchronized void enableDummyAuthorization ()
{
    if ( this.authzHandle != null )
    {
        return;
    }

    final Dictionary<String, Object> properties = new Hashtable<String, Object> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "A dummy authorization service" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( Constants.SERVICE_RANKING, this.authorizationPriority );

    System.out.println ( String.format ( "Injecting dummy authorization service with priority: %s", this.authorizationPriority ) );
    this.authzHandle = this.context.registerService ( AuthorizationManager.class, this.authorizationService, properties );
}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    logger.info ( "Starting file based DS" );
    this.service = new StorageImpl ();
    final Dictionary<String, Object> properties = new Hashtable<String, Object> ( 2 );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( Constants.SERVICE_DESCRIPTION, "A file based data store implemenentation" );
    context.registerService ( DataStore.class.getName (), this.service, properties );
}
项目:gemini.blueprint    文件:OsgiHeaderUtilsTest.java   
public void testGetRequireBundleWithMultipleBundlesAttributesAndWhitespaces() throws Exception {
    Properties props = new Properties();
    String pkg2 = "foo.bar";
    props.setProperty(Constants.REQUIRE_BUNDLE, "  " + PKG + ";visibility:=reexport;bundle-version=\"1.0\" ,\t  "
            + pkg2 + "\n  ");
    Bundle bundle = new MockBundle(props);
    String[] rb = OsgiHeaderUtils.getRequireBundle(bundle);

    assertSame(rb[0], rb[0].trim());
    assertSame(rb[1], rb[1].trim());
}
项目:neoscada    文件:Activator.java   
@Override
public void start ( final BundleContext context ) throws Exception
{
    this.service = new PropertyAuthenticationService ();

    final Dictionary<String, Object> properties = new Hashtable<String, Object> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "A plain authentication service based on a system property" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( Constants.SERVICE_RANKING, this.priority );

    context.registerService ( AuthenticationService.class.getName (), this.service, properties );
}