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


Java BundleContext.removeServiceListener方法代码示例

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


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

示例1: stop

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

    this.itemTracker.close ();
    this.poolTracker.close ();

    this.handle.unregister ();
    this.handle = null;

    this.service.stop ();
    this.service = null;

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

示例2: removeServiceListener

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
/**
 * Removes a service listener from the given bundle context. This method
 * simply takes care of any exceptions that might be thrown (in case the
 * context is invalid).
 * 
 * @param context bundle context to unregister the listener from
 * @param listener service listener to unregister
 * @return true if the listener unregistration has succeeded, false
 * otherwise (for example if the bundle context is invalid)
 */
public static boolean removeServiceListener(BundleContext context, ServiceListener listener) {
	if (context == null || listener == null)
		return false;

	try {
		context.removeServiceListener(listener);
		return true;
	}
	catch (IllegalStateException e) {
		// Bundle context is no longer valid
	}

	return false;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:25,代码来源:OsgiListenerUtils.java

示例3: waitOnContextCreation

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
/**
 * Waits for a <em>Spring powered</em> bundle, given by its symbolic name,
 * to be fully started.
 * 
 * <p/>Forces the current (test) thread to wait for the a Spring application
 * context to be published under the given symbolic name. This method allows
 * waiting for full initialization of Spring OSGi bundles before starting
 * the actual test execution.
 * 
 * @param context bundle context to use for service lookup
 * @param forBundleWithSymbolicName bundle symbolic name
 * @param timeout maximum time to wait (in seconds) for the application
 * context to be published
 */
protected void waitOnContextCreation(BundleContext context, String forBundleWithSymbolicName, long timeout) {
	// translate from seconds to milliseconds
	long time = timeout * SECOND;

	// use the counter to make sure the threads block
	final Counter counter = new Counter("waitForContext on bnd=" + forBundleWithSymbolicName);

	counter.increment();

	String filter = "(org.springframework.context.service.name=" + forBundleWithSymbolicName + ")";

	ServiceListener listener = new ServiceListener() {

		public void serviceChanged(ServiceEvent event) {
			if (event.getType() == ServiceEvent.REGISTERED)
				counter.decrement();
		}
	};

	OsgiListenerUtils.addServiceListener(context, listener, filter);

	if (logger.isDebugEnabled())
		logger.debug("Start waiting for Spring/OSGi bundle=" + forBundleWithSymbolicName);

	try {
		if (counter.waitForZero(time)) {
			waitingFailed(forBundleWithSymbolicName);
		}
		else if (logger.isDebugEnabled()) {
			logger.debug("Found applicationContext for bundle=" + forBundleWithSymbolicName);
		}
	}
	finally {
		// inform waiting thread
		context.removeServiceListener(listener);
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:52,代码来源:AbstractSynchronizedOsgiTests.java


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