private ActionRuntime match(final RouteChunk chunk, final String[] path, final int ndx) { final int maxDeep = path.length - 1; if (ndx > maxDeep) { // too deep, don't go any further return null; } if (!chunk.match(path[ndx])) { // no match, continue return null; } if (ndx == maxDeep) { // end of the path if (chunk.isEndpoint()) { return chunk.value(); } return null; } // matched, scan children RouteChunk[] children = chunk.children(); if (children == null) { return null; } for (RouteChunk child : children) { ActionRuntime matched = match(child, path, ndx + 1); if (matched != null) { return matched; } } return null; }
/** * Registers manually created {@link ActionRuntime action runtime configurations}. * Optionally, if action path with the same name already exist, * exception will be thrown. */ public ActionRuntime registerActionRuntime(final ActionRuntime actionRuntime) { final String actionPath = actionRuntime.getActionPath(); final String method = actionRuntime.getActionMethod(); log.debug(() -> "Madvoc action: " + ifNotNull(method, m -> m + " ") + actionRuntime.getActionPath() + " => " + actionRuntime.createActionString()); final RouteChunk routeChunk = routes.registerPath(method, actionPath); if (routeChunk.value() != null) { // existing chunk if (detectDuplicatePathsEnabled) { throw new MadvocException("Duplicate action path for [" + actionRuntime + "] occupied by: [" + routeChunk.value() + "]"); } } else { actionsCount++; } routeChunk.bind(actionRuntime); // finally runtimes.put(actionRuntime.createActionString(), actionRuntime); // async check if (actionRuntime.isAsync()) { asyncMode = true; } return actionRuntime; }