-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
206 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
模块化的实现、好处、框架 | ||
|
||
|
||
|
||
--------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
模块化框架: | ||
osgi、jarslink、java9等 | ||
|
||
|
||
模块化好处: | ||
便于项目管理,解耦:开发、测试、交付、升级,引用其他类库都可以独立进行 | ||
|
||
OSGI: | ||
https://www.infoq.cn/article/modular-java-dynamic-modularity | ||
|
||
|
||
javaagent使用 + 字节码修改框架 | ||
动态代理和静态代理:参考quickstart-proxy/doc | ||
java探针javaAgent的使用 | ||
java的热部署和热加载:联系、区别、原理、使用场景 | ||
java热加载:VirtualMachine、Attach、Agent、Instrumentation:只能修改方法体,不能修改的的结构,不能变更方法签名、增加和删除方法/类的成员属性 | ||
|
||
热部署:一般是使用自定义的ClassLoader来加载应用,类似tomcat中配置的context,检测到class文件有变化,就重新加载项目,并替换之前的classloader | ||
热加载:就是通过Attach技术使用javaagent来重新加载类,retransformClasses对于已经加载的类重新进行转换处理,即会触发重新加载类定义,或者使用字节码修改框架来实现类 | ||
热部署可以进行模块化开发:比如可以进行同一个类的不同版本的加载,不同项目的加载(依赖jar版本不一样),直接进行不同版本的jar加载 | ||
模块可以是一个类的不同版本、不同的包路径下的代码、同一个jar的不同版本,同一个项目的不同模块,任何一个 Java 类库 | ||
|
||
|
||
premain | ||
以vm参数的形式载入,在程序main方法执行之前执行 | ||
其jar包的manifest需要配置属性Premain-Class | ||
|
||
agentmain | ||
以vm参数的形式载入,在程序main方法执行之前执行 | ||
其jar包的manifest需要配置属性Premain-Class | ||
|
||
|
||
|
||
--------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
|
||
--------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
|
||
|
||
--------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.quickstart</groupId> | ||
<artifactId>quickstart-all</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<relativePath>..</relativePath> <!-- lookup parent from repository --> | ||
</parent> | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.quickstart</groupId> | ||
<artifactId>quickstart-all</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<!-- <relativePath>..</relativePath> <!– lookup parent from repository –>--> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>quickstart-modular</artifactId> | ||
<packaging>pom</packaging> | ||
<name>${project.artifactId}-${project.version}</name> | ||
<url>http://maven.apache.org</url> | ||
<description>Demo project for XXX</description> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>quickstart-modular</artifactId> | ||
<packaging>pom</packaging> | ||
<name>${project.artifactId}-${project.version}</name> | ||
<url>http://maven.apache.org</url> | ||
<description>Demo project for XXX</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependencies> | ||
|
||
</dependencies> | ||
</dependencies> | ||
|
||
<modules> | ||
<module>quickstart-jarslink</module> | ||
</modules> | ||
<modules> | ||
<module>quickstart-jarslink</module> | ||
<module>quickstart-sofa-jarslink</module> | ||
</modules> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.quickstart</groupId> | ||
<artifactId>quickstart-modular</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<relativePath>..</relativePath> <!-- lookup parent from repository --> | ||
</parent> | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.quickstart</groupId> | ||
<artifactId>quickstart-modular</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<relativePath>..</relativePath> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>quickstart-jarslink</artifactId> | ||
<packaging>pom</packaging> | ||
<name>${project.artifactId}-${project.version}</name> | ||
<url>http://maven.apache.org</url> | ||
<description>Demo project for XXX</description> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>quickstart-jarslink</artifactId> | ||
<packaging>pom</packaging> | ||
<name>${project.artifactId}-${project.version}</name> | ||
<url>http://maven.apache.org</url> | ||
<description>Demo project for XXX</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<jarslink.version>1.6.1.20180301</jarslink.version> | ||
<jarslink.version>1.5.0.20180213</jarslink.version> | ||
</properties> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<jarslink.version>1.6.1.20180301</jarslink.version> | ||
<jarslink.version>1.5.0.20180213</jarslink.version> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-dependencies</artifactId> | ||
<!-- <version>1.5.13.RELEASE</version> --> | ||
<version>2.0.0.RELEASE</version> | ||
|
||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-dependencies</artifactId> | ||
<!-- <version>1.5.13.RELEASE</version> --> | ||
<version>2.0.0.RELEASE</version> | ||
|
||
<dependencies> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependency> | ||
<groupId>com.alipay.jarslink</groupId> | ||
<artifactId>jarslink-api</artifactId> | ||
<version>${jarslink.version}</version> | ||
</dependency> | ||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<!-- 现在已经合并到蚂蚁金服开源项目sofa-jarslink里面了--> | ||
<dependency> | ||
<groupId>com.alipay.jarslink</groupId> | ||
<artifactId>jarslink-api</artifactId> | ||
<version>${jarslink.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>fastjson</artifactId> | ||
<version>1.2.46</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>fastjson</artifactId> | ||
<version>1.2.46</version> | ||
</dependency> | ||
|
||
<modules> | ||
<module>quickstart-jarslink-api</module> | ||
<module>quickstart-jarslink-memory</module> | ||
<module>quickstart-jarslink-mysql</module> | ||
<module>quickstart-jarslink-redis</module> | ||
<module>quickstart-jarslink-app</module> | ||
<module>quickstart-jarslink-service-a</module> | ||
<module>quickstart-jarslink-service-b</module> | ||
<module>quickstart-jarslink-web</module> | ||
</modules> | ||
</dependencies> | ||
|
||
<modules> | ||
<module>quickstart-jarslink-api</module> | ||
<module>quickstart-jarslink-memory</module> | ||
<module>quickstart-jarslink-mysql</module> | ||
<module>quickstart-jarslink-redis</module> | ||
<module>quickstart-jarslink-app</module> | ||
<module>quickstart-jarslink-service-a</module> | ||
<module>quickstart-jarslink-service-b</module> | ||
<module>quickstart-jarslink-web</module> | ||
</modules> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
参考 | ||
/Users/yangzl/git/quickstart-javase9 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0"?> | ||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<parent> | ||
<groupId>org.quickstart</groupId> | ||
<artifactId>quickstart-modular</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>quickstart-javase9</artifactId> | ||
<packaging>jar</packaging> | ||
<name>${project.artifactId}-${project.version}</name> | ||
<url>http://maven.apache.org</url> | ||
<description>Demo project for XXX</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
参考 | ||
/Users/yangzl/git/quickstart-sofa/quickstart-sofa-jarslink | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0"?> | ||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<parent> | ||
<groupId>org.quickstart</groupId> | ||
<artifactId>quickstart-modular</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>quickstart-sofa-jarslink</artifactId> | ||
<packaging>jar</packaging> | ||
<name>${project.artifactId}-${project.version}</name> | ||
<url>http://maven.apache.org</url> | ||
<description>Demo project for XXX</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
</dependencies> | ||
|
||
</project> |