Closed JacksenLaw closed 6 years ago
interceptor:com.billy.cc.core.component.LocalCCInterceptor.CCResult:{"success":false,"code":1,"errorMessage":"has not support for action:login"}
componentName和actionName都是一样的
`public class ComponentB implements IComponent {
public static final String ComponentName = "library_b.ComponentB"; private AtomicBoolean initialized = new AtomicBoolean(false); private final HashMap<String, IActionProcessor> map = new HashMap<>(4); public void initProcessors() { } private void add(IActionProcessor processor) { map.put(processor.getActionName(), processor); } @Override public String getName() { return ComponentName; } @Override public boolean onCall(CC cc) {
// switch (cc.getActionName()) { // case "login": // map.put(cc.getActionName(), new LoginProcessor()); // break; // case "getNetData": // map.put(cc.getActionName(), new NetProcessor()); // break; // }
if (initialized.compareAndSet(false, true)) { synchronized (map) { initProcessors(); } } String actionName = cc.getActionName(); IActionProcessor processor = map.get(actionName); if (processor != null) { return processor.onActionCall(cc); } CC.sendCCResult(cc.getCallId(), CCResult.error("has not support for action:" + cc.getActionName())); return false; }`
其中map的size为0
如果需要像Demo_b那样使用ActionProcessor,需要注意以下两点:
interceptor:com.billy.cc.core.component.LocalCCInterceptor.CCResult:{"success":false,"code":1,"errorMessage":"has not support for action:login"}
componentName和actionName都是一样的
`public class ComponentB implements IComponent {
// switch (cc.getActionName()) { // case "login": // map.put(cc.getActionName(), new LoginProcessor()); // break; // case "getNetData": // map.put(cc.getActionName(), new NetProcessor()); // break; // }
其中map的size为0