• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SynchronousBundleListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: start

import org.osgi.framework.SynchronousBundleListener; //导入依赖的package包/类
@Override
public void start(BundleContext bundleContext) throws Exception {
    final String configAdminInit = bundleContext.getBundle().getHeaders().get("X-Aries-Blueprint-ConfigAdmin-Init");
    if (configAdminInit != null) {
        final BundleContext sysContext = bundleContext.getBundle(0).getBundleContext();
        // we are started before blueprint.core and felix.configadmin
        // we are sure that felix.configadmin is started before blueprint.core
        sysContext.addBundleListener(new SynchronousBundleListener() {
            @Override
            public void bundleChanged(BundleEvent event) {
                if (event.getType() == BundleEvent.STARTED
                        && "org.apache.felix.configadmin".equals(event.getBundle().getSymbolicName())) {
                    // configadmin should have already been started
                    ServiceReference<?> sr = sysContext.getServiceReference("org.osgi.service.cm.ConfigurationAdmin");
                    if (sr != null && sysContext.getService(sr) != null) {
                        initializeConfigAdmin(sysContext, configAdminInit);
                    }
                }
            }
        });
    }
}
 
开发者ID:mattrpav,项目名称:blueprint-test,代码行数:23,代码来源:BlueprintHelper.java


示例2: start

