當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。