Author: bpoussin Date: 2011-11-24 12:55:28 +0100 (Thu, 24 Nov 2011) New Revision: 2235 Url: http://nuiton.org/repositories/revision/nuiton-utils/2235 Log: Evolution #1823: [ApplicationConfig] add method to launch all Action in step order Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java 2011-11-24 11:22:15 UTC (rev 2234) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java 2011-11-24 11:55:28 UTC (rev 2235) @@ -58,6 +58,7 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.Enumeration; import java.util.HashMap; @@ -208,7 +209,8 @@ * <p/> * Les actions ne sont pas execute mais seulement parsees. Pour les executer * il faut utiliser la méthode {@link #doAction(int)} qui prend en argument un numero - * de 'step'. Par defaut toutes les actions sont de niveau 0 et sont executee + * de 'step' ou {@link #doAllAction()} qui fait les actions dans l'ordre de leur step. + * Par defaut toutes les actions sont de niveau 0 et sont executee * dans l'ordre d'apparition sur la ligne de commande. Si l'on souhaite * distinguer les actions il est possible d'utiliser l'annotation * {@link ApplicationConfig.Action.Step} sur la methode qui fera l'action en @@ -672,6 +674,40 @@ } /** + * Return ordered action step number. + * example: 0,1,5,6 + * + * @since 2.4 + */ + public List<Integer> getActionStep() { + List<Integer> result = new ArrayList<Integer>(actions.keySet()); + Collections.sort(result); + return result; + } + + /** + * Do all action in specified order step (first 0). + * + * @param step do action only defined in this step + * + * @throws IllegalAccessException if action invocation failed + * @throws IllegalArgumentException if action invocation failed + * @throws InvocationTargetException if action invocation failed + * @throws InstantiationException if action invocation failed + * + * @see Action.Step + * @since 2.4 + */ + public void doAllAction() throws IllegalAccessException, + IllegalArgumentException, + InvocationTargetException, + InstantiationException { + for (int step : getActionStep()) { + doAction(step); + } + } + + /** * Do action in specified step. * * @param step do action only defined in this step