Source:
private static String exportOrUnexportCallbackService(Channel channel, URL url, Class clazz, Object inst, Boolean export) throws IOException { int instid = System.identityHashCode(inst); Map<String, String> params = new HashMap<String, String>(3); params.put(Constants.IS_SERVER_KEY, Boolean.FALSE.toString()); params.put(Constants.IS_CALLBACK_SERVICE, Boolean.TRUE.toString()); String group = (url == null ? null : url.getParameter(Constants.GROUP_KEY)); if (group != null && group.length() > 0) { params.put(Constants.GROUP_KEY, group); } params.put(Constants.METHODS_KEY, StringUtils.join(Wrapper.getWrapper(clazz).getDeclaredMethodNames(), ",")); Map<String, String> tmpMap = new HashMap<String, String>(url.getParameters()); tmpMap.putAll(params); tmpMap.remove(Constants.VERSION_KEY); tmpMap.put(Constants.INTERFACE_KEY, clazz.getName()); URL exportUrl = new URL(DubboProtocol.NAME, channel.getLocalAddress().getAddress().getHostAddress(), channel.getLocalAddress().getPort(), clazz.getName() + "." + instid, tmpMap); String cacheKey = getClientSideCallbackServiceCacheKey(instid); String countKey = getClientSideCountKey(clazz.getName()); if (export) { if (!channel.hasAttribute(cacheKey)) { if (!isInstancesOverLimit(channel, url, clazz.getName(), instid, false)) { Invoker<?> invoker = proxyFactory.getInvoker(inst, clazz, exportUrl); Exporter<?> exporter = protocol.export(invoker); channel.setAttribute(cacheKey, exporter); logger.info("export a callback service :" + exportUrl + ", on " + channel + ", url is: " + url); increaseInstanceCount(channel, countKey); } } } else { if (channel.hasAttribute(cacheKey)) { Exporter<?> exporter = (Exporter<?>) channel.getAttribute(cacheKey); exporter.unexport(); channel.removeAttribute(cacheKey); decreaseInstanceCount(channel, countKey); } } return String.valueOf(instid); }

Target:
private static String exportOrUnexportCallbackService(Channel channel, URL url, Class clazz, Object inst, Boolean export) throws IOException { int instid = System.identityHashCode(inst); Map<String, String> params = new HashMap<>(3); params.put(Constants.IS_SERVER_KEY, Boolean.FALSE.toString()); params.put(Constants.IS_CALLBACK_SERVICE, Boolean.TRUE.toString()); String group = (url == null ? null : url.getParameter(Constants.GROUP_KEY)); if (group != null && group.length() > 0) { params.put(Constants.GROUP_KEY, group); } params.put(Constants.METHODS_KEY, StringUtils.join(Wrapper.getWrapper(clazz).getDeclaredMethodNames(), ",")); Map<String, String> tmpMap = new HashMap<>(url.getParameters()); tmpMap.putAll(params); tmpMap.remove(Constants.VERSION_KEY); tmpMap.put(Constants.INTERFACE_KEY, clazz.getName()); URL exportUrl = new URL(DubboProtocol.NAME, channel.getLocalAddress().getAddress().getHostAddress(), channel.getLocalAddress().getPort(), clazz.getName() + "." + instid, tmpMap); String cacheKey = getClientSideCallbackServiceCacheKey(instid); String countKey = getClientSideCountKey(clazz.getName()); if (export) { if (!channel.hasAttribute(cacheKey)) { if (!isInstancesOverLimit(channel, url, clazz.getName(), instid, false)) { Invoker<?> invoker = proxyFactory.getInvoker(inst, clazz, exportUrl); Exporter<?> exporter = protocol.export(invoker); channel.setAttribute(cacheKey, exporter); logger.info("Export a callback service :" + exportUrl + ", on " + channel + ", url is: " + url); increaseInstanceCount(channel, countKey); } } } else { if (channel.hasAttribute(cacheKey)) { Exporter<?> exporter = (Exporter<?>) channel.getAttribute(cacheKey); exporter.unexport(); channel.removeAttribute(cacheKey); decreaseInstanceCount(channel, countKey); } } return String.valueOf(instid); }