You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2008/01/22 15:24:57 UTC

svn commit: r614204 [3/3] - in /incubator/sling/trunk/osgi/console-web: ./ src/main/java/org/apache/sling/osgi/console/web/ src/main/java/org/apache/sling/osgi/console/web/internal/ src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ s...

Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/GCAction.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/GCAction.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/GCAction.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/GCAction.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/GCAction.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/GCAction.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/GCAction.java Tue Jan 22 06:24:42 2008
@@ -14,19 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.system;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.sling.osgi.console.web.Action;
 
-/**
- * The <code>GCAction</code> TODO
- *
- * @scr.component metatype="false"
- * @scr.service
- */
 public class GCAction implements Action {
 
     public static final String NAME = "gc";
@@ -40,9 +34,6 @@
         return LABEL;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.sling.manager.web.internal.Action#performAction(javax.servlet.http.HttpServletRequest)
-     */
     public boolean performAction(HttpServletRequest request, HttpServletResponse response) {
         System.gc();
         return false;

Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/ShutdownAction.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ShutdownAction.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/ShutdownAction.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/ShutdownAction.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ShutdownAction.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ShutdownAction.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/ShutdownAction.java Tue Jan 22 06:24:42 2008
@@ -14,20 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.system;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.sling.osgi.console.web.Action;
+import org.apache.sling.osgi.console.web.internal.BaseManagementPlugin;
+import org.osgi.framework.BundleException;
+import org.osgi.service.log.LogService;
 
-/**
- * The <code>ShutdownAction</code> TODO
- *
- * @scr.component metatype="false"
- * @scr.service
- */
-public class ShutdownAction implements Action {
+public class ShutdownAction extends BaseManagementPlugin implements Action {
 
     public static final String NAME = "shutdown";
 
@@ -39,10 +36,8 @@
         return NAME;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.sling.manager.web.internal.internal.Action#performAction(javax.servlet.http.HttpServletRequest)
-     */
-    public boolean performAction(HttpServletRequest request, HttpServletResponse response) {
+    public boolean performAction(HttpServletRequest request,
+            HttpServletResponse response) {
         // simply terminate VM in case of shutdown :-)
         Thread t = new Thread("Stopper") {
             public void run() {
@@ -52,8 +47,15 @@
                     // ignore
                 }
 
-                // TODO: log("Shutting down server now!");
-                System.exit(0);
+                getLog().log(LogService.LOG_INFO, "Shutting down server now!");
+
+                // stopping bundle 0 (system bundle) stops the framework
+                try {
+                    getBundleContext().getBundle(0).stop();
+                } catch (BundleException be) {
+                    getLog().log(LogService.LOG_ERROR,
+                        "Problem stopping Framework", be);
+                }
             }
         };
         t.start();

Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/ShutdownRender.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ShutdownRender.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/ShutdownRender.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/ShutdownRender.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ShutdownRender.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ShutdownRender.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/ShutdownRender.java Tue Jan 22 06:24:42 2008
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.system;
 
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -24,36 +24,19 @@
 
 import org.apache.sling.osgi.console.web.Render;
 
-/**
- * The <code>ShutdownRender</code> TODO
- *
- * @scr.component metatype="false"
- * @scr.service
- */
 public class ShutdownRender implements Render {
 
     public static final String NAME = "shutdown";
     public static final String LABEL = null; // hide from navigation
 
-    /*
-     * (non-Javadoc)
-     * @see org.apache.sling.manager.web.internal.Render#getName()
-     */
     public String getName() {
         return NAME;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.apache.sling.manager.web.internal.Render#getLabel()
-     */
     public String getLabel() {
         return LABEL;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.sling.manager.web.internal.Render#render(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-     */
     public void render(HttpServletRequest request, HttpServletResponse response)
             throws IOException {
 

Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/VMStatRender.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/VMStatRender.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/VMStatRender.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/VMStatRender.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/VMStatRender.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/VMStatRender.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/VMStatRender.java Tue Jan 22 06:24:42 2008
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.system;
 
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -24,43 +24,26 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.sling.osgi.console.web.Render;
-import org.osgi.service.startlevel.StartLevel;
+import org.apache.sling.osgi.console.web.internal.BaseManagementPlugin;
+import org.apache.sling.osgi.console.web.internal.Util;
+import org.apache.sling.osgi.console.web.internal.core.SetStartLevelAction;
 
-/**
- * The <code>VMStatRender</code> TODO
- *
- * @scr.component metatype="false"
- * @scr.service
- */
-public class VMStatRender implements Render {
+public class VMStatRender extends BaseManagementPlugin implements Render {
 
     public static final String NAME = "vmstat";
+
     public static final String LABEL = "System Information";
 
     private static final long startDate = (new Date()).getTime();
 
-    /** @scr.reference */
-    private StartLevel startLevel;
-
-    /*
-     * (non-Javadoc)
-     * @see org.apache.sling.manager.web.internal.Render#getName()
-     */
     public String getName() {
         return NAME;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.apache.sling.manager.web.internal.Render#getLabel()
-     */
     public String getLabel() {
         return LABEL;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.sling.manager.web.internal.Render#render(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-     */
     public void render(HttpServletRequest request, HttpServletResponse response)
             throws IOException {
 
@@ -87,7 +70,8 @@
         pw.println("<form method='post'>");
         pw.println("<input type='hidden' name='" + Util.PARAM_ACTION
             + "' value='" + SetStartLevelAction.NAME + "'>");
-        pw.println("<input class='input' type='text' size='3' name='systemStartLevel' value='" + this.startLevel.getStartLevel() + "'/>");
+        pw.println("<input class='input' type='text' size='3' name='systemStartLevel' value='"
+            + getStartLevel().getStartLevel() + "'/>");
         pw.println("&nbsp;&nbsp;<input class='submit' type='submit' name='"
             + SetStartLevelAction.LABEL + "' value='Change'>");
         pw.println("</form>");
@@ -99,7 +83,8 @@
         pw.println("<form method='post'>");
         pw.println("<input type='hidden' name='" + Util.PARAM_ACTION
             + "' value='" + SetStartLevelAction.NAME + "'>");
-        pw.println("<input class='input' type='text' size='3' name='bundleStartLevel' value='" + this.startLevel.getInitialBundleStartLevel() + "'/>");
+        pw.println("<input class='input' type='text' size='3' name='bundleStartLevel' value='"
+            + getStartLevel().getInitialBundleStartLevel() + "'/>");
         pw.println("&nbsp;&nbsp;<input class='submit' type='submit' name='"
             + SetStartLevelAction.LABEL + "' value='Change'>");
         pw.println("</form>");
@@ -118,7 +103,8 @@
         pw.println("<td class='content'>Last Started</td>");
         pw.println("<td class='content'>");
         pw.println("<script language='JavaScript'>");
-        pw.println("localDate(" + startDate /* <%= Server.getStartTime() %> */ + ")");
+        pw.println("localDate(" + startDate /* <%= Server.getStartTime() %> */
+            + ")");
         pw.println("</script>");
         pw.println("</td>");
         pw.println("</tr>");
@@ -134,7 +120,8 @@
                 + "' value='" + Util.VALUE_SHUTDOWN + "'>");
             pw.println("<input class='submit important' type='submit' value='Stop' onclick=\"return confirm('This will terminate all running applications. Do you want to stop the server?')\">");
         } else {
-            pw.println("<input class='submit important' type='button' value='Abort' onclick=\"abort('" + request.getRequestURI() + "')\">&nbsp;");
+            pw.println("<input class='submit important' type='button' value='Abort' onclick=\"abort('"
+                + request.getRequestURI() + "')\">&nbsp;");
             pw.println("<input type='hidden' name='" + Util.PARAM_ACTION
                 + "' value='" + ShutdownAction.NAME + "'>");
             pw.println("Shutdown in <span id='countdowncell'>&nbsp;</span>");
@@ -182,13 +169,4 @@
         pw.println("</td></tr>");
     }
 
-    //--------- SCR Integration -----------------------------------------------
-
-    protected void bindStartLevel(StartLevel startLevel) {
-        this.startLevel = startLevel;
-    }
-
-    protected void unbindStartLevel(StartLevel startLevel) {
-        this.startLevel = null;
-    }
 }