Skip to content

Commit

Permalink
dubbo provider add getBusinessParams
Browse files Browse the repository at this point in the history
Signed-off-by: sanxun0325 <bbz17640380550@163.com>
  • Loading branch information
binbin0325 authored and xcaspar committed Dec 16, 2021
1 parent 2bbca8e commit fef7ff4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,16 @@ protected Object getUrl(Object instance, Object invocation) throws Exception {
}
return ReflectUtil.invokeMethod(instance, GET_URL, new Object[0], false);
}

@Override
protected Map<String, Map<String, String>> getBusinessParams(final Object invocation) throws Exception {
return BusinessParamUtil.getAndParse(DubboConstant.TARGET_NAME, new BusinessDataGetter() {
@Override
public String get(String key) throws Exception {
Map<String, String> attachments = ReflectUtil.invokeMethod(invocation, GET_ATTACHMENTS, new Object[0], false);
if (attachments == null || attachments.isEmpty()) {
return null;
}
return attachments.get(key);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

import com.alibaba.chaosblade.exec.common.aop.EnhancerModel;
import com.alibaba.chaosblade.exec.common.model.action.delay.TimeoutExecutor;
import com.alibaba.chaosblade.exec.common.util.BusinessParamUtil;
import com.alibaba.chaosblade.exec.common.util.ReflectUtil;
import com.alibaba.chaosblade.exec.plugin.dubbo.DubboConstant;
import com.alibaba.chaosblade.exec.plugin.dubbo.DubboEnhancer;
import com.alibaba.chaosblade.exec.spi.BusinessDataGetter;

import java.util.Map;

Expand All @@ -41,8 +43,17 @@ protected TimeoutExecutor createTimeoutExecutor(ClassLoader classLoader, long ti
}

@Override
protected Map<String, Map<String, String>> getBusinessParams(Object invocation) throws Exception {
return null;
protected Map<String, Map<String, String>> getBusinessParams(final Object invocation) throws Exception {
return BusinessParamUtil.getAndParse(DubboConstant.TARGET_NAME, new BusinessDataGetter() {
@Override
public String get(String key) throws Exception {
Map<String, String> attachments = ReflectUtil.invokeMethod(invocation, GET_ATTACHMENTS, new Object[0], false);
if (attachments == null || attachments.isEmpty()) {
return null;
}
return attachments.get(key);
}
});
}

@Override
Expand Down

0 comments on commit fef7ff4

Please sign in to comment.