03 为什么 Bootstrap 代理之后能使用 maven 来管理 rcp 项目的依赖

2024-03-15 10:59

本文主要是介绍03 为什么 Bootstrap 代理之后能使用 maven 来管理 rcp 项目的依赖,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

前言

呵呵 这里会大致的跟一些 可能有帮助于理解 使用 maven 来管理 rcp 项目的依赖 的一些记录信息  

当然 不了解也没关系 

 

 

业务代码使用 sqlite.JDBC

 

 

看 sqlite.JDBC 的加载 

可以看到的是 Activator 触发了 sqlite.JDBC 的加载 

这里面的 Classloader 实例, ModuleClassLoader 的实例, 实际上的实现是 org.eclipse.osgi.internal.loader.EquinoxClassLoader 

可以看到这一系列的加载非常复杂, 我们还是看一些重点吧, 类加载的路由部分主要是委托给了这里的 ClasspathManager 来寻找 

从下面的图片也可以看到, 这里的 cpEntries 大概是有 31 个, 对应的就是 各个 jar, 也就是我们 pom.xml 里面配置的各个 plugin.jar 以及 sqlite.jar 以及 commons-io.jar 可以参见后面的 "cpEntries 包含了那些?" 

可以看到的是在 /Users/jerry/.m2/repository/org/xerial/sqlite-jdbc/3.32.3.2/sqlite-jdbc-3.32.3.2.jar 中发现了 sqlite.JDBC, 然后 就走了后面的从 sqlite-jdbc-3.32.3.2.jar 中加载 sqlite.JDBC defineClass 的相关流程 

 

 

cpEntries 包含了那些数据?

我们这里吧 cpEntries 列出来 大致的结构是 

*.plugin.* 相关的差不多是 24 个依赖 

sqlite.jar, commons-io.jar 两个业务依赖 

idea_rt.jar 一个 jdk 的基础依赖 

$base.dir/target/classes, $base.dir, $base.dir[target/classes], $base.dir/libs/sqlite.jar 四个其他依赖

0 = "/Users/jerry/EclipseWorkStations/MyRcp/target/classes"
1 = "/Users/jerry/.p2/pool/plugins/org.eclipse.equinox.launcher_1.6.0.v20200915-1508.jar"
2 = "/Users/jerry/.p2/pool/plugins/javax.inject_1.0.0.v20091030.jar"
3 = "/Users/jerry/.p2/pool/plugins/org.eclipse.swt_3.115.100.v20201202-1103.jar"
4 = "/Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.model.workbench_2.1.900.v20201014-0742.jar"
5 = "/Users/jerry/.p2/pool/plugins/org.eclipse.jface_3.22.0.v20201106-0834.jar"
6 = "/Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.services_1.4.0.v20201014-0944.jar"
7 = "/Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.workbench_1.12.0.v20201119-1132.jar"
8 = "/Users/jerry/.p2/pool/plugins/org.eclipse.e4.core.di_1.7.600.v20200428-0912.jar"
9 = "/Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.di_1.2.900.v20201021-1339.jar"
10 = "/Users/jerry/.p2/pool/plugins/org.eclipse.e4.core.contexts_1.8.400.v20191217-1710.jar"
11 = "/Users/jerry/.p2/pool/plugins/org.eclipse.core.runtime_3.20.0.v20201027-1526.jar"
12 = "/Users/jerry/.p2/pool/plugins/org.eclipse.core.commands_3.9.800.v20201021-1339.jar"
13 = "/Users/jerry/.p2/pool/plugins/org.eclipse.e4.core.di.annotations_1.6.600.v20191216-2352.jar"
14 = "/Users/jerry/.p2/pool/plugins/org.eclipse.osgi_3.16.100.v20201030-1916.jar"
15 = "/Users/jerry/.p2/pool/plugins/org.eclipse.osgi.compatibility.state_1.2.200.v20200915-2015.jar"
16 = "/Users/jerry/.p2/pool/plugins/org.eclipse.equinox.common_3.14.0.v20201102-2053.jar"
17 = "/Users/jerry/.p2/pool/plugins/org.eclipse.core.jobs_3.10.1000.v20200909-1312.jar"
18 = "/Users/jerry/.p2/pool/plugins/org.eclipse.equinox.registry_3.10.0.v20201107-1818.jar"
19 = "/Users/jerry/.p2/pool/plugins/org.eclipse.equinox.preferences_3.8.100.v20201102-2042.jar"
20 = "/Users/jerry/.p2/pool/plugins/org.eclipse.core.contenttype_3.7.800.v20200724-0804.jar"
21 = "/Users/jerry/.p2/pool/plugins/org.eclipse.equinox.app_1.5.0.v20200717-0620.jar"
22 = "/Users/jerry/.p2/pool/plugins/javax.annotation_1.3.5.v20200909-1856.jar"
23 = "/Users/jerry/.p2/pool/plugins/org.eclipse.swt.browser.chromium.cocoa.macosx.x86_64_3.115.100.v20201202-1103.jar"
24 = "/Users/jerry/.p2/pool/plugins/org.eclipse.swt.cocoa.macosx.x86_64_3.115.100.v20201202-1103.jar"
25 = "/Users/jerry/.m2/repository/org/xerial/sqlite-jdbc/3.32.3.2/sqlite-jdbc-3.32.3.2.jar"
26 = "/Users/jerry/.m2/repository/commons-io/commons-io/2.6/commons-io-2.6.jar"
27 = "/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar"
28 = "/Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/EclipseWorkStations/MyRcp[target/classes/]"
29 = "/Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/EclipseWorkStations/MyRcp"
30 = "/Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/EclipseWorkStations/MyRcp/libs/sqlite-jdbc-3.32.3.2.jar"

 

 

