当前位置: 首页>>代码示例>>Java>>正文


Java Constants类代码示例

本文整理汇总了Java中org.osgi.framework.Constants的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Constants类属于org.osgi.framework包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.osgi.framework.Constants; //导入依赖的package包/类
@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 );

}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:Activator.java

示例2: bindExtensionService

import org.osgi.framework.Constants; //导入依赖的package包/类
@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);
        }
    }

}
 
开发者ID:deepthinkit,项目名称:patternlab-for-sling,代码行数:22,代码来源:ExtensionRegistryService.java

示例3: installAndStartBundle

import org.osgi.framework.Constants; //导入依赖的package包/类
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");
       }
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:AbstractOnTheFlyBundleCreatorTests.java

示例4: testGetObjectWithFilterOnly

import org.osgi.framework.Constants; //导入依赖的package包/类
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);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:19,代码来源:OsgiSingleServiceProxyFactoryBeanTest.java

示例5: testStickinessWhenServiceGoesDown

import org.osgi.framework.Constants; //导入依赖的package包/类
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());
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:27,代码来源:OsgiServiceDynamicInterceptorListenerTest.java

示例6: getConfiguration

import org.osgi.framework.Constants; //导入依赖的package包/类
@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 );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:26,代码来源:ConfigurationManagerImpl.java

示例7: readFromManifest

import org.osgi.framework.Constants; //导入依赖的package包/类
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 );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:20,代码来源:Starter.java

示例8: setup

import org.osgi.framework.Constants; //导入依赖的package包/类
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;
    }

}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:22,代码来源:ServiceDiscoverer.java

示例9: registerService

import org.osgi.framework.Constants; //导入依赖的package包/类
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 );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:Activator.java

示例10: determinePlatform

import org.osgi.framework.Constants; //导入依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:17,代码来源:OsgiPlatformDetector.java

示例11: start

import org.osgi.framework.Constants; //导入依赖的package包/类
@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 );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:Activator.java

示例12: getServiceReferences

import org.osgi.framework.Constants; //导入依赖的package包/类
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 }) };
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:MockBundleContext.java

示例13: serviceChange

import org.osgi.framework.Constants; //导入依赖的package包/类
@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 );
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:23,代码来源:Activator.java

示例14: getPriority

import org.osgi.framework.Constants; //导入依赖的package包/类
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 );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:24,代码来源:ProxyDataSource.java

示例15: createDefaultManifest

import org.osgi.framework.Constants; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:32,代码来源:AbstractOnTheFlyBundleCreatorTests.java


注:本文中的org.osgi.framework.Constants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。