-
Notifications
You must be signed in to change notification settings - Fork 694
/
InvokePlugin.java
115 lines (100 loc) · 3.04 KB
/
InvokePlugin.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package com.alibaba.jvm.sandbox.repeater.plugin.spi;
import com.alibaba.jvm.sandbox.api.resource.ModuleEventWatcher;
import com.alibaba.jvm.sandbox.repeater.plugin.api.InvocationListener;
import com.alibaba.jvm.sandbox.repeater.plugin.domain.InvokeType;
import com.alibaba.jvm.sandbox.repeater.plugin.domain.RepeaterConfig;
import com.alibaba.jvm.sandbox.repeater.plugin.exception.PluginLifeCycleException;
/**
* {@link InvokePlugin} 核心接口,定义一个调用插件
* <p>
* 每个类型的流量都需要实现该插件完成录制
* </p>
*
* @author zhaoyb1990
*/
public interface InvokePlugin {
/**
* 调用类型
*
* @return 调用类型
* @see com.alibaba.jvm.sandbox.repeater.plugin.domain.InvokeType
*/
InvokeType getType();
/**
* 身份标识 - 唯一标识一个插件
* 因为同一个 {@link InvokeType} 会存在入口调用和子调用插件,{@link InvokePlugin#getType} 不能唯一标识一个插件
*
* @return identity 能够唯一标志插件
*/
String identity();
/**
* 是否是入口流量插件
*
* @return true/false
*/
boolean isEntrance();
/**
* 是否生效
*
* @param config 配置文件
* @return true/false
*/
boolean enable(RepeaterConfig config);
/**
* 被加载之前
*
* @throws PluginLifeCycleException 插件周期异常
*/
void onLoaded() throws PluginLifeCycleException;
/**
* 被激活
*
* @throws PluginLifeCycleException 插件周期异常
*/
void onActive() throws PluginLifeCycleException;
/**
* 重新初始化 (例如:推送配置之后,需要重新增强代码)
*
* @param watcher 增强器
* @param listener invocation的监听者
* @throws PluginLifeCycleException 插件周期异常
*/
void watch(ModuleEventWatcher watcher,
InvocationListener listener) throws PluginLifeCycleException;
/**
* 删除插件
*
* @param watcher 增强器
* @param listener invocation的监听者
*/
void unWatch(ModuleEventWatcher watcher,
InvocationListener listener);
/**
* 重新初始化 (例如:推送配置之后,需要重新增强代码)
*
* @param watcher 增强器
* @param listener invocation的监听者
* @throws PluginLifeCycleException 插件周期异常
*/
void reWatch(ModuleEventWatcher watcher,
InvocationListener listener) throws PluginLifeCycleException;
/**
* 被冻结
*
* @throws PluginLifeCycleException 插件周期异常
*/
void onFrozen() throws PluginLifeCycleException;
/**
* 被卸载
*
* @throws PluginLifeCycleException 插件周期异常
*/
void onUnloaded() throws PluginLifeCycleException;
/**
* 监听配置变化
*
* @param config 配置文件
* @throws PluginLifeCycleException 插件周期异常
*/
void onConfigChange(RepeaterConfig config) throws PluginLifeCycleException;
}