ClasspathManager 里面的 cpEntries 来自于哪里?

ClasspathManager 的创建是在 EquinoxClassLoader 里面 

我们在 ClasspathManager 里面打上断点 

... 然后我们会发现 N 个进入 ClasspathManager 的断点?, 创建了这么多的 EquinoxClassLoader ?  

我们可以稍微打印一下这些 EquinoxClassLoader 的相关上下文信息, 一些是 *.plugin.*, 另外还有一个而我们需要关注的 MyRcp 

entryLength = 31, firstBundle = /Users/jerry/EclipseWorkStations/MyRcp/target/classes

 inClasspathManager - entryLength = 1, firstBundle = /Users/jerry/.p2/pool/plugins/org.eclipse.osgi_3.16.100.v20201030-1916.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.apache.felix.scr_2.1.24.v20200924-1939.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.osgi.services_3.9.0.v20200511-1725.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.equinox.common_3.14.0.v20201102-2053.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.osgi.util_3.5.300.v20190708-1141.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.core.contenttype_3.7.800.v20200724-0804.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.equinox.preferences_3.8.100.v20201102-2042.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.equinox.registry_3.10.0.v20201107-1818.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.core.di.extensions.supplier_0.15.700.v20200622-1247.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.core.di_1.7.600.v20200428-0912.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.core.runtime_3.20.0.v20201027-1526.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.equinox.app_1.5.0.v20200717-0620.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.equinox.event_1.5.500.v20200616-0800.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.workbench.swt_0.15.0.v20201103-0952.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.jface_3.22.0.v20201106-0834.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.model.workbench_2.1.900.v20201014-0742.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.core.services_2.2.500.v20200928-2213.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.workbench_1.12.0.v20201119-1132.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.core.contexts_1.8.400.v20191217-1710.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.swt_3.115.100.v20201202-1103.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.services_1.4.0.v20201014-0944.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/javax.inject_1.0.0.v20091030.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.core.di.annotations_1.6.600.v20191216-2352.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/javax.annotation_1.3.5.v20200909-1856.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.emf.ecore_2.23.0.v20200630-0516.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.emf.common_2.21.0.v20200917-1439.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.emf.ecore.xmi_2.16.0.v20190528-0725.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.emf.ecore.change_2.14.0.v20190528-0725.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.emf.xpath_0.2.800.v20200609-0849.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.emf.databinding_1.5.0.v20180706-1146.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.workbench.renderers.swt_0.15.0.v20201125-0918.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.workbench.addons.swt_1.4.0.v20201119-1132.jarinClasspathManager - entryLength = 31, firstBundle = /Users/jerry/EclipseWorkStations/MyRcp/target/classesinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.core.commands_3.9.800.v20201021-1339.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.core.databinding.observable_1.10.0.v20200730-0848.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.jface.databinding_1.12.100.v20201014-0742.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.di_1.2.900.v20201021-1339.jar
org.sqlite.JDBC
E4LifeCycle.postContextCreateinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.core.commands_0.13.0.v20201119-1132.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.bindings_0.13.0.v20201119-1132.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.core.di.extensions_0.16.0.v20200507-0938.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.css.core_0.13.0.v20201015-0653.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.css.swt.theme_0.13.0.v20201026-1147.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.css.swt_0.14.0.v20201103-0952.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.w3c.css.sac_1.3.1.v200903091627.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.apache.batik.css_1.13.0.v20200622-2037.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.apache.batik.i18n_1.13.0.v20200622-2037.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.apache.batik.util_1.13.0.v20200622-2037.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.widgets_1.2.800.v20201021-1339.jarinClasspathManager - entryLength = 1, firstBundle = /Applications/Eclipse.app/Contents/Eclipse/../../../../Users/jerry/.p2/pool/plugins/org.eclipse.e4.ui.workbench3_0.15.500.v20201021-1339.jar

 

这些 module 来自于 /Users/jerry/EclipseWorkStations/.metadata/.plugins/org.eclipse.pde.core/MyRcp.product/org.eclipse.osgi/framework.info.8 解析出来的 module 部分的信息 

