test_class.declarator: protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension()
test_class.modifier: private
test_class.original_string: private Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
test_class.type: Protocol
test_class.var_name: protocol
test_class.declarator: proxy = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension()
test_class.modifier: private
test_class.original_string: private ProxyFactory proxy = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
test_class.type: ProxyFactory
test_class.var_name: proxy
test_class.file: dubbo-rpc/dubbo-rpc-dubbo/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocolTest.java
test_class.identifier: DubboProtocolTest
test_case.body: @Test
      public void testDubboProtocol() throws Exception {
          DemoService service = new DemoServiceImpl();
          protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:9010/" + DemoService.class.getName())));
          service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:9010/" + DemoService.class.getName())));
          assertEquals(service.enumlength(new Type[]{}), Type.Lower);
          assertEquals(service.getSize(null), -1);
          assertEquals(service.getSize(new String[]{"", "", ""}), 3);
          Map<String, String> map = new HashMap<String, String>();
          map.put("aa", "bb");
          Set<String> set = service.keys(map);
          assertEquals(set.size(), 1);
          assertEquals(set.iterator().next(), "aa");
          service.invoke("dubbo://127.0.0.1:9010/" + DemoService.class.getName() + "", "invoke");
  
          service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:9010/" + DemoService.class.getName() + "?client=netty")));
          // test netty client
          StringBuffer buf = new StringBuffer();
          for (int i = 0; i < 1024 * 32 + 32; i++)
              buf.append('A');
          System.out.println(service.stringLength(buf.toString()));
  
          // cast to EchoService
          EchoService echo = proxy.getProxy(protocol.refer(EchoService.class, URL.valueOf("dubbo://127.0.0.1:9010/" + DemoService.class.getName() + "?client=netty")));
          assertEquals(echo.$echo(buf.toString()), buf.toString());
          assertEquals(echo.$echo("test"), "test");
          assertEquals(echo.$echo("abcdefg"), "abcdefg");
          assertEquals(echo.$echo(1234), 1234);
      }
