Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deploying new method or updating method without restarting the application.

Notifications You must be signed in to change notification settings

javafine/dynamic-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dynamic-code

特性

  • 动态部署:基于groovy的MOP机制实现的方法的动态部署和更新。
  • 动态配置管理:动态部署的最佳使用场景。
  • 动态转发请求:动态部署的典型使用场景

环境

jdk1.8、maven3.8.4、IntelliJ IDEA(Community Edition)、windows

代码结构

一个WEB示例工程,包含动态部署的管理和示例

  • FunctionManager.groovy:基于groovy的MOP机制实现动态加载。
  • ConfigurationManager.java:实现配置文件的动态管理。
  • sample.groovy:示例脚本代码,被动态部署和更新。
  • conf_sample.groovy:示例配置文件,被动态管理的配置信息。

运行

直接在本工程的release目录下执行 java -jar .\dynamic-code-0.1.0.jar 或者:

  1. 在本工程目录下执行mvn gplus:compile package
  2. 将生成的target/dynamic-code-0.1.0.jar放到release目录下,与release/code/sample.groovyrelease/conf/conf_sample.groovy在一个目录下执行java -jar .\dynamic-code-0.1.0.jar

测试

  1. 请求curl --location --request GET 'localhost:8080/file/sample/function/hello?name=anna' 执行release/code/sample.groovy内的hello方法,返回Hello : anna
  2. 修改release/code/sample.groovyhello方法代码。
  3. 请求curl --location --request GET 'localhost:8080/meta/reload/file/sample/function/hello' 重新加载release/code/sample.groovy
  4. 再次请求curl --location --request GET 'localhost:8080/file/sample/function/hello?name=anna',获得更新后的结果。

联系方式

[email protected]

About

Deploying new method or updating method without restarting the application.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published