mappings.add(createConstantMapping(path, constantBegin, i)); constantBegin = -1; mappings.add(createRegexMapping(path, paramBegin, paramNameEnd, i)); paramBegin = -1; paramNameEnd = -1; mappings.add(createRegexMapping(path, paramBegin, paramNameEnd, i)); paramBegin = -1; paramNameEnd = -1; mappings.add(createConstantMapping(path, constantBegin, i)); constantBegin = -1; "invalid string '" + path + "', wrong '}' at position " + i); } else { mappings.add(createRegexMapping(path, paramBegin, paramNameEnd, i)); paramBegin = -1; paramNameEnd = -1; if (paramBegin < 0) { if (constantBegin >= 0) { mappings.add(createConstantMapping(path, constantBegin, i)); mappings.add(createRegexMapping(path, paramBegin, paramNameEnd, i)); paramBegin = -1; constantBegin = i; mappings.add(createConstantMapping(path, constantBegin, chars.length));
private void addAction(Module module, ControllerRef controller, MethodRef action, MappingNode controllerNode, LinkedEngine controllerEngine) { Map<String, Set<ReqMethod>> mappingPaths = action.getMappings(); if (mappingPaths.size() == 0) { return; } Engine actionEngine = new ActionEngine(module, controller.getControllerClass(),// controller.getControllerObject(), action.getMethod()); for (String mappingPath : mappingPaths.keySet()) { List<Mapping> mappings = MappingFactory.parse(mappingPath); MappingNode target = controllerNode; for (Mapping mapping : mappings) { if (mapping.getDefinition().length() == 0) { continue; } MappingNode temp = target.getChild(mapping.getDefinition()); if (temp == null) { temp = new MappingNode(mapping); target.linkAsChild(temp); } target = temp; } // for (ReqMethod method : mappingPaths.get(mappingPath)) { LinkedEngine linkedActionEngine = new LinkedEngine(// controllerEngine, actionEngine, target); target.getLeafEngines().addEngine(method, linkedActionEngine); } } }
mappings.add(createConstantMapping(path, constantBegin, i)); constantBegin = -1; mappings.add(createRegexMapping(path, paramBegin, paramNameEnd, i)); paramBegin = -1; paramNameEnd = -1; mappings.add(createRegexMapping(path, paramBegin, paramNameEnd, i)); paramBegin = -1; paramNameEnd = -1; mappings.add(createConstantMapping(path, constantBegin, i)); constantBegin = -1; "invalid string '" + path + "', wrong '}' at position " + i); } else { mappings.add(createRegexMapping(path, paramBegin, paramNameEnd, i)); paramBegin = -1; paramNameEnd = -1; if (paramBegin < 0) { if (constantBegin >= 0) { mappings.add(createConstantMapping(path, constantBegin, i)); mappings.add(createRegexMapping(path, paramBegin, paramNameEnd, i)); paramBegin = -1; constantBegin = i; mappings.add(createConstantMapping(path, constantBegin, chars.length));
private void addController(Module module, MappingNode moduleNode, LinkedEngine moduleEngine, ControllerRef controller) { // Engine engine = new ControllerEngine(module, controller); Set<String> mappingPaths = new HashSet<String>(Arrays.asList(controller.getMappingPaths())); for (String mappingPath : mappingPaths) { List<Mapping> mappings = MappingFactory.parse(mappingPath); // MappingNode target = moduleNode; for (Mapping mapping : mappings) { if (mapping.getDefinition().length() == 0) { continue; } MappingNode temp = target.getChild(mapping.getDefinition()); if (temp == null) { temp = new MappingNode(mapping); target.linkAsChild(temp); } target = temp; } LinkedEngine controllerEngine = new LinkedEngine(moduleEngine, engine, target); target.getMiddleEngines().addEngine(ReqMethod.ALL, controllerEngine); // // actions MethodRef[] actions = controller.getActions(); for (MethodRef action : actions) { addAction(module, controller, action, target, controllerEngine); } } }
private void addModule(final MappingNode rootNode, Module module) { List<Mapping> terms = MappingFactory.parse(module.getMappingPath()); LinkedEngine rootEngine = rootNode.getMiddleEngines().getEngines(ReqMethod.GET)[0]; MappingNode parent = rootNode; for (Mapping mapping : terms) { if (mapping.getDefinition().length() == 0) { continue; } MappingNode temp = parent.getChild(mapping.getDefinition()); if (temp == null) { temp = new MappingNode(mapping); parent.linkAsChild(temp); } parent = temp; } LinkedEngine moduleEngine = new LinkedEngine(rootEngine, new ModuleEngine(module), parent); parent.getMiddleEngines().addEngine(ReqMethod.ALL, moduleEngine); // controllers List<ControllerRef> controllers = module.getControllers(); for (ControllerRef controller : controllers) { addController(module, parent, moduleEngine, controller); } }
private void addAction(Module module, ControllerRef controller, MethodRef action, MappingNode controllerNode, LinkedEngine controllerEngine) { Map<String, Set<ReqMethod>> mappingPaths = action.getMappings(); if (mappingPaths.size() == 0) { return; } Engine actionEngine = new ActionEngine(module, controller.getControllerClass(),// controller.getControllerObject(), action.getMethod()); for (String mappingPath : mappingPaths.keySet()) { List<Mapping> mappings = MappingFactory.parse(mappingPath); MappingNode target = controllerNode; for (Mapping mapping : mappings) { if (mapping.getDefinition().length() == 0) { continue; } MappingNode temp = target.getChild(mapping.getDefinition()); if (temp == null) { temp = new MappingNode(mapping); target.linkAsChild(temp); } target = temp; } // for (ReqMethod method : mappingPaths.get(mappingPath)) { LinkedEngine linkedActionEngine = new LinkedEngine(// controllerEngine, actionEngine, target); target.getLeafEngines().addEngine(method, linkedActionEngine); } } }
private void addController(Module module, MappingNode moduleNode, LinkedEngine moduleEngine, ControllerRef controller) { // Engine engine = new ControllerEngine(module, controller); Set<String> mappingPaths = new HashSet<String>(Arrays.asList(controller.getMappingPaths())); for (String mappingPath : mappingPaths) { List<Mapping> mappings = MappingFactory.parse(mappingPath); // MappingNode target = moduleNode; for (Mapping mapping : mappings) { if (mapping.getDefinition().length() == 0) { continue; } MappingNode temp = target.getChild(mapping.getDefinition()); if (temp == null) { temp = new MappingNode(mapping); target.linkAsChild(temp); } target = temp; } LinkedEngine controllerEngine = new LinkedEngine(moduleEngine, engine, target); target.getMiddleEngines().addEngine(ReqMethod.ALL, controllerEngine); // // actions MethodRef[] actions = controller.getActions(); for (MethodRef action : actions) { addAction(module, controller, action, target, controllerEngine); } } }
private void addModule(final MappingNode rootNode, Module module) { List<Mapping> terms = MappingFactory.parse(module.getMappingPath()); LinkedEngine rootEngine = rootNode.getMiddleEngines().getEngines(ReqMethod.GET)[0]; MappingNode parent = rootNode; for (Mapping mapping : terms) { if (mapping.getDefinition().length() == 0) { continue; } MappingNode temp = parent.getChild(mapping.getDefinition()); if (temp == null) { temp = new MappingNode(mapping); parent.linkAsChild(temp); } parent = temp; } LinkedEngine moduleEngine = new LinkedEngine(rootEngine, new ModuleEngine(module), parent); parent.getMiddleEngines().addEngine(ReqMethod.ALL, moduleEngine); // controllers List<ControllerRef> controllers = module.getControllers(); for (ControllerRef controller : controllers) { addController(module, parent, moduleEngine, controller); } }