private MappingNode prepareMappingTree(List<Module> modules) { Mapping rootMapping = new ConstantMapping(""); MappingNode mappingTree = new MappingNode(rootMapping); LinkedEngine rootEngine = new LinkedEngine(null, new RootEngine(instructionExecutor), mappingTree); mappingTree.getMiddleEngines().addEngine(ReqMethod.ALL, rootEngine); TreeBuilder treeBuilder = new TreeBuilder(); treeBuilder.create(mappingTree, modules); return mappingTree; }
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 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 MappingNode prepareMappingTree(List<Module> modules) { Mapping rootMapping = new ConstantMapping(""); MappingNode mappingTree = new MappingNode(rootMapping); LinkedEngine rootEngine = new LinkedEngine(null, new RootEngine(instructionExecutor), mappingTree); mappingTree.getMiddleEngines().addEngine(ReqMethod.ALL, rootEngine); TreeBuilder treeBuilder = new TreeBuilder(); treeBuilder.create(mappingTree, modules); return mappingTree; }
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); } } }