test_case.class_method_signature: DubboProtocolTest.testDubboProtocol()
test_case.full_signature: @Test public void testDubboProtocol()
test_case.identifier: testDubboProtocol
test_case.invocations: export getInvoker valueOf getName getProxy refer valueOf getName assertEquals enumlength assertEquals getSize assertEquals getSize put keys assertEquals size assertEquals next iterator invoke getName getProxy refer valueOf getName append println stringLength toString getProxy refer valueOf getName assertEquals echo toString toString assertEquals echo assertEquals echo assertEquals echo
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testDubboProtocol()
focal_class.declarator: NAME = "dubbo"
focal_class.modifier: public static final
focal_class.original_string: public static final String NAME = "dubbo";
focal_class.type: String
focal_class.var_name: NAME
focal_class.declarator: DEFAULT_PORT = 20880
focal_class.modifier: public static final
focal_class.original_string: public static final int DEFAULT_PORT = 20880;
focal_class.type: int
focal_class.var_name: DEFAULT_PORT
focal_class.declarator: IS_CALLBACK_SERVICE_INVOKE = "_isCallBackServiceInvoke"
focal_class.modifier: private static final
focal_class.original_string: private static final String IS_CALLBACK_SERVICE_INVOKE = "_isCallBackServiceInvoke";
focal_class.type: String
focal_class.var_name: IS_CALLBACK_SERVICE_INVOKE
focal_class.declarator: INSTANCE
focal_class.modifier: private static
focal_class.original_string: private static DubboProtocol INSTANCE;
focal_class.type: DubboProtocol
focal_class.var_name: INSTANCE
focal_class.declarator: serverMap = new ConcurrentHashMap<String, ExchangeServer>()
focal_class.modifier: private final
focal_class.original_string: private final Map<String, ExchangeServer> serverMap = new ConcurrentHashMap<String, ExchangeServer>();
focal_class.type: Map<String, ExchangeServer>
focal_class.var_name: serverMap
focal_class.declarator: referenceClientMap = new ConcurrentHashMap<String, ReferenceCountExchangeClient>()
focal_class.modifier: private final
focal_class.original_string: private final Map<String, ReferenceCountExchangeClient> referenceClientMap = new ConcurrentHashMap<String, ReferenceCountExchangeClient>();
focal_class.type: Map<String, ReferenceCountExchangeClient>
focal_class.var_name: referenceClientMap
focal_class.declarator: ghostClientMap = new ConcurrentHashMap<String, LazyConnectExchangeClient>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<String, LazyConnectExchangeClient> ghostClientMap = new ConcurrentHashMap<String, LazyConnectExchangeClient>();
focal_class.type: ConcurrentMap<String, LazyConnectExchangeClient>
focal_class.var_name: ghostClientMap
focal_class.declarator: locks = new ConcurrentHashMap<String, Object>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<String, Object> locks = new ConcurrentHashMap<String, Object>();
focal_class.type: ConcurrentMap<String, Object>
focal_class.var_name: locks
focal_class.declarator: optimizers = new ConcurrentHashSet<String>()
focal_class.modifier: private final
focal_class.original_string: private final Set<String> optimizers = new ConcurrentHashSet<String>();
focal_class.type: Set<String>
focal_class.var_name: optimizers
focal_class.declarator: stubServiceMethodsMap = new ConcurrentHashMap<String, String>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<String, String> stubServiceMethodsMap = new ConcurrentHashMap<String, String>();
focal_class.type: ConcurrentMap<String, String>
focal_class.var_name: stubServiceMethodsMap
focal_class.declarator: requestHandler = new ExchangeHandlerAdapter() {
  
          @Override
          public Object reply(ExchangeChannel channel, Object message) throws RemotingException {
              if (message instanceof Invocation) {
                  Invocation inv = (Invocation) message;
                  Invoker<?> invoker = getInvoker(channel, inv);
                  // need to consider backward-compatibility if it's a callback
                  if (Boolean.TRUE.toString().equals(inv.getAttachments().get(IS_CALLBACK_SERVICE_INVOKE))) {
                      String methodsStr = invoker.getUrl().getParameters().get("methods");
                      boolean hasMethod = false;
                      if (methodsStr == null || methodsStr.indexOf(",") == -1) {
                          hasMethod = inv.getMethodName().equals(methodsStr);
                      } else {
                          String[] methods = methodsStr.split(",");
                          for (String method : methods) {
                              if (inv.getMethodName().equals(method)) {
                                  hasMethod = true;
                                  break;
                              }
                          }
                      }
                      if (!hasMethod) {
                          logger.warn(new IllegalStateException("The methodName " + inv.getMethodName()
                                  + " not found in callback service interface ,invoke will be ignored."
                                  + " please update the api interface. url is:"
                                  + invoker.getUrl()) + " ,invocation is :" + inv);
                          return null;
                      }
                  }
                  RpcContext.getContext().setRemoteAddress(channel.getRemoteAddress());
                  return invoker.invoke(inv);
              }
              throw new RemotingException(channel, "Unsupported request: "
                      + (message == null ? null : (message.getClass().getName() + ": " + message))
                      + ", channel: consumer: " + channel.getRemoteAddress() + " --> provider: " + channel.getLocalAddress());
          }
  
          @Override
          public void received(Channel channel, Object message) throws RemotingException {
              if (message instanceof Invocation) {
                  reply((ExchangeChannel) channel, message);
              } else {
                  super.received(channel, message);
              }
          }
  
          @Override
          public void connected(Channel channel) throws RemotingException {
              invoke(channel, Constants.ON_CONNECT_KEY);
          }
  
          @Override
          public void disconnected(Channel channel) throws RemotingException {
              if (logger.isInfoEnabled()) {
                  logger.info("disconnected from " + channel.getRemoteAddress() + ",url:" + channel.getUrl());
              }
              invoke(channel, Constants.ON_DISCONNECT_KEY);
          }
  
          private void invoke(Channel channel, String methodKey) {
              Invocation invocation = createInvocation(channel, channel.getUrl(), methodKey);
              if (invocation != null) {
                  try {
                      received(channel, invocation);
                  } catch (Throwable t) {
                      logger.warn("Failed to invoke event method " + invocation.getMethodName() + "(), cause: " + t.getMessage(), t);
                  }
              }
          }
  
          private Invocation createInvocation(Channel channel, URL url, String methodKey) {
              String method = url.getParameter(methodKey);
              if (method == null || method.length() == 0) {
                  return null;
              }
              RpcInvocation invocation = new RpcInvocation(method, new Class<?>[0], new Object[0]);
              invocation.setAttachment(Constants.PATH_KEY, url.getPath());
              invocation.setAttachment(Constants.GROUP_KEY, url.getParameter(Constants.GROUP_KEY));
              invocation.setAttachment(Constants.INTERFACE_KEY, url.getParameter(Constants.INTERFACE_KEY));
              invocation.setAttachment(Constants.VERSION_KEY, url.getParameter(Constants.VERSION_KEY));
              if (url.getParameter(Constants.STUB_EVENT_KEY, false)) {
                  invocation.setAttachment(Constants.STUB_EVENT_KEY, Boolean.TRUE.toString());
              }
              return invocation;
          }
      }
