/** * Tries to registers action path using {@link #mapActionPathToSignature(String, String) CoC mapping}. */ protected ActionConfig registerActionPath(String actionPath, String packageRoot) { String signature = mapActionPathToSignature(actionPath, packageRoot); try { return actionsManager.register(signature, actionPath); } catch(MadvocException ignore) { return null; } }
/** * Resolves action config from action path and http method. Returns <code>null</code> * if action config not found. Performs initialization of founded action config, * if necessary. */ protected ActionConfig resolveActionConfig(String actionPath, String httpMethod) { ActionConfig actionConfig = actionPathMapper.resolveActionConfig(actionPath, httpMethod); if (actionConfig != null) { if (actionConfig.initialized == false) { initializeActionConfig(actionConfig); } } return actionConfig; }
/** * Performs action config lookup from action path and http request method. * Lookups action configuration from action path and resolves * unregistered paths. Lookup may be optionally disabled if mapping is not used. */ public ActionConfig resolveActionConfig(String actionPath, String method) { String[] actionPathChunks = MadvocUtil.splitActionPath(actionPath); ActionConfig cfg = actionsManager.lookup(actionPath, actionPathChunks, method); if ((cfg == null) && madvocConfig.isActionPathMappingEnabled()) { String packageRoot = madvocConfig.getRootPackage(); if (packageRoot != null) { cfg = registerActionPath(actionPath, packageRoot); // cfg = actionsManager.lookup(actionPath, actionPathChunks); } } if ((cfg == null) && madvocConfig.getSupplementAction() != null) { cfg = registerSupplementAction(actionPath); // cfg = actionsManager.lookup(actionPath, actionPathChunks); } return cfg; }
/** * Maps action path to method signature. Actually, just parse the action path and * calls the {@link #buildSignature(String, String, String, String, String)}. */ protected String mapActionPathToSignature(String actionPath, String packageRoot) { // package int slashNdx = actionPath.lastIndexOf('/'); if (slashNdx > 0) { int start = actionPath.startsWith(StringPool.SLASH) ? 1 : 0; packageRoot += '.' + actionPath.substring(start, slashNdx).replace('/', '.'); } String className; String methodName = null; String extension = null; int dotNdx = actionPath.indexOf('.', slashNdx); if (dotNdx != -1) { className = actionPath.substring(slashNdx + 1, dotNdx); int extNdx = actionPath.indexOf('.', dotNdx + 1); if (extNdx != -1) { methodName = actionPath.substring(dotNdx + 1, extNdx); extension = actionPath.substring(extNdx + 1); } else { methodName = null; extension = actionPath.substring(dotNdx + 1); } } else { className = actionPath.substring(slashNdx + 1); } return buildSignature(packageRoot, className, methodName, extension, null); }