test_class.declarator: SCRIPT_URL = URL.valueOf("script://javascript?type=javascript")
test_class.modifier: private
test_class.original_string: private URL SCRIPT_URL = URL.valueOf("script://javascript?type=javascript");
test_class.type: URL
test_class.var_name: SCRIPT_URL
test_class.file: dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/script/ScriptRouterTest.java
test_class.identifier: ScriptRouterTest
test_case.body: @Test
      public void testRoutePickInvokers() {
          String rule = "var result = new java.util.ArrayList(invokers.size());" +
                  "for (i=0;i<invokers.size(); i++){ " +
                  "if (invokers.get(i).isAvailable()) {" +
                  "result.add(invokers.get(i)) ;" +
                  "}" +
                  "} ; " +
                  "return result;";
          String script = "function route(invokers,invocation,context){" + rule + "} route(invokers,invocation,context)";
          Router router = new ScriptRouterFactory().getRouter(getRouteUrl(script));
  
          List<Invoker<String>> invokers = new ArrayList<Invoker<String>>();
          Invoker<String> invoker1 = new MockInvoker<String>(false);
          Invoker<String> invoker2 = new MockInvoker<String>(true);
          Invoker<String> invoker3 = new MockInvoker<String>(true);
          invokers.add(invoker1);
          invokers.add(invoker2);
          invokers.add(invoker3);
          List<Invoker<String>> filteredInvokers = router.route(invokers, invokers.get(0).getUrl(), new RpcInvocation());
          Assertions.assertEquals(2, filteredInvokers.size());
          Assertions.assertEquals(invoker2, filteredInvokers.get(0));
          Assertions.assertEquals(invoker3, filteredInvokers.get(1));
      }
test_case.class_method_signature: ScriptRouterTest.testRoutePickInvokers()
test_case.full_signature: @Test public void testRoutePickInvokers()
test_case.identifier: testRoutePickInvokers
test_case.invocations: getRouter getRouteUrl add add add route getUrl get assertEquals size assertEquals get assertEquals get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRoutePickInvokers()
focal_class.declarator: NAME = "SCRIPT_ROUTER"
focal_class.modifier: public static final
focal_class.original_string: public static final String NAME = "SCRIPT_ROUTER";
focal_class.type: String
focal_class.var_name: NAME
focal_class.declarator: SCRIPT_ROUTER_DEFAULT_PRIORITY = 0
focal_class.modifier: private static final
focal_class.original_string: private static final int SCRIPT_ROUTER_DEFAULT_PRIORITY = 0;
focal_class.type: int
focal_class.var_name: SCRIPT_ROUTER_DEFAULT_PRIORITY
focal_class.declarator: logger = LoggerFactory.getLogger(ScriptRouter.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(ScriptRouter.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: ENGINES = new ConcurrentHashMap<>()
focal_class.modifier: private static final
focal_class.original_string: private static final Map<String, ScriptEngine> ENGINES = new ConcurrentHashMap<>();
focal_class.type: Map<String, ScriptEngine>
focal_class.var_name: ENGINES
focal_class.declarator: engine
focal_class.modifier: private final
focal_class.original_string: private final ScriptEngine engine;
focal_class.type: ScriptEngine
focal_class.var_name: engine
focal_class.declarator: rule
focal_class.modifier: private final
focal_class.original_string: private final String rule;
focal_class.type: String
focal_class.var_name: rule
focal_class.declarator: function
focal_class.modifier: private
focal_class.original_string: private CompiledScript function;
focal_class.type: CompiledScript
focal_class.var_name: function
focal_class.file: dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/script/ScriptRouter.java
focal_class.identifier: ScriptRouter
focal_class.class_method_signature: ScriptRouter.ScriptRouter(URL url)
focal_class.full_signature: public  ScriptRouter(URL url)
focal_class.identifier: ScriptRouter
focal_class.modifiers: public
focal_class.parameters: (URL url)
focal_class.signature:  ScriptRouter(URL url)
focal_class.class_method_signature: ScriptRouter.getRule(URL url)
focal_class.full_signature: private String getRule(URL url)
focal_class.identifier: getRule
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: String
focal_class.signature: String getRule(URL url)
focal_class.class_method_signature: ScriptRouter.getEngine(URL url)
focal_class.full_signature: private ScriptEngine getEngine(URL url)
focal_class.identifier: getEngine
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: ScriptEngine
focal_class.signature: ScriptEngine getEngine(URL url)
focal_class.class_method_signature: ScriptRouter.route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.full_signature: @Override public List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.identifier: route
focal_class.modifiers: @Override public
focal_class.parameters: (List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.return: List<Invoker<T>>
focal_class.signature: List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.class_method_signature: ScriptRouter.getRoutedInvokers(Object obj)
focal_class.full_signature: @SuppressWarnings("unchecked") protected List<Invoker<T>> getRoutedInvokers(Object obj)
focal_class.identifier: getRoutedInvokers
focal_class.modifiers: @SuppressWarnings("unchecked") protected
focal_class.parameters: (Object obj)
focal_class.return: List<Invoker<T>>
focal_class.signature: List<Invoker<T>> getRoutedInvokers(Object obj)
focal_class.class_method_signature: ScriptRouter.createBindings(List<Invoker<T>> invokers, Invocation invocation)
focal_class.full_signature: private Bindings createBindings(List<Invoker<T>> invokers, Invocation invocation)
focal_class.identifier: createBindings
focal_class.modifiers: private
focal_class.parameters: (List<Invoker<T>> invokers, Invocation invocation)
focal_class.return: Bindings
focal_class.signature: Bindings createBindings(List<Invoker<T>> invokers, Invocation invocation)
focal_class.class_method_signature: ScriptRouter.isRuntime()
focal_class.full_signature: @Override public boolean isRuntime()
focal_class.identifier: isRuntime
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isRuntime()
focal_class.class_method_signature: ScriptRouter.isForce()
focal_class.full_signature: @Override public boolean isForce()
focal_class.identifier: isForce
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isForce()
focal_class.superclass: extends AbstractRouter
focal_method.body: @Override
      public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException {
          try {
              Bindings bindings = createBindings(invokers, invocation);
              if (function == null) {
                  return invokers;
              }
              return getRoutedInvokers(function.eval(bindings));
          } catch (ScriptException e) {
              logger.error("route error, rule has been ignored. rule: " + rule + ", method:" +
                      invocation.getMethodName() + ", url: " + RpcContext.getContext().getUrl(), e);
              return invokers;
          }
      }
focal_method.class_method_signature: ScriptRouter.route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_method.full_signature: @Override public List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_method.identifier: route
focal_method.invocations: createBindings getRoutedInvokers eval error getMethodName getUrl getContext
focal_method.modifiers: @Override public
focal_method.parameters: (List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_method.return: List<Invoker<T>>
focal_method.signature: List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation)