private static void registerSuperclassForwards( final ActionMapping actionMapping, Class<?> superclass, Mapping mapping, String defaultResourcesName) { if (UPPER_BOUND_SUPERCLASSES.contains(superclass.getSimpleName())) { return; } Forwards forwards = superclass.getAnnotation(Forwards.class); if (forwards == null) { return; } for (final Forward forward : forwards.value()) { try { actionMapping.findForward(forward.name()); } catch (NullPointerException ex) { // Forward wasn't registered in any subclass, so register it. registerForward(actionMapping, forward, forwards, mapping, defaultResourcesName); } } registerSuperclassForwards( actionMapping, superclass.getSuperclass(), mapping, defaultResourcesName); }
public PartialTileDefinition( Forward forward, Forwards forwards, Mapping mapping, String defaultBundleName) { Tile localTile = forward.tileProperties(); Tile globalTile = forwards.tileProperties(); path = forward.path(); extend = getDefinedValue(localTile.extend(), globalTile.extend(), getDefaultValue("extend")); title = getDefinedValue(localTile.title(), globalTile.title(), getDefaultValue("title")); customBundleName = getDefinedValue(localTile.bundle(), globalTile.bundle(), getDefaultValue("bundle")); this.defaultBundleName = (defaultBundleName == null) ? mapping.module() : defaultBundleName; for (Method tileMethod : tileMethods) { TileCustomPropertyName tileCustomProperty = tileMethod.getAnnotation(TileCustomPropertyName.class); String tileMethodName = (tileCustomProperty != null) ? tileCustomProperty.value() : tileMethod.getName(); String localValue = invokeAnnotationMethod(tileMethod, localTile); String globalValue = invokeAnnotationMethod(tileMethod, globalTile); attributeValues.put( tileMethodName, getDefinedValue(localValue, globalValue, (String) tileMethod.getDefaultValue())); attributeDefaults.put(tileMethodName, (String) tileMethod.getDefaultValue()); } }
@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); } }