2008-02-22

OSGI TIPS

关键字: osgi
1.在bundle和component中必须得有一个无参的构造函数。否则bundle将抛出异常,component不抛出异常,但是该component不能启动。

Caused by: java.lang.InstantiationException: b.Activator
	at java.lang.Class.newInstance0(Class.java:335)
	at java.lang.Class.newInstance(Class.java:303)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:136)
	... 14 more

2.在一个bundle中有多个component的。
为每个component定义个配置文件,然后在MANIFEST.MF中进行配置如下:
Service-Component: OSGI-INF/component.xml,OSGI-INF/component2.xml

3.在一个component的service中,提供多个interface,如下:
<component name="comeImpl">
<implementation class="impl2.ComeImpl"/>
<service>
<provide interface="intf2.Come"/>
<provide interface="intf3.Third"/>
</service>
</component>

4.提供的service,一定要被其他bundle引用,否则提供service的component不会被加载。

5.当一个component被加载的时候,先调用构造函数,再调用注入(set)方法,然后是activate方法。

 

评论
hankesi2000 2008-02-26
恩,有建设性,就是有些乱~~~
发表评论

您还没有登录,请登录后发表评论

puroc
搜索本博客
最新评论