Skip to content

Commit

Permalink
修复重复订阅问题 alibaba#159
Browse files Browse the repository at this point in the history
支持Java 11    alibaba#158
  • Loading branch information
daviyang35 committed Jan 7, 2022
1 parent 13153f7 commit 309d38f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

import javax.annotation.Resource;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -92,6 +93,8 @@ public class RepeaterModule implements Module, ModuleLifecycle {

private final AtomicBoolean initialized = new AtomicBoolean(false);

private static List<SubscribeSupporter> subscribes = new ArrayList<SubscribeSupporter>();

@Override
public void onLoad() throws Throwable {
// 初始化日志框架
Expand Down Expand Up @@ -187,8 +190,9 @@ private synchronized void initialize(RepeaterConfig config) {
}

RepeaterBridge.instance().build(repeaters);
unregisterSubscribed();
// 装载消息订阅器
List<SubscribeSupporter> subscribes = lifecycleManager.loadSubscribes();
subscribes = lifecycleManager.loadSubscribes();
for (SubscribeSupporter subscribe : subscribes) {
subscribe.register();
}
Expand All @@ -200,6 +204,13 @@ private synchronized void initialize(RepeaterConfig config) {
}
}

private void unregisterSubscribed() {
for (SubscribeSupporter subscribe : subscribes) {
subscribe.unRegister();
}
subscribes.clear();
}

/**
* 回放http接口
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public void onConfigChange(RepeaterConfig config) throws PluginLifeCycleExceptio
if (configTemporary == null) {
super.onConfigChange(config);
} else {
this.config = config;
super.onConfigChange(config);
List<Behavior> current = config.getJavaEntranceBehaviors();
List<Behavior> latest = configTemporary.getJavaEntranceBehaviors();
this.config = config;
super.onConfigChange(config);
if (JavaPluginUtils.hasDifference(current, latest)) {
reWatch0();
}
Expand Down
8 changes: 8 additions & 0 deletions repeater-console/repeater-console-bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
<name>repeater-console::bootstrap</name>

<dependencies>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.jvm.sandbox</groupId>
<artifactId>repeater-console-service</artifactId>
Expand Down

0 comments on commit 309d38f

Please sign in to comment.