osgi学习之---扩展点理解

1.某个bundle定义自己的扩展点,只是为了别的bundle使用此bundle的服务时,能把自己的个性化数据加入提供服务的bundle。比如:我们使用hibernate这个bundle的服务时,必须告诉此bundle我们自己的pojo对应的配置文件,即hbm文件。达到如下效果:
<mapping resource=”cn/org/osgi/bulletin/po/Bulletin.hbm.xml”/>

2.定义自己的扩展点的bundle通过实现监听接口IRegistryChangeListener来监听新的扩展点的实现,通过这个监听来动态的把扩展点实现者的内容加入自己的bundle内部,可以通过IExtensionRegistry服务来获取所有的扩展点实现。在hibernate所在的bundle中,必定有一个监听器实现了IRegistryChangeListener,当有新的扩展点加入的时候,动态的把mapping映射加入hibernate中

3.扩展点中xsd文件,仅仅是用于规范扩展点实现者在使用扩展点时采用xml的方式来配置。比如:
<extension point="HibernateModule.HibernateExtension">
<po class="cn.org.osgi.bulletin.po.Bulletin"/>
</extension>
xsd描述文件定义了有一个节点,名字为po,有一个属性为class

猜你喜欢

转载自never-chi.iteye.com/blog/1505853