關(guān)于ClassLoader 問(wèn)題的分析:
EclipeClassLoader 創(chuàng)建:
public org.eclipse.osgi.framework.adaptor.BundleClassLoader createClassLoader
(ClassLoaderDelegate delegate, ProtectionDomain domain, S
tring[] bundleclasspath, AbstractBundleData data) {
return new EclipseClassLoader(delegate, domain,
bundleclasspath, data.getAdaptor().getBundleClassLoaderParent(), data);
}
獲取ClassLoaderParent 的方法,使用了EclipseAdaptor
Adaptor 的getBundleClassLoaderParent() 如何去定 bundleClassLoaderParent?

2

3


4

5

6

7

8

9

10

11

12

13

14

15

16

17



18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33



34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

如果使用了了boot Classloader 則 ParentClassLoader 是新建的 boot,這里分析看來(lái)應(yīng)該使用framework 或者系統(tǒng)的ClassLoader吧。
根據(jù)以上的分析,對(duì)Triones的啟動(dòng)環(huán)境進(jìn)行了調(diào)整:
1、直接引用 org.eclipse.osgi 中的啟動(dòng)包,避免使用反射。注:可以直接調(diào)用EclipseStarter.run(null) 了。
2、將Triones Runtime 拆分成為 triones-core.jar (包括主要的服務(wù)接口 ItrionesFramework 等)和 triones-runtime.jar (Triones Runtime Eclipse插件)。
3、修改 Eclipse 的 config.ini 配置。
# osgi classloader :
osgi.parentClassloader = fwk
根據(jù)上面的分析, fwk 表示使用 FrameworkAdaptor 的ClassLoader 作為OSGi的parent classloader。
bundleClassLoaderParent = FrameworkAdaptor.class.getClassLoader();
不得窺道門(mén),不得悟佛門(mén),不得入窄門(mén),實(shí)乃破門(mén)。