import org.osgi.framework.SynchronousBundleListener; //导入依赖的package包/类
@Override
public void start(BundleContext bundleContext) throws Exception {
    final String configAdminInit = bundleContext.getBundle().getHeaders().get("X-Camel-Blueprint-ConfigAdmin-Init");
    if (configAdminInit != null) {
        final BundleContext sysContext = bundleContext.getBundle(0).getBundleContext();
        // we are started before blueprint.core and felix.configadmin
        // we are sure that felix.configadmin is started before blueprint.core
        sysContext.addBundleListener(new SynchronousBundleListener() {
            @Override
            public void bundleChanged(BundleEvent event) {
                if (event.getType() == BundleEvent.STARTED
                        && "org.apache.felix.configadmin".equals(event.getBundle().getSymbolicName())) {
                    // configadmin should have already been started
                    ServiceReference<?> sr = sysContext.getServiceReference("org.osgi.service.cm.ConfigurationAdmin");
                    if (sr != null && sysContext.getService(sr) != null) {
                        initializeConfigAdmin(sysContext, configAdminInit);
                    }
                }
            }
        });
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:CamelBlueprintHelper.java


示例3: init

import org.osgi.framework.SynchronousBundleListener; //导入依赖的package包/类
@Override
public void init(ConfigurationProvider configurationProvider) {
	LOG.debug("Initializing observer configuration");
	tracker = new ServiceTracker<SessionFactoryObserver, SessionFactoryObserver>(bundleContext, SessionFactoryObserver.class,
			null);
	tracker.open();
	bundleContext.addBundleListener(new SynchronousBundleListener() {

		@Override
		public void bundleChanged(BundleEvent event) {
			if (event.getBundle().equals(bundleContext.getBundle()) && event.getType() == BundleEvent.STOPPING) {
				tracker.close();
				tracker = null;
			}
		}
	});
	configurationProvider.getConfiguration().setSessionFactoryObserver(this);
	configurationProvider.invalidate();
}
 
开发者ID:frincon,项目名称:openeos,代码行数:20,代码来源:ObserverConfigurator.java


示例4: ListenerBundleEvent

import org.osgi.framework.SynchronousBundleListener; //导入依赖的package包/类
/**
 * 监听插件安装事件,当有新插件安装或卸载时成功也更新一下
 */
public void ListenerBundleEvent(){
    BundleContextFactory.getInstance().getBundleContext()
            .addBundleListener(
                    new SynchronousBundleListener(){

                        public void bundleChanged(BundleEvent event) {
                            //把插件列表清空
                            bundles.clear();
                            BundleContext context =BundleContextFactory.getInstance().getBundleContext();
                            for(int i=0;i<context.getBundles().length;i++)
                            {
                                bundles.add(context.getBundles()[i]);

                            }
                            adapter.notifyDataSetChanged();
                        }

                    });
}
 
开发者ID:eoecn,项目名称:Libraries-for-Android-Developers,代码行数:23,代码来源:MainFragment.java


示例5: testCallGetResourceOnADifferentBundleRetrievedThroughBundleEvent

import org.osgi.framework.SynchronousBundleListener; //导入依赖的package包/类
public void testCallGetResourceOnADifferentBundleRetrievedThroughBundleEvent() throws Exception {
	String EXTRA_BUNDLE = "org.apache.servicemix.bundles.spring-core";

	Bundle[] bundles = bundleContext.getBundles();
	Bundle bundle = null;
	for (int i = 1; bundle == null && i < bundles.length; i++) {
		String location = bundles[i].getLocation();
		if (location != null && location.contains(EXTRA_BUNDLE))
			bundle = bundles[i];
	}

	assertNotNull("no bundle found", bundle);
	final Bundle sampleBundle = bundle;

	final boolean[] listenerCalled = new boolean[] { false };

	// register listener
	bundleContext.addBundleListener(new SynchronousBundleListener() {

		public void bundleChanged(BundleEvent event) {
			// call getResource
			event.getBundle().getResource(LOCATION);
			// call getResources
			try {
				event.getBundle().getResources(LOCATION);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}

			listenerCalled[0] = true;
		}
	});

	// update
	sampleBundle.stop();

	assertTrue("bundle listener hasn't been called", listenerCalled[0]);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:39,代码来源:CallingResourceOnDifferentBundlesTest.java


示例6: UIServiceTrackers

import org.osgi.framework.SynchronousBundleListener; //导入依赖的package包/类
/**
 * Constructs the registry and registers a bundle listener that will remove trackers for bundles that are stopping.
 * @param bundleContext the bundle context used to register the bundle listener
 */
public UIServiceTrackers(BundleContext bundleContext) {
    bundleContext.addBundleListener(new SynchronousBundleListener() {
        @Override
        public void bundleChanged(BundleEvent event) {
            if (event.getType() == BundleEvent.STOPPING) {
                removeTrackerFor(event.getBundle());
            }
        }
    });
}
 
开发者ID:motech,项目名称:motech,代码行数:15,代码来源:UIServiceTrackers.java


示例7: HttpServiceTrackers

import org.osgi.framework.SynchronousBundleListener; //导入依赖的package包/类
/**
 * Creates this http tracker registry and registers a bundle listener,
 * that will close the trackers for a bundle once it is stopped.
 *
 * @param bundleContext the context used for registering the bundle listener
 */
public HttpServiceTrackers(BundleContext bundleContext) {
    bundleContext.addBundleListener(new SynchronousBundleListener() {
        @Override
        public void bundleChanged(BundleEvent event) {
            if (event.getType() == BundleEvent.STOPPING) {
                removeTrackerFor(event.getBundle());
            }
        }
    });
}
 
开发者ID:motech,项目名称:motech,代码行数:17,代码来源:HttpServiceTrackers.java


示例8: addBundleListener

import org.osgi.framework.SynchronousBundleListener; //导入依赖的package包/类
public void addBundleListener(BundleListener bundleListener) {
    checkValid();
    List list = bundleListener instanceof SynchronousBundleListener ? Framework.syncBundleListeners : Framework.bundleListeners;
    if (this.bundle.registeredBundleListeners == null) {
        this.bundle.registeredBundleListeners = new ArrayList();
    }
    if (!this.bundle.registeredBundleListeners.contains(bundleListener)) {
        list.add(bundleListener);
        this.bundle.registeredBundleListeners.add(bundleListener);
    }
}
 
开发者ID:achellies,项目名称:AtlasForAndroid,代码行数:12,代码来源:BundleContextImpl.java


示例9: removeBundleListener

import org.osgi.framework.SynchronousBundleListener; //导入依赖的package包/类
public void removeBundleListener(BundleListener bundleListener) {
    checkValid();
    (bundleListener instanceof SynchronousBundleListener ? Framework.syncBundleListeners : Framework.bundleListeners).remove(bundleListener);
    this.bundle.registeredBundleListeners.remove(bundleListener);
    if (this.bundle.registeredBundleListeners.isEmpty()) {
        this.bundle.registeredBundleListeners = null;
    }
}
 
开发者ID:achellies,项目名称:AtlasForAndroid,代码行数:9,代码来源:BundleContextImpl.java


示例10: init

import org.osgi.framework.SynchronousBundleListener; //导入依赖的package包/类
@Override
public void init(final ConfigurationProvider configurationProvider) {
	LOG.debug("Initializing filter configuration");
	tracker = new ServiceTracker<FilterProvider, FilterProvider>(bundleContext, FilterProvider.class, null) {

		@Override
		public FilterProvider addingService(ServiceReference<FilterProvider> reference) {
			LOG.debug("Filter provider added as a service");
			FilterProvider provider = super.addingService(reference);
			addFilterDefinitions(provider, configurationProvider);
			return provider;
		}

		@Override
		public void removedService(ServiceReference<FilterProvider> reference, FilterProvider service) {
			LOG.debug("Filter provider removed");
			removeFilterDefinitions(service, configurationProvider);
			super.removedService(reference, service);
		}

	};
	tracker.open();
	bundleContext.addBundleListener(new SynchronousBundleListener() {

		@Override
		public void bundleChanged(BundleEvent event) {
			if (event.getBundle().equals(bundleContext.getBundle()) && event.getType() == BundleEvent.STOPPING) {
				tracker.close();
				tracker = null;
			}
		}
	});
}
 
开发者ID:frincon,项目名称:openeos,代码行数:34,代码来源:FilterConfigurator.java


示例11: testCallGetResourceOnADifferentBundleRetrievedThroughBundleEvent

import org.osgi.framework.SynchronousBundleListener; //导入依赖的package包/类
public void testCallGetResourceOnADifferentBundleRetrievedThroughBundleEvent() throws Exception {
	String EXTRA_BUNDLE = "org.springframework.core";

	Bundle[] bundles = bundleContext.getBundles();
	Bundle bundle = null;
	// find cglib library as we don't use it
	for (int i = 1; bundle == null && i < bundles.length; i++) {
		String location = bundles[i].getLocation();
		if (location != null && location.indexOf(EXTRA_BUNDLE) > -1)
			bundle = bundles[i];
	}

	assertNotNull("no bundle found", bundle);
	final Bundle sampleBundle = bundle;

	final boolean[] listenerCalled = new boolean[] { false };

	// register listener
	bundleContext.addBundleListener(new SynchronousBundleListener() {

		public void bundleChanged(BundleEvent event) {
			// call getResource
			event.getBundle().getResource(LOCATION);
			// call getResources
			try {
				event.getBundle().getResources(LOCATION);
			}
			catch (IOException e) {
				throw new RuntimeException(e);
			}

			listenerCalled[0] = true;
		}
	});

	// update
	sampleBundle.stop();

	assertTrue("bundle listener hasn't been called", listenerCalled[0]);
}
 
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:41,代码来源:CallingResourceOnDifferentBundlesTest.java


示例12: adaptBundleListener

import org.osgi.framework.SynchronousBundleListener; //导入依赖的package包/类
private ModuleListener adaptBundleListener(BundleListener listener) {
    if (listener instanceof SynchronousBundleListener) {
        return new SynchronousBundleListenerAdaptor(listener);
    } else {
        return new BundleListenerAdaptor(listener);
    }
}
 
开发者ID:tdiesler,项目名称:gravia,代码行数:8,代码来源:BundleContextAdaptor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MimeConfig类代码示例发布时间:2022-05-21
下一篇:
Java DeviceInterfaceModule类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap