/** * Register a given ActionMapping * * @param actionMapping * @throws Exception */ protected void registerActionMapping(ActionMapping actionMapping) throws Exception { if (actions == null) { actions = new ArrayList<ActionConfig>(); } String actionClassType = actionMapping.getType(); // Will inject the action classes inside the dotCMS context injectContext(actionClassType); ModuleConfig moduleConfig = activatorUtil.getModuleConfig(); // We need to unfreeze this module in order to add new action mappings activatorUtil.unfreeze(moduleConfig); // Adding the ActionConfig to the ForwardConfig moduleConfig.addActionConfig(actionMapping); // moduleConfig.freeze(); actions.add(actionMapping); Logger.info(this, "Added Struts Action Mapping: " + actionClassType); }
@Override public void init(ActionServlet servlet, ModuleConfig config) throws ServletException { if (!initialized) { loadActionsFromFile(actionClasses); PartialTileDefinition.init(); initialized = true; } final String modulePrefix = StringUtils.removeStart(config.getPrefix(), "/"); for (Class<?> actionClass : actionClasses) { Mapping mapping = actionClass.getAnnotation(Mapping.class); if (mapping == null || !modulePrefix.equals(mapping.module())) { continue; } final ActionMapping actionMapping = createCustomActionMapping(mapping); if (actionMapping == null) { continue; } actionMapping.setPath(mapping.path()); actionMapping.setType(actionClass.getName()); actionMapping.setScope(mapping.scope()); actionMapping.setParameter(mapping.parameter()); actionMapping.setValidate(mapping.validate()); if (mapping.formBeanClass() != ActionForm.class) { final String formName = mapping.formBeanClass().getName(); createFormBeanConfigIfNecessary(config, mapping, formName); actionMapping.setName(formName); } else if (!mapping.formBean().isEmpty()) { actionMapping.setName(mapping.formBean()); } if (mapping.input().isEmpty()) { actionMapping.setInput(findInputMethod(actionClass, mapping)); } else { registerInput(actionMapping, mapping.input()); } String defaultResourcesName = getDefaultResourcesName(config); Forwards forwards = actionClass.getAnnotation(Forwards.class); if (forwards != null) { for (final Forward forward : forwards.value()) { registerForward(actionMapping, forward, forwards, mapping, defaultResourcesName); } } registerSuperclassForwards( actionMapping, actionClass.getSuperclass(), mapping, defaultResourcesName); Exceptions exceptions = actionClass.getAnnotation(Exceptions.class); if (exceptions != null) { registerExceptionHandling(actionMapping, exceptions); } initializeActionMappingProperties(actionMapping, mapping.customMappingProperties()); config.addActionConfig(actionMapping); } }