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

相关文章

详解Vue如何使用xlsx库导出Excel文件

《详解Vue如何使用xlsx库导出Excel文件》第三方库xlsx提供了强大的功能来处理Excel文件,它可以简化导出Excel文件这个过程,本文将为大家详细介绍一下它的具体使用,需要的小伙伴可以了解... 目录1. 安装依赖2. 创建vue组件3. 解释代码在Vue.js项目中导出Excel文件,使用第三

Linux alias的三种使用场景方式

《Linuxalias的三种使用场景方式》文章介绍了Linux中`alias`命令的三种使用场景:临时别名、用户级别别名和系统级别别名,临时别名仅在当前终端有效,用户级别别名在当前用户下所有终端有效... 目录linux alias三种使用场景一次性适用于当前用户全局生效,所有用户都可调用删除总结Linux

java图像识别工具类(ImageRecognitionUtils)使用实例详解

《java图像识别工具类(ImageRecognitionUtils)使用实例详解》:本文主要介绍如何在Java中使用OpenCV进行图像识别,包括图像加载、预处理、分类、人脸检测和特征提取等步骤... 目录前言1. 图像识别的背景与作用2. 设计目标3. 项目依赖4. 设计与实现 ImageRecogni

python管理工具之conda安装部署及使用详解

《python管理工具之conda安装部署及使用详解》这篇文章详细介绍了如何安装和使用conda来管理Python环境,它涵盖了从安装部署、镜像源配置到具体的conda使用方法,包括创建、激活、安装包... 目录pytpshheraerUhon管理工具:conda部署+使用一、安装部署1、 下载2、 安装3

Mysql虚拟列的使用场景

《Mysql虚拟列的使用场景》MySQL虚拟列是一种在查询时动态生成的特殊列,它不占用存储空间,可以提高查询效率和数据处理便利性,本文给大家介绍Mysql虚拟列的相关知识,感兴趣的朋友一起看看吧... 目录1. 介绍mysql虚拟列1.1 定义和作用1.2 虚拟列与普通列的区别2. MySQL虚拟列的类型2

使用MongoDB进行数据存储的操作流程

《使用MongoDB进行数据存储的操作流程》在现代应用开发中,数据存储是一个至关重要的部分,随着数据量的增大和复杂性的增加,传统的关系型数据库有时难以应对高并发和大数据量的处理需求,MongoDB作为... 目录什么是MongoDB?MongoDB的优势使用MongoDB进行数据存储1. 安装MongoDB

关于@MapperScan和@ComponentScan的使用问题

《关于@MapperScan和@ComponentScan的使用问题》文章介绍了在使用`@MapperScan`和`@ComponentScan`时可能会遇到的包扫描冲突问题,并提供了解决方法,同时,... 目录@MapperScan和@ComponentScan的使用问题报错如下原因解决办法课外拓展总结@

mysql数据库分区的使用

《mysql数据库分区的使用》MySQL分区技术通过将大表分割成多个较小片段,提高查询性能、管理效率和数据存储效率,本文就来介绍一下mysql数据库分区的使用,感兴趣的可以了解一下... 目录【一】分区的基本概念【1】物理存储与逻辑分割【2】查询性能提升【3】数据管理与维护【4】扩展性与并行处理【二】分区的

使用Python实现在Word中添加或删除超链接

《使用Python实现在Word中添加或删除超链接》在Word文档中,超链接是一种将文本或图像连接到其他文档、网页或同一文档中不同部分的功能,本文将为大家介绍一下Python如何实现在Word中添加或... 在Word文档中,超链接是一种将文本或图像连接到其他文档、网页或同一文档中不同部分的功能。通过添加超

Linux使用fdisk进行磁盘的相关操作

《Linux使用fdisk进行磁盘的相关操作》fdisk命令是Linux中用于管理磁盘分区的强大文本实用程序,这篇文章主要为大家详细介绍了如何使用fdisk进行磁盘的相关操作,需要的可以了解下... 目录简介基本语法示例用法列出所有分区查看指定磁盘的区分管理指定的磁盘进入交互式模式创建一个新的分区删除一个存