Skip to content

Commit

Permalink
Merge pull request alibaba#159 from alibaba/develop-for-AddUsrModule
Browse files Browse the repository at this point in the history
add default user module dir {SANDBOX_HOME_DIR}/sandbox-module/
  • Loading branch information
dongchenxu authored Apr 7, 2019
2 parents 5ff3554 + be8fb58 commit 534f315
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bin/sandbox-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mkdir -p ${SANDBOX_TARGET_DIR}/lib
mkdir -p ${SANDBOX_TARGET_DIR}/module
mkdir -p ${SANDBOX_TARGET_DIR}/cfg
mkdir -p ${SANDBOX_TARGET_DIR}/provider

mkdir -p ${SANDBOX_TARGET_DIR}/sandbox-module

# copy jar to TARGET_DIR
cp ../sandbox-core/target/sandbox-core-*-jar-with-dependencies.jar ${SANDBOX_TARGET_DIR}/lib/sandbox-core.jar \
Expand Down
6 changes: 3 additions & 3 deletions bin/sandbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ usage: ${0} [h] [<p:> [vlRFfu:a:A:d:m:I:P:C:X]]
if module reload occur error, ignore this module.
MODULE LIB:
- ${HOME}/.sandbox-module/
- ${SANDBOX_HOME_DIR}/sandbox-module/
-f : force flush
Expand All @@ -94,15 +94,15 @@ usage: ${0} [h] [<p:> [vlRFfu:a:A:d:m:I:P:C:X]]
if module reload occur error, ignore this module.
MODULE LIB:
- ${HOME}/.sandbox-module/
- ${SANDBOX_HOME_DIR}/sandbox-module/
-R : restart sandbox
Force flush the sandbox\` sys & user module library.
MODULE LIB:
- ${SANDBOX_HOME_DIR}/module/
- ${HOME}/.sandbox-module/
- ${SANDBOX_HOME_DIR}/sandbox-module/
-u : unload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ private static String getSandboxProviderPath(String sandboxHome) {
.getParent();

private static final String SANDBOX_USER_MODULE_PATH
= System.getProperties().getProperty("user.home")
+ File.separator + ".sandbox-module";
= DEFAULT_SANDBOX_HOME
+ File.separator + "sandbox-module";

// 启动模式: agent方式加载
private static final String LAUNCH_MODE_AGENT = "agent";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class CoreConfigure {
// 受保护key数组,在保护key范围之内,如果前端已经传递过参数了,只能认前端,后端无法修改
private static final String[] PROTECT_KEY_ARRAY = {KEY_NAMESPACE, KEY_SANDBOX_HOME, KEY_LAUNCH_MODE, KEY_SERVER_IP, KEY_SERVER_PORT};

// 用户配置和系统默认配置都可以,需要进行合并的key,例如user_module
private static final String[] MULTI_KEY_ARRAY = {KEY_USER_MODULE_LIB_PATH};

private static final FeatureCodec codec = new FeatureCodec(';', '=');

private final Map<String, String> featureMap;
Expand All @@ -55,7 +58,15 @@ public static CoreConfigure toConfigure(final String featureString, final String

// 从配置文件中合并配置到CoreConfigure中
private static CoreConfigure mergePropertiesFile(final CoreConfigure cfg, final String propertiesFilePath) {
cfg.featureMap.putAll(propertiesToStringMap(fetchProperties(propertiesFilePath)));

// cfg.featureMap.putAll(propertiesToStringMap(fetchProperties(propertiesFilePath)));
Map<String , String> propertiesMap = propertiesToStringMap(fetchProperties(propertiesFilePath));
for (String key : MULTI_KEY_ARRAY){
if (cfg.featureMap.containsKey(key) && propertiesMap.containsKey(key)){
propertiesMap.put(key, cfg.featureMap.get(key) + ";" + propertiesMap.get(key));
}
}
cfg.featureMap.putAll(propertiesMap);
return cfg;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public void control(final Map<String, String> param, final PrintWriter writer){

final String cnPattern = getParameter(param, "class");
final String mnPattern = getParameter(param, "method");
lifeCLogger.info("param.class={}", cnPattern);
lifeCLogger.info("param.method={}", mnPattern);


int watcherId = moduleEventWatcher.watch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public void loadCompleted() {
@Override
protected void before(Advice advice) throws Throwable {


// 只关心顶层调用
if (!advice.isProcessTop()) {
return;
Expand Down

0 comments on commit 534f315

Please sign in to comment.