forked from alibaba/jvm-sandbox
-
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.
引入ModuleJarLifeCycleProvider接口解决模块泄漏问题
- Loading branch information
1 parent
86e6e33
commit c64dde4
Showing
8 changed files
with
129 additions
and
42 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
sandbox-api/src/main/java/com/alibaba/jvm/sandbox/api/spi/ModuleJarLifeCycleProvider.java
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,16 @@ | ||
package com.alibaba.jvm.sandbox.api.spi; | ||
|
||
/** | ||
* 模块Jar包生命周期管理 | ||
* | ||
* @author oldmanpushcart@gmail.com | ||
* @since {@code sandbox-api:1.2.0} | ||
*/ | ||
public interface ModuleJarLifeCycleProvider { | ||
|
||
/** | ||
* 模块Jar文件卸载完所有模块后,正式卸载Jar文件之前之后调用! | ||
*/ | ||
void onJarUnLoadCompleted(); | ||
|
||
} |
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
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
25 changes: 25 additions & 0 deletions
25
...debug-module/src/main/java/com/alibaba/jvm/sandbox/module/debug/OnJarUnLoadCompleted.java
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 @@ | ||
package com.alibaba.jvm.sandbox.module.debug; | ||
|
||
import ch.qos.logback.classic.LoggerContext; | ||
import com.alibaba.jvm.sandbox.api.spi.ModuleJarLifeCycleProvider; | ||
import org.kohsuke.MetaInfServices; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@MetaInfServices(ModuleJarLifeCycleProvider.class) | ||
public class OnJarUnLoadCompleted implements ModuleJarLifeCycleProvider { | ||
|
||
@Override | ||
public void onJarUnLoadCompleted() { | ||
closeLogback(); | ||
} | ||
|
||
// 关闭Logback日志框架 | ||
private void closeLogback() { | ||
try { | ||
((LoggerContext) LoggerFactory.getILoggerFactory()).stop(); | ||
} catch (Throwable cause) { | ||
cause.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
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
25 changes: 25 additions & 0 deletions
25
...box-mgr-module/src/main/java/com/alibaba/jvm/sandbox/module/mgr/OnJarUnLoadCompleted.java
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 @@ | ||
package com.alibaba.jvm.sandbox.module.mgr; | ||
|
||
import ch.qos.logback.classic.LoggerContext; | ||
import com.alibaba.jvm.sandbox.api.spi.ModuleJarLifeCycleProvider; | ||
import org.kohsuke.MetaInfServices; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@MetaInfServices(ModuleJarLifeCycleProvider.class) | ||
public class OnJarUnLoadCompleted implements ModuleJarLifeCycleProvider { | ||
|
||
@Override | ||
public void onJarUnLoadCompleted() { | ||
closeLogback(); | ||
} | ||
|
||
// 关闭Logback日志框架 | ||
private void closeLogback() { | ||
try { | ||
((LoggerContext) LoggerFactory.getILoggerFactory()).stop(); | ||
} catch (Throwable cause) { | ||
cause.printStackTrace(); | ||
} | ||
} | ||
|
||
} |