这个文件里面包含了 一些常规信息, 版本, 时间, 权限信息, 以及这里的 模块的相关信息, 具体的过程可以参见  Storage.<init> 

 

 

回到主题, 我们这里需要关注的是 MyRcp 对应的这个 EquinoxClassLoader 

读取 MyRcp 对应的额 classpath 读取出来的数据大致如下, 看起来就是 dev.properties 里面的配置 

 

配置的加载来自于 初始化 EquinoxConfiguration 的时候, 配置文件来自于 osgi.dev 的配置 

 

这个 osgi.dev 的配置 来自于参入的 程序参数[Program arguments]

 

 

扩展

现在能够反向的理解 使用 maven 来管理 rcp 项目的依赖 了么?

至于我最开始怎么知道修改 dev.properties 的? 你猜 ~ little tricks[占位符] 

 

 

完 

 

 

参照

使用 maven 来管理 rcp 项目的依赖

 

 

这篇关于03 为什么 Bootstrap 代理之后能使用 maven 来管理 rcp 项目的依赖的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/811741

相关文章

使用Python创建一个功能完整的Windows风格计算器程序

《使用Python创建一个功能完整的Windows风格计算器程序》:本文主要介绍如何使用Python和Tkinter创建一个功能完整的Windows风格计算器程序,包括基本运算、高级科学计算(如三... 目录python实现Windows系统计算器程序(含高级功能)1. 使用Tkinter实现基础计算器2.

在.NET平台使用C#为PDF添加各种类型的表单域的方法

《在.NET平台使用C#为PDF添加各种类型的表单域的方法》在日常办公系统开发中,涉及PDF处理相关的开发时,生成可填写的PDF表单是一种常见需求,与静态PDF不同,带有**表单域的文档支持用户直接在... 目录引言使用 PdfTextBoxField 添加文本输入域使用 PdfComboBoxField

Git可视化管理工具(SourceTree)使用操作大全经典

《Git可视化管理工具(SourceTree)使用操作大全经典》本文详细介绍了SourceTree作为Git可视化管理工具的常用操作,包括连接远程仓库、添加SSH密钥、克隆仓库、设置默认项目目录、代码... 目录前言:连接Gitee or github,获取代码:在SourceTree中添加SSH密钥:Cl

Python开发文字版随机事件游戏的项目实例

《Python开发文字版随机事件游戏的项目实例》随机事件游戏是一种通过生成不可预测的事件来增强游戏体验的类型,在这篇博文中,我们将使用Python开发一款文字版随机事件游戏,通过这个项目,读者不仅能够... 目录项目概述2.1 游戏概念2.2 游戏特色2.3 目标玩家群体技术选择与环境准备3.1 开发环境3

Python中模块graphviz使用入门

《Python中模块graphviz使用入门》graphviz是一个用于创建和操作图形的Python库,本文主要介绍了Python中模块graphviz使用入门,具有一定的参考价值,感兴趣的可以了解一... 目录1.安装2. 基本用法2.1 输出图像格式2.2 图像style设置2.3 属性2.4 子图和聚

windows和Linux使用命令行计算文件的MD5值

《windows和Linux使用命令行计算文件的MD5值》在Windows和Linux系统中,您可以使用命令行(终端或命令提示符)来计算文件的MD5值,文章介绍了在Windows和Linux/macO... 目录在Windows上:在linux或MACOS上:总结在Windows上:可以使用certuti

CentOS和Ubuntu系统使用shell脚本创建用户和设置密码

《CentOS和Ubuntu系统使用shell脚本创建用户和设置密码》在Linux系统中,你可以使用useradd命令来创建新用户,使用echo和chpasswd命令来设置密码,本文写了一个shell... 在linux系统中,你可以使用useradd命令来创建新用户,使用echo和chpasswd命令来设

Python使用Matplotlib绘制3D曲面图详解

《Python使用Matplotlib绘制3D曲面图详解》:本文主要介绍Python使用Matplotlib绘制3D曲面图,在Python中,使用Matplotlib库绘制3D曲面图可以通过mpl... 目录准备工作绘制简单的 3D 曲面图绘制 3D 曲面图添加线框和透明度控制图形视角Matplotlib

Pandas中统计汇总可视化函数plot()的使用

《Pandas中统计汇总可视化函数plot()的使用》Pandas提供了许多强大的数据处理和分析功能,其中plot()函数就是其可视化功能的一个重要组成部分,本文主要介绍了Pandas中统计汇总可视化... 目录一、plot()函数简介二、plot()函数的基本用法三、plot()函数的参数详解四、使用pl

gradle第三方Jar包依赖统一管理方式

《gradle第三方Jar包依赖统一管理方式》:本文主要介绍gradle第三方Jar包依赖统一管理方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录背景实现1.顶层模块build.gradle添加依赖管理插件2.顶层模块build.gradle添加所有管理依赖包