Giter VIP home page Giter VIP logo

jar-dependency's Introduction

服务单元依赖装配

主要为实现为Standalone JAR包依赖情况的维护,便于新增服务单元注入依赖,确保Standalone依赖的清晰化和可见化。

1. 流程

ackTPJ.png

  • 本地用户根据DependencyUtil.jar包工具生成目标Jar包的Dependency JSON

  • 用户根据Dependency JSON调用下述/api/jar/dependencies/match接口获取依赖匹配情况;

  • 用户根据上述接口返回信息处理完成后,调用下述/api/jar/dependencies/inject并上传Dependency JSON完成依赖装配;

    TODO:/api/jar/dependencies/inject接口可能存在数据破坏情况,即当前接口未进行常规依赖安全检查,后续可进行完善。

  • 用户可通过/api/jar/dependencies/{appId}接口获取最新Dependency JSON内容。

2. API接口

请求路径 请求方法 请求参数 说明
/api/jar/dependencies/inject POST 详见下部分请求JSON 上传待注入的依赖(Dependency) JSON,由本接口进行分析、判断及注入
/api/jar/dependencies/{appId} GET 应用标识ID 根据应用标识ID获取依赖(Dependency)详情(JSON)
/api/jar/dependencies/match POST 详见下部分请求JSON 根据参数请求体参数verbose返回上传的JAR包依赖中与源JAR包中匹配或不匹配的依赖
  • 请求JSON
{
    "appId":"UjQhM2mOOR7I",
	"dependencies":[
		"spring-boot-starter-amqp-1.5.6.RELEASE.jar",
		"spring-boot-starter-1.5.6.RELEASE.jar",
		"spring-boot-1.5.6.RELEASE.jar",
		".......",
		"activation-1.1.1.jar",
		"aspectjweaver-1.9.4.jar"
	],
    "verbose":"true"
}

其中verbose参数用于匹配/api/jar/dependencies/match接口根据参数值返回对应数据,verbose:true则返回不匹配依赖,verbose:false则返回匹配依赖。

3. 数据表设计

  • t_jar记录表
字段 类型 说明
id bigint(20) 记录ID
app_id varchar(128) 应用标识ID
name varchar(255) JAR包记录名称
status varchar(26) 当前记录状态
dependencies json JAR包依赖JSON
create_time datetime 记录创建时间
update_time datetime 记录更新时间

4. 请求示例

a. 获取依赖信息

根据应用标识ID获取依赖(Dependency)详情(JSON)。

  • 请求方式:GET
  • 请求地址:/api/jar/dependencies/{appId}

注:此处标注的占位符{appId},为需要替换的 变量,根据实际获取值更新。其它接口也将采用相同的标注,后续将不再声明。

  • 参数说明:
参数 必须 说明
appId 待查询的应用标识ID
  • 返回结果:
{
    "code": 200,
    "message": "Success",
    "data": {
        "id": 1,
        "appId": "UjQhM2mOOR7I",
        "name": "standalone.jar",
        "status": "stat",
        "listDependencies": [
            "spring-boot-starter-amqp-1.5.6.RELEASE.jar",
		   ".......................",
            "activation-1.1.1.jar",
            "aspectjweaver-1.9.4.jar",
            "test-inject.jar"
        ]
    }
}

b. 匹配依赖

返回上传的JAR包依赖中与源JAR包中不匹配的依赖。

  • 请求方式:POST

  • 请求地址:/api/jar/dependencies/match

  • 请求参数:

{
    "appId":"UjQhM2mOOR7I",
	"dependencies":[
		"spring-boot-starter-amqp-1.5.6.RELEASE.jar",
		"spring-boot-starter-1.5.6.RELEASE.jar",
		"spring-boot-1.5.6.RELEASE.jar",
		"activation-1.1.1.jar",
		"aspectjweaver-11.9.4.jar",
                "1.jar"
	],
    "verbose":"true"
}
  • 返回结果:
{
    "code": 200,
    "message": "Success",
    "data": [
        "aspectjweaver-11.9.4.jar",
        "1.jar"
    ]
}

c. 注入依赖

上传待注入的依赖(Dependency) JSON,由本接口进行分析、判断及注入。

  • 请求方式:POST

  • 请求地址:/api/jar/dependencies/inject

  • 请求参数:

{
    "appId":"UjQhM2mOOR7I",
	"dependencies":[
            "test-inject.jar"
	]
}
  • 返回结果:
{
    "code": 200,
    "message": "Success",
    "data": null
}

5. 疑难点

  • 本地生成Dependencies JSON格式?【DONE】

    • 自定义模块 (jar-dependency-parse)
  • 云端 依赖(Dependency) 如何存储?【DONE】

    • MySQL -> JSON
  • 依赖(Dependency) 比对的逻辑【DONE】

    • 如何处理目标Jar包不存在Standalone依赖情况?
      • 返回缺失信息
    • 如何处理Standalone依赖缺失目标Jar包依赖情况?
      • 返回缺失信息

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.