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()+"启动完毕!");
}
②服务工厂注册:
略。

浙公网安备 33010602011771号