FELIX-2124 Apply patch by Valentin Valchev (thanks).

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@918435 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/SetStartLevelAction.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/SetStartLevelAction.java
deleted file mode 100644
index d8046ae..0000000
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/SetStartLevelAction.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.webconsole.internal.core;
-
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.felix.webconsole.Action;
-import org.apache.felix.webconsole.WebConsoleUtil;
-import org.apache.felix.webconsole.internal.BaseManagementPlugin;
-import org.osgi.service.startlevel.StartLevel;
-
-
-/**
- * The <code>SetStartLevelAction</code> TODO
- */
-public class SetStartLevelAction extends BaseManagementPlugin implements Action
-{
-
-    public static final String NAME = "setStartLevel";
-
-    public static final String LABEL = "Set Start Level";
-
-
-    public String getName()
-    {
-        return NAME;
-    }
-
-
-    public String getLabel()
-    {
-        return LABEL;
-    }
-
-
-    public boolean performAction( HttpServletRequest request, HttpServletResponse response )
-    {
-
-        StartLevel sl = getStartLevel();
-        if ( sl != null )
-        {
-            int bundleSL = WebConsoleUtil.getParameterInt( request, "bundleStartLevel", -1 );
-            if ( bundleSL > 0 && bundleSL != sl.getInitialBundleStartLevel() )
-            {
-                sl.setInitialBundleStartLevel( bundleSL );
-            }
-
-            int systemSL = WebConsoleUtil.getParameterInt( request, "systemStartLevel", -1 );
-            if ( systemSL > 0 && systemSL != sl.getStartLevel() )
-            {
-                sl.setStartLevel( systemSL );
-            }
-        }
-
-        return true;
-    }
-
-
-}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
index 570694a..1196773 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
@@ -133,13 +133,11 @@
             "org.apache.felix.webconsole.internal.core.BundlesServlet",
             "org.apache.felix.webconsole.internal.core.ServicesServlet",
             "org.apache.felix.webconsole.internal.core.InstallAction",
-            "org.apache.felix.webconsole.internal.core.SetStartLevelAction",
             "org.apache.felix.webconsole.internal.deppack.DepPackServlet",
             "org.apache.felix.webconsole.internal.misc.LicenseServlet",
             "org.apache.felix.webconsole.internal.misc.ConfigurationRender",
             "org.apache.felix.webconsole.internal.misc.ShellServlet",
             "org.apache.felix.webconsole.internal.obr.BundleRepositoryRender",
-            "org.apache.felix.webconsole.internal.system.GCAction",
             "org.apache.felix.webconsole.internal.system.VMStatPlugin"
         };
 
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/GCAction.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/GCAction.java
deleted file mode 100644
index 29effb0..0000000
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/GCAction.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.felix.webconsole.internal.system;
-
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.felix.webconsole.Action;
-
-
-public class GCAction implements Action
-{
-
-    public static final String NAME = "gc";
-    public static final String LABEL = "Collect Garbage";
-
-
-    public String getName()
-    {
-        return NAME;
-    }
-
-
-    public String getLabel()
-    {
-        return LABEL;
-    }
-
-
-    public boolean performAction( HttpServletRequest request, HttpServletResponse response )
-    {
-        System.gc();
-        return true;
-    }
-
-}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
index edf69be..04a9428 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
@@ -84,7 +84,32 @@
     protected void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException,
         IOException
     {
-        if ( request.getParameter( PARAM_SHUTDOWN_TIMER ) == null )
+        final String action = request.getParameter( "action");
+
+        if ( "setStartLevel".equals( action ))
+        {
+            StartLevel sl = getStartLevel();
+            if ( sl != null )
+            {
+                int bundleSL = WebConsoleUtil.getParameterInt( request, "bundleStartLevel", -1 );
+                if ( bundleSL > 0 && bundleSL != sl.getInitialBundleStartLevel() )
+                {
+                    sl.setInitialBundleStartLevel( bundleSL );
+                }
+
+                int systemSL = WebConsoleUtil.getParameterInt( request, "systemStartLevel", -1 );
+                if ( systemSL > 0 && systemSL != sl.getStartLevel() )
+                {
+                    sl.setStartLevel( systemSL );
+                }
+            }
+        }
+        else if ( "gc".equals( action ) )
+        {
+            System.gc();
+            System.gc(); // twice for sure
+        }
+        else if ( request.getParameter( PARAM_SHUTDOWN_TIMER ) == null )        
         {
 
             // whether to stop or restart the framework