focal_class.modifier: private
focal_class.original_string: private ExchangeHandler requestHandler = new ExchangeHandlerAdapter() {
  
          @Override
          public Object reply(ExchangeChannel channel, Object message) throws RemotingException {
              if (message instanceof Invocation) {
                  Invocation inv = (Invocation) message;
                  Invoker<?> invoker = getInvoker(channel, inv);
                  // need to consider backward-compatibility if it's a callback
                  if (Boolean.TRUE.toString().equals(inv.getAttachments().get(IS_CALLBACK_SERVICE_INVOKE))) {
                      String methodsStr = invoker.getUrl().getParameters().get("methods");
                      boolean hasMethod = false;
                      if (methodsStr == null || methodsStr.indexOf(",") == -1) {
                          hasMethod = inv.getMethodName().equals(methodsStr);
                      } else {
                          String[] methods = methodsStr.split(",");
                          for (String method : methods) {
                              if (inv.getMethodName().equals(method)) {
                                  hasMethod = true;
                                  break;
                              }
                          }
                      }
                      if (!hasMethod) {
                          logger.warn(new IllegalStateException("The methodName " + inv.getMethodName()
                                  + " not found in callback service interface ,invoke will be ignored."
                                  + " please update the api interface. url is:"
                                  + invoker.getUrl()) + " ,invocation is :" + inv);
                          return null;
                      }
                  }
                  RpcContext.getContext().setRemoteAddress(channel.getRemoteAddress());
                  return invoker.invoke(inv);
              }
              throw new RemotingException(channel, "Unsupported request: "
                      + (message == null ? null : (message.getClass().getName() + ": " + message))
                      + ", channel: consumer: " + channel.getRemoteAddress() + " --> provider: " + channel.getLocalAddress());
          }
  
          @Override
          public void received(Channel channel, Object message) throws RemotingException {
              if (message instanceof Invocation) {
                  reply((ExchangeChannel) channel, message);
              } else {
                  super.received(channel, message);
              }
          }
  
          @Override
          public void connected(Channel channel) throws RemotingException {
              invoke(channel, Constants.ON_CONNECT_KEY);
          }
  
          @Override
          public void disconnected(Channel channel) throws RemotingException {
              if (logger.isInfoEnabled()) {
                  logger.info("disconnected from " + channel.getRemoteAddress() + ",url:" + channel.getUrl());
              }
              invoke(channel, Constants.ON_DISCONNECT_KEY);
          }
  
          private void invoke(Channel channel, String methodKey) {
              Invocation invocation = createInvocation(channel, channel.getUrl(), methodKey);
              if (invocation != null) {
                  try {
                      received(channel, invocation);
                  } catch (Throwable t) {
                      logger.warn("Failed to invoke event method " + invocation.getMethodName() + "(), cause: " + t.getMessage(), t);
                  }
              }
          }
  
          private Invocation createInvocation(Channel channel, URL url, String methodKey) {
              String method = url.getParameter(methodKey);
              if (method == null || method.length() == 0) {
                  return null;
              }
              RpcInvocation invocation = new RpcInvocation(method, new Class<?>[0], new Object[0]);
              invocation.setAttachment(Constants.PATH_KEY, url.getPath());
              invocation.setAttachment(Constants.GROUP_KEY, url.getParameter(Constants.GROUP_KEY));
              invocation.setAttachment(Constants.INTERFACE_KEY, url.getParameter(Constants.INTERFACE_KEY));
              invocation.setAttachment(Constants.VERSION_KEY, url.getParameter(Constants.VERSION_KEY));
              if (url.getParameter(Constants.STUB_EVENT_KEY, false)) {
                  invocation.setAttachment(Constants.STUB_EVENT_KEY, Boolean.TRUE.toString());
              }
              return invocation;
          }
      };
