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/com/alibaba/dubbo/rpc/cluster/router/script/ScriptRouterTest.java
test_class.identifier: ScriptRouterTest
test_case.body: @Test
      public void testRoute_ReturnAll() {
          Router router = new ScriptRouterFactory().getRouter(getRouteUrl("function route(op1,op2){return op1} route(invokers)"));
          List<Invoker<String>> invokers = new ArrayList<Invoker<String>>();
          invokers.add(new MockInvoker<String>());
          invokers.add(new MockInvoker<String>());
          invokers.add(new MockInvoker<String>());
          List<Invoker<String>> fileredInvokers = router.route(invokers, invokers.get(0).getUrl(), new RpcInvocation());
          Assert.assertEquals(invokers, fileredInvokers);
      }
test_case.class_method_signature: ScriptRouterTest.testRoute_ReturnAll()
test_case.full_signature: @Test public void testRoute_ReturnAll()
test_case.identifier: testRoute_ReturnAll
test_case.invocations: getRouter getRouteUrl add add add route getUrl get assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRoute_ReturnAll()
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: DEFAULT_PRIORITY = 1
focal_class.modifier: private static final
focal_class.original_string: private static final int DEFAULT_PRIORITY = 1;
focal_class.type: int
focal_class.var_name: DEFAULT_PRIORITY
focal_class.declarator: engines = new ConcurrentHashMap<String, ScriptEngine>()
focal_class.modifier: private static final
focal_class.original_string: private static final Map<String, ScriptEngine> engines = new ConcurrentHashMap<String, ScriptEngine>();
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.file: dubbo-cluster/src/main/java/com/alibaba/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.route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.full_signature: @Override @SuppressWarnings("unchecked") public List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.identifier: route
focal_class.modifiers: @Override @SuppressWarnings("unchecked") 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.superclass: extends AbstractRouter
focal_method.body: @Override
      @SuppressWarnings("unchecked")
      public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException {
          try {
              List<Invoker<T>> invokersCopy = new ArrayList<Invoker<T>>(invokers);
              Compilable compilable = (Compilable) engine;
              Bindings bindings = engine.createBindings();
              bindings.put("invokers", invokersCopy);
              bindings.put("invocation", invocation);
              bindings.put("context", RpcContext.getContext());
              CompiledScript function = compilable.compile(rule);
              Object obj = function.eval(bindings);
              if (obj instanceof Invoker[]) {
                  invokersCopy = Arrays.asList((Invoker<T>[]) obj);
              } else if (obj instanceof Object[]) {
                  invokersCopy = new ArrayList<Invoker<T>>();
                  for (Object inv : (Object[]) obj) {
                      invokersCopy.add((Invoker<T>) inv);
                  }
              } else {
                  invokersCopy = (List<Invoker<T>>) obj;
              }
              return invokersCopy;
          } catch (ScriptException e) {
              //fail then ignore rule .invokers.
              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 @SuppressWarnings("unchecked") public List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_method.identifier: route
focal_method.invocations: createBindings put put put getContext compile eval asList add error getMethodName getUrl getContext
focal_method.modifiers: @Override @SuppressWarnings("unchecked") 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)