OSGi的ClassLoader是一个非常烦人的事情. 这里看到一篇文章, 觉得不错, 意译了一下.
http://olegz.wordpress.com/2008/11/05/osgi-and-classforname/
在osgi中, 除了java.*包下面的类之外, 每一个bundle使用它们自己的classloader来加载所有的类
而osgi的bundle中classloader加载类的过程与一般的classloader有一些区别, 它的加载过程会受到mainfest文件中Import/Export-Package, Required-Bundle 以及其他定义的制约
osgi的classloader有两个职责:
1.加载本bundle下的类(包括相关依赖jar包下的类)
2.按照osgi的规则与其他bundle的classloader协作获取本bundle所需要的class
这里有一个Bundle Class Space的概念, Bundle Class Space = Bundle-Space + Import-Pckage + Import-Bundle etc
可以理解为class范围.
当使用Class.forName()的时候, 需要注意这个要加载的类是否超出了当前Bundle的Class Space
对于Class.forName(”org.bar.Foo”);来说, 必须做到依赖的bundle需要export出org.bar, 而依赖方需要设置bundle的import package 或者require bundle
BTW:To load a class from another bundle use Bundle.loadClass(String) method
分享到:
相关推荐
org.eclipse.osgi_3.7.0.v20110613以及源码 。
org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar
NULL 博文链接:https://cobble19.iteye.com/blog/1010849
[OSGi实战].(OSGi.in.Action).R.S.Hall&K.Pauls&S.McCulloch&D.Savage.文字版.pdf
osgi规范..................
OSGi-lib.rar OSGi-lib.rar OSGi-lib.rar OSGi-lib.rar
[OSGi实战].(OSGi.in.Action).R.S.Hall&K.Pauls&S.McCulloch&D.Savage.文字版.pdf 该书是一本入门的好教材
电子书: 9781934356401-1934356409_Modular Java - Creating Flexible Applications with OSGi and Spring .pdf 可以去Amazon上看介绍。
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) ...
Manning.OSGi.in.Action.Jul.2010.MEAP.rar
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) ...
org.apache.axis2.osgi-1.5.jar
Packt.Instant.OSGi.Starter.2013初学者指南
标签:ant-1.6.5-osgi.jar.zip,ant,1.6.5,osgi,jar.zip包下载,依赖包
在ubuntu软件中心安装的eclipse启动存在异常,需要在plugins中加入这个文件才能正常启动
osgi.r4.services.pdf osgi的R4服务规范
OSGi+Technology.rar OSGi+Technology.rar
OSGi.in.action.ppt Use OSGi with popular framework Deploy exist system to OSGi The feature of OSGi application OSGi application design best practices OSGi application develop best practices ...
osgi最新jar包org.osgi.core-4.2.0
这个是真的,高清PDF Manning.OSGi.in.Action.Jul.2010.MEAP.pdf