focal_class.type: ExchangeHandler
focal_class.var_name: requestHandler
focal_class.file: dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocol.java
focal_class.identifier: DubboProtocol
focal_class.class_method_signature: DubboProtocol.DubboProtocol()
focal_class.full_signature: public  DubboProtocol()
focal_class.identifier: DubboProtocol
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  DubboProtocol()
focal_class.class_method_signature: DubboProtocol.getDubboProtocol()
focal_class.full_signature: public static DubboProtocol getDubboProtocol()
focal_class.identifier: getDubboProtocol
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: DubboProtocol
focal_class.signature: DubboProtocol getDubboProtocol()
focal_class.class_method_signature: DubboProtocol.getServers()
focal_class.full_signature: public Collection<ExchangeServer> getServers()
focal_class.identifier: getServers
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Collection<ExchangeServer>
focal_class.signature: Collection<ExchangeServer> getServers()
focal_class.class_method_signature: DubboProtocol.getExporters()
focal_class.full_signature: public Collection<Exporter<?>> getExporters()
focal_class.identifier: getExporters
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Collection<Exporter<?>>
focal_class.signature: Collection<Exporter<?>> getExporters()
focal_class.class_method_signature: DubboProtocol.getExporterMap()
focal_class.full_signature:  Map<String, Exporter<?>> getExporterMap()
focal_class.identifier: getExporterMap
focal_class.parameters: ()
focal_class.return: Map<String, Exporter<?>>
focal_class.signature: Map<String, Exporter<?>> getExporterMap()
focal_class.class_method_signature: DubboProtocol.isClientSide(Channel channel)
focal_class.full_signature: private boolean isClientSide(Channel channel)
focal_class.identifier: isClientSide
focal_class.modifiers: private
focal_class.parameters: (Channel channel)
focal_class.return: boolean
focal_class.signature: boolean isClientSide(Channel channel)
focal_class.class_method_signature: DubboProtocol.getInvoker(Channel channel, Invocation inv)
focal_class.full_signature:  Invoker<?> getInvoker(Channel channel, Invocation inv)
focal_class.identifier: getInvoker
focal_class.parameters: (Channel channel, Invocation inv)
focal_class.return: Invoker<?>
focal_class.signature: Invoker<?> getInvoker(Channel channel, Invocation inv)
focal_class.class_method_signature: DubboProtocol.getInvokers()
focal_class.full_signature: public Collection<Invoker<?>> getInvokers()
focal_class.identifier: getInvokers
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Collection<Invoker<?>>
focal_class.signature: Collection<Invoker<?>> getInvokers()
focal_class.class_method_signature: DubboProtocol.getDefaultPort()
focal_class.full_signature: @Override public int getDefaultPort()
focal_class.identifier: getDefaultPort
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getDefaultPort()
focal_class.class_method_signature: DubboProtocol.export(Invoker<T> invoker)
focal_class.full_signature: @Override public Exporter<T> export(Invoker<T> invoker)
focal_class.identifier: export
focal_class.modifiers: @Override public
focal_class.parameters: (Invoker<T> invoker)
focal_class.return: Exporter<T>
focal_class.signature: Exporter<T> export(Invoker<T> invoker)
focal_class.class_method_signature: DubboProtocol.openServer(URL url)
focal_class.full_signature: private void openServer(URL url)
focal_class.identifier: openServer
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void openServer(URL url)
focal_class.class_method_signature: DubboProtocol.createServer(URL url)
focal_class.full_signature: private ExchangeServer createServer(URL url)
focal_class.identifier: createServer
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: ExchangeServer
focal_class.signature: ExchangeServer createServer(URL url)
focal_class.class_method_signature: DubboProtocol.optimizeSerialization(URL url)
focal_class.full_signature: private void optimizeSerialization(URL url)
focal_class.identifier: optimizeSerialization
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void optimizeSerialization(URL url)
focal_class.class_method_signature: DubboProtocol.refer(Class<T> serviceType, URL url)
focal_class.full_signature: @Override public Invoker<T> refer(Class<T> serviceType, URL url)
focal_class.identifier: refer
focal_class.modifiers: @Override public
focal_class.parameters: (Class<T> serviceType, URL url)
focal_class.return: Invoker<T>
focal_class.signature: Invoker<T> refer(Class<T> serviceType, URL url)
focal_class.class_method_signature: DubboProtocol.getClients(URL url)
focal_class.full_signature: private ExchangeClient[] getClients(URL url)
focal_class.identifier: getClients
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: ExchangeClient[]
focal_class.signature: ExchangeClient[] getClients(URL url)
focal_class.class_method_signature: DubboProtocol.getSharedClient(URL url)
focal_class.full_signature: private ExchangeClient getSharedClient(URL url)
focal_class.identifier: getSharedClient
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: ExchangeClient
focal_class.signature: ExchangeClient getSharedClient(URL url)
focal_class.class_method_signature: DubboProtocol.initClient(URL url)
focal_class.full_signature: private ExchangeClient initClient(URL url)
focal_class.identifier: initClient
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: ExchangeClient
focal_class.signature: ExchangeClient initClient(URL url)
focal_class.class_method_signature: DubboProtocol.destroy()
focal_class.full_signature: @Override public void destroy()
focal_class.identifier: destroy
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void destroy()
focal_class.superclass: extends AbstractProtocol
focal_method.body: public DubboProtocol() {
          INSTANCE = this;
      }
focal_method.class_method_signature: DubboProtocol.DubboProtocol()
focal_method.full_signature: public  DubboProtocol()
focal_method.identifier: DubboProtocol
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.signature:  DubboProtocol()