OSGI-服务-注册服务

可以直接注册,也可以使用服务工厂注册。

①直接注册:

public void start(BundleContext bundleContext) throws Exception {
		Activator.context = bundleContext;
		EnHelloworld hs = new EnHelloworld();
		Dictionary<String,Object> properties = new Hashtable<String,Object>();
		//properties.put(Constants.SERVICE_RANKING, 100);
		properties.put("service.language", "english");
		context.registerService(IHelloService.class, hs, properties);
		
		System.out.println("bundle "+bundleContext.getBundle().getSymbolicName()+"启动完毕!");
	}

②服务工厂注册:

略。

posted @ 2022-05-14 11:18  `安安安安安  阅读(78)  评论(0)    收藏  举报