FELIX-1722: gogo AbstractCommand should let the possibility to release the used Action

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@881284 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/commands/src/main/java/org/apache/felix/gogo/commands/basic/AbstractCommand.java b/gogo/commands/src/main/java/org/apache/felix/gogo/commands/basic/AbstractCommand.java
index 1c1fe04..1cf3a72 100644
--- a/gogo/commands/src/main/java/org/apache/felix/gogo/commands/basic/AbstractCommand.java
+++ b/gogo/commands/src/main/java/org/apache/felix/gogo/commands/basic/AbstractCommand.java
@@ -30,15 +30,29 @@
 
     public Object execute(CommandSession session, List<Object> arguments) throws Exception {
         Action action = createNewAction();
-        if (getPreparator().prepare(action, session, arguments)) {
-            return action.execute(session);
-        } else {
-            return null;
+        try {
+            if (getPreparator().prepare(action, session, arguments)) {
+                return action.execute(session);
+            } else {
+                return null;
+            }
+        } finally {
+        	releaseAction(action);
         }
     }
 
     protected abstract Action createNewAction() throws Exception;
 
+    /**
+     * Release the used Action.
+     * This method has to be overridden for pool based Actions.
+     * @param action Action that was executed
+     * @throws Exception if something went wrong during the Action release
+     */
+    protected void releaseAction(Action action) throws Exception {
+    	// Do nothing by default (stateful)
+    }
+
     protected ActionPreparator getPreparator() throws Exception {
         return new DefaultActionPreparator();
     }