Esempio n. 1
0
  Handler(Route root, Bridge bridge) throws ServletException {
    this.bridge = bridge;

    //
    try {
      bridge.boot();

      //
      HashMap<MethodHandle, Route> routeMap = new HashMap<MethodHandle, Route>();
      HashMap<Route, Map<Phase, MethodHandle>> routeMap2 =
          new HashMap<Route, Map<Phase, MethodHandle>>();

      //
      RouteDescriptor routesDesc =
          (RouteDescriptor) bridge.runtime.getDescriptor().getPluginDescriptor("router");
      if (routesDesc != null) {
        for (RouteDescriptor child : routesDesc.getChildren()) {
          Route route = root.append(child.getPath());
          for (Map.Entry<String, String> entry : child.getTargets().entrySet()) {
            MethodHandle handle = MethodHandle.parse(entry.getValue());
            Phase phase = Phase.valueOf(entry.getKey());
            routeMap.put(handle, route);
            Map<Phase, MethodHandle> map = routeMap2.get(route);
            if (map == null) {
              routeMap2.put(route, map = new HashMap<Phase, MethodHandle>());
            }
            map.put(phase, handle);
          }
        }
      }

      //
      this.root = root;
      this.routeMap = routeMap;
      this.routeMap2 = routeMap2;
    } catch (Exception e) {
      throw ServletBridge.wrap(e);
    }
  }