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


Java BundleContext类代码示例

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


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

示例1: start

import org.osgi.framework.BundleContext; //导入依赖的package包/类
@Override
public void start ( final BundleContext context ) throws Exception
{
    super.start ( context );
    plugin = this;

    this.treeRoot = new WritableSet ( DisplayRealm.getRealm ( getWorkbench ().getDisplay () ) );
    this.treeRootManager = new ConnectionTreeManager ( this.treeRoot );

    this.connectionManager = new ConnectionManager ( context );

    for ( final Map.Entry<Class<?>, IAdapterFactory> entry : this.adaperFactories.entrySet () )
    {
        Platform.getAdapterManager ().registerAdapters ( entry.getValue (), entry.getKey () );
    }

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

示例2: StorageImpl

import org.osgi.framework.BundleContext; //导入依赖的package包/类
public StorageImpl ( final File file, final BundleContext context, final DataFilePool pool, final ScheduledExecutorService queryExecutor, final ScheduledExecutorService updateExecutor, final ScheduledExecutorService eventExecutor ) throws Exception
{
    super ( file, pool, queryExecutor, eventExecutor );

    this.updateExecutor = updateExecutor;

    this.heartbeatJob = updateExecutor.scheduleAtFixedRate ( new Runnable () {
        @Override
        public void run ()
        {
            heartbeat ();
        }
    }, 0, getHeartbeatPeriod (), TimeUnit.MILLISECONDS );

    // 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 ( StorageHistoricalItem.class, this, properties );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:21,代码来源:StorageImpl.java

示例3: createService

import org.osgi.framework.BundleContext; //导入依赖的package包/类
@Override
protected Entry<ComponentFactory> createService ( final UserInformation userInformation, final String configurationId, final BundleContext context, final Map<String, String> parameters ) throws Exception
{
    final ConfigurationDataHelper cfg = new ConfigurationDataHelper ( parameters );
    final String xml = cfg.getStringNonEmpty ( "configuration" );

    final XMIResource xmi = new XMIResourceImpl ();
    final Map<?, ?> options = new HashMap<Object, Object> ();
    final InputSource is = new InputSource ( new StringReader ( xml ) );
    xmi.load ( is, options );

    final Object c = EcoreUtil.getObjectByType ( xmi.getContents (), ParserPackage.Literals.COMPONENT );
    if ( ! ( c instanceof Component ) )
    {
        throw new RuntimeException ( String.format ( "Configuration did not contain an object of type %s", Component.class.getName () ) );
    }

    final ComponentFactoryWrapper wrapper = new ComponentFactoryWrapper ( this.executor, (Component)c );

    final Dictionary<String, ?> properties = new Hashtable<> ();
    final ServiceRegistration<ComponentFactory> handle = context.registerService ( ComponentFactory.class, wrapper, properties );

    return new Entry<ComponentFactory> ( configurationId, wrapper, handle );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:FactoryImpl.java

示例4: AbstractOsgiHiveCommon

import org.osgi.framework.BundleContext; //导入依赖的package包/类
public AbstractOsgiHiveCommon ( final BundleContext context, final Executor executor )
{
    this.context = context;
    this.executor = executor;

    if ( context != null )
    {
        this.authenticationImplementation = new TrackingAuthenticationImplementation ( context );
        this.authorizationManager = new TrackingAuthorizationImplementation ( context );
        this.authorizationTracker = new TrackingAuthorizationTracker ( context );

        this.auditLogTracker = new TrackingAuditLogImplementation ( context );

        setAuthenticationImplementation ( this.authenticationImplementation );
        setAuthorizationImplementation ( this.authorizationManager );
        setAuditLogService ( this.auditLogTracker );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:AbstractOsgiHiveCommon.java

示例5: setUp

import org.osgi.framework.BundleContext; //导入依赖的package包/类
protected void setUp() throws Exception {

		final BundleContext ctx = new MockBundleContext();
		prop.setProperty("foo", "bar");

		platform = new AbstractOsgiPlatform() {

			Properties getPlatformProperties() {
				return prop;
			}

			public BundleContext getBundleContext() {
				return ctx;
			}

			public void start() throws Exception {
			}

			public void stop() throws Exception {
			}

		};
	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:24,代码来源:AbstractOsgiPlatformTest.java

示例6: registerToSR

import org.osgi.framework.BundleContext; //导入依赖的package包/类
private static Set<ServiceRegistration<?>> registerToSR(final AutoCloseable instance,
        final BundleContext bundleContext,
        final Map<ServiceInterfaceAnnotation, String /* service ref name */> serviceNamesToAnnotations) {
    Set<ServiceRegistration<?>> serviceRegistrations = new HashSet<>();
    for (Entry<ServiceInterfaceAnnotation, String /* service ref name */> entry : serviceNamesToAnnotations
            .entrySet()) {
        ServiceInterfaceAnnotation annotation = entry.getKey();
        Class<?> requiredInterface = annotation.osgiRegistrationType();

        if (!annotation.registerToOsgi()) {
            LOG.debug("registerToOsgi for service interface {} is false - not registering", requiredInterface);
            continue;
        }

        Preconditions.checkState(requiredInterface.isInstance(instance),
                instance.getClass().getName() + " instance should implement " + requiredInterface.getName());
        Dictionary<String, String> propertiesForOsgi = createProps(entry.getValue());
        ServiceRegistration<?> serviceRegistration = bundleContext.registerService(requiredInterface.getName(),
                instance, propertiesForOsgi);
        serviceRegistrations.add(serviceRegistration);
    }
    return serviceRegistrations;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:BeanToOsgiServiceManager.java

示例7: activate

import org.osgi.framework.BundleContext; //导入依赖的package包/类
@Activate
void activate(BundleContext context) {
    this.context = context;

    if (doReplaceSslKeysAndReboot()) {
        return;
    }

    Runnable server = () -> {
        try {
            startServer();
        } catch (Exception e) {
            log.error("startServer failed", e);
        }
    };

    this.thread = new Thread(server, "Start-Server");
    this.thread.start();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:20,代码来源:Server.java

示例8: getServiceReference

import org.osgi.framework.BundleContext; //导入依赖的package包/类
/**
 * Returns a reference to the <em>best matching</em> service for the given classes and OSGi filter.
 * 
 * @param bundleContext OSGi bundle context
 * @param classes array of fully qualified class names
 * @param filter valid OSGi filter (can be <code>null</code>)
 * @return reference to the <em>best matching</em> service
 */
public static ServiceReference getServiceReference(BundleContext bundleContext, String[] classes, String filter) {
	// use #getServiceReference(BundleContext, String, String) method to
	// speed the service lookup process by
	// giving one class as a hint to the OSGi implementation

	String clazz = (ObjectUtils.isEmpty(classes) ? null : classes[0]);

	return getServiceReference(bundleContext, clazz, OsgiFilterUtils.unifyFilter(classes, filter));
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:OsgiServiceReferenceUtils.java

示例9: LocalMonitorQueryListener

import org.osgi.framework.BundleContext; //导入依赖的package包/类
public LocalMonitorQueryListener ( final BundleContext context, final String monitorQueryId, final ProxyMonitorQuery proxyMonitorQuery, final Lock lock ) throws InvalidSyntaxException
{
    super ( proxyMonitorQuery, lock, monitorQueryId );
    logger.info ( "Creating new listener - query: {}", monitorQueryId );

    this.tracker = new SingleServiceTracker<MonitorQuery> ( context, FilterUtil.createClassAndPidFilter ( MonitorQuery.class, monitorQueryId ), this.queryListener );
    this.tracker.open ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:9,代码来源:LocalMonitorQueryListener.java

示例10: getModuleFactoryBundleContext

import org.osgi.framework.BundleContext; //导入依赖的package包/类
@Override
public BundleContext getModuleFactoryBundleContext(final String factoryName) {
    Map.Entry<ModuleFactory, BundleContext> factoryBundleContextEntry = this.currentlyRegisteredFactories
            .get(factoryName);
    if (factoryBundleContextEntry == null || factoryBundleContextEntry.getValue() == null) {
        throw new NullPointerException("Bundle context of " + factoryName + " ModuleFactory not found.");
    }
    return factoryBundleContextEntry.getValue();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:ConfigTransactionControllerImpl.java

示例11: start

import org.osgi.framework.BundleContext; //导入依赖的package包/类
@Activate
private void start(BundleContext ctx) {

    this.ctx = ctx;

    this.statusViews.add(new OSCViewProvider<>(VIEW_FRAGMENT_ALERTS, AlertView.class, this.alertViewFactory));
    this.statusViews.add(new OSCViewProvider<>(VIEW_FRAGMENT_APPLIANCE_INSTANCES,
            ApplianceInstanceView.class, this.applianceInstanceViewFactory));
    this.statusViews.add(new OSCViewProvider<>(VIEW_FRAGMENT_JOBS, JobView.class,
            this.jobViewFactory));

    this.setupViews.add(new OSCViewProvider<>(VIEW_FRAGMENT_VIRTUALIZATION_CONNECTORS,
            VirtualizationConnectorView.class, this.virtualizationConnectorViewFactory));
    this.setupViews.add(new OSCViewProvider<>(VIEW_FRAGMENT_SECURITY_MANAGER_CONNECTORS,
            ManagerConnectorView.class, this.managerConnectorViewFactory));
    this.setupViews.add(new OSCViewProvider<>(VIEW_FRAGMENT_SECURITY_FUNCTION_CATALOG,
            ApplianceView.class, this.applicanceViewFactory));
    this.setupViews.add(new OSCViewProvider<>(VIEW_FRAGMENT_DISTRIBUTED_APPLIANCES,
            DistributedApplianceView.class, this.distributedApplicanceViewFactory));

    this.manageViews.add(new OSCViewProvider<>(VIEW_FRAGMENT_USERS, UserView.class,
            this.userViewFactory));
    this.manageViews.add(new OSCViewProvider<>(VIEW_FRAGMENT_ALARMS, AlarmView.class,
            this.alarmViewFactory));
    this.manageViews.add(new OSCViewProvider<>(VIEW_FRAGMENT_PLUGIN, PluginView.class,
            this.pluginViewFactory));
    this.manageViews.add(new OSCViewProvider<>(VIEW_FRAGMENT_SERVER, MaintenanceView.class,
            this.maintenanceViewFactory));
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:30,代码来源:MainUI.java

示例12: stop

import org.osgi.framework.BundleContext; //导入依赖的package包/类
@Override
public void stop ( final BundleContext context ) throws Exception
{
    this.handle.unregister ();

    this.factory.dispose ();

    this.executor.shutdown ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:10,代码来源:Activator.java

示例13: ConfigurationFactoryImpl

import org.osgi.framework.BundleContext; //导入依赖的package包/类
public ConfigurationFactoryImpl ()
{
    final ReadWriteLock lock = new ReentrantReadWriteLock ();
    this.readLock = lock.readLock ();
    this.writeLock = lock.writeLock ();

    final BundleContext context = FrameworkUtil.getBundle ( DataContext.class ).getBundleContext ();

    this.executor = new ScheduledExportedExecutorService ( "org.eclipse.scada.da.server.exporter.rest", 1 );
    this.hiveSource = new ServiceListenerHiveSource ( context, this.executor );
    this.hiveSource.open ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:13,代码来源:ConfigurationFactoryImpl.java

示例14: stop

import org.osgi.framework.BundleContext; //导入依赖的package包/类
@Override
public void stop ( final BundleContext context ) throws Exception
{
    this.dataSourceTracker.close ();

    this.masterHandle.unregister ();
    this.masterFactory.dispose ();
    this.masterFactory = null;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:10,代码来源:Activator.java

示例15: createService

import org.osgi.framework.BundleContext; //导入依赖的package包/类
@Override
protected Entry<BufferedDataSource> createService ( final UserInformation userInformation, final String configurationId, final BundleContext context, final Map<String, String> parameters ) throws Exception
{
    logger.debug ( "Creating new change counter source: {}", configurationId );

    final BufferedDataSourceImpl source = new BufferedDataSourceImpl ( this.context, this.executor, this.poolTracker, this.dataNodeTracker, configurationId, objectPool );
    source.update ( parameters );

    return new Entry<BufferedDataSource> ( configurationId, source );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:11,代码来源:BufferedDatasourceFactory.java


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