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

相关文章

Linux中压缩、网络传输与系统监控工具的使用完整指南

《Linux中压缩、网络传输与系统监控工具的使用完整指南》在Linux系统管理中,压缩与传输工具是数据备份和远程协作的桥梁,而系统监控工具则是保障服务器稳定运行的眼睛,下面小编就来和大家详细介绍一下它... 目录引言一、压缩与解压:数据存储与传输的优化核心1. zip/unzip:通用压缩格式的便捷操作2.

深度解析Java项目中包和包之间的联系

《深度解析Java项目中包和包之间的联系》文章浏览阅读850次,点赞13次,收藏8次。本文详细介绍了Java分层架构中的几个关键包:DTO、Controller、Service和Mapper。_jav... 目录前言一、各大包1.DTO1.1、DTO的核心用途1.2. DTO与实体类(Entity)的区别1

使用Python实现可恢复式多线程下载器

《使用Python实现可恢复式多线程下载器》在数字时代,大文件下载已成为日常操作,本文将手把手教你用Python打造专业级下载器,实现断点续传,多线程加速,速度限制等功能,感兴趣的小伙伴可以了解下... 目录一、智能续传:从崩溃边缘抢救进度二、多线程加速:榨干网络带宽三、速度控制:做网络的好邻居四、终端交互

Python中注释使用方法举例详解

《Python中注释使用方法举例详解》在Python编程语言中注释是必不可少的一部分,它有助于提高代码的可读性和维护性,:本文主要介绍Python中注释使用方法的相关资料,需要的朋友可以参考下... 目录一、前言二、什么是注释?示例:三、单行注释语法:以 China编程# 开头,后面的内容为注释内容示例:示例:四

Go语言数据库编程GORM 的基本使用详解

《Go语言数据库编程GORM的基本使用详解》GORM是Go语言流行的ORM框架,封装database/sql,支持自动迁移、关联、事务等,提供CRUD、条件查询、钩子函数、日志等功能,简化数据库操作... 目录一、安装与初始化1. 安装 GORM 及数据库驱动2. 建立数据库连接二、定义模型结构体三、自动迁

ModelMapper基本使用和常见场景示例详解

《ModelMapper基本使用和常见场景示例详解》ModelMapper是Java对象映射库,支持自动映射、自定义规则、集合转换及高级配置(如匹配策略、转换器),可集成SpringBoot,减少样板... 目录1. 添加依赖2. 基本用法示例:简单对象映射3. 自定义映射规则4. 集合映射5. 高级配置匹

Spring 框架之Springfox使用详解

《Spring框架之Springfox使用详解》Springfox是Spring框架的API文档工具,集成Swagger规范,自动生成文档并支持多语言/版本,模块化设计便于扩展,但存在版本兼容性、性... 目录核心功能工作原理模块化设计使用示例注意事项优缺点优点缺点总结适用场景建议总结Springfox 是

嵌入式数据库SQLite 3配置使用讲解

《嵌入式数据库SQLite3配置使用讲解》本文强调嵌入式项目中SQLite3数据库的重要性,因其零配置、轻量级、跨平台及事务处理特性,可保障数据溯源与责任明确,详细讲解安装配置、基础语法及SQLit... 目录0、惨痛教训1、SQLite3环境配置(1)、下载安装SQLite库(2)、解压下载的文件(3)、

使用Python绘制3D堆叠条形图全解析

《使用Python绘制3D堆叠条形图全解析》在数据可视化的工具箱里,3D图表总能带来眼前一亮的效果,本文就来和大家聊聊如何使用Python实现绘制3D堆叠条形图,感兴趣的小伙伴可以了解下... 目录为什么选择 3D 堆叠条形图代码实现:从数据到 3D 世界的搭建核心代码逐行解析细节优化应用场景:3D 堆叠图

Springboot如何正确使用AOP问题

《Springboot如何正确使用AOP问题》:本文主要介绍Springboot如何正确使用AOP问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录​一、AOP概念二、切点表达式​execution表达式案例三、AOP通知四、springboot中使用AOP导出