incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r713998 - in /incubator/sling/trunk/extensions/runmode: pom.xml src/main/java/org/apache/sling/runmode/impl/RunModeCommand.java src/main/java/org/apache/sling/runmode/impl/RunModePanel.java
Date Fri, 14 Nov 2008 13:31:58 GMT
Author: fmeschbe
Date: Fri Nov 14 05:31:57 2008
New Revision: 713998

URL: http://svn.apache.org/viewvc?rev=713998&view=rev
Log:
SLING-732 Add Felix Shell and Web Console integration

Added:
    incubator/sling/trunk/extensions/runmode/src/main/java/org/apache/sling/runmode/impl/RunModeCommand.java
    incubator/sling/trunk/extensions/runmode/src/main/java/org/apache/sling/runmode/impl/RunModePanel.java
Modified:
    incubator/sling/trunk/extensions/runmode/pom.xml

Modified: incubator/sling/trunk/extensions/runmode/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/runmode/pom.xml?rev=713998&r1=713997&r2=713998&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/runmode/pom.xml (original)
+++ incubator/sling/trunk/extensions/runmode/pom.xml Fri Nov 14 05:31:57 2008
@@ -19,69 +19,101 @@
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.apache.sling</groupId>
-    <artifactId>sling</artifactId>
-    <version>4-incubator-SNAPSHOT</version>
-    <relativePath> ../../sling/parent/</relativePath>
-  </parent>
-
-  <artifactId>org.apache.sling.runmode</artifactId>
-  <version>2.0.3-incubator-SNAPSHOT</version>
-  <packaging>bundle</packaging>
-
-  <name>Sling - RunMode service</name>
-  <description> 
-    Used to enable/disable sets of components
-    based on a list of "run mode" strings.
-  </description>
-  
-  <scm>
-    <connection> scm:svn:http://svn.apache.org/repos/asf/incubator/sling/whiteboard/runmode</connection>
-    <developerConnection> scm:svn:https://svn.apache.org/repos/asf/incubator/sling/whiteboard/runmode</developerConnection>
-    <url> http://svn.apache.org/viewvc/incubator/sling/whiteboard/runmode</url>
-  </scm>
-  
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-scr-plugin</artifactId>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Export-Package>
-              org.apache.sling.runmode,
-              !org.apache.sling.runmode.impl
-            </Export-Package>
-            <Private-Package>org.apache.sling.runmode.impl.*</Private-Package>
-          </instructions>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-  
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.felix</groupId>
-      <artifactId>org.osgi.core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.felix</groupId>
-      <artifactId>org.osgi.compendium</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-simple</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-    </dependency>
-  </dependencies>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>4-incubator-SNAPSHOT</version>
+        <relativePath>../../sling/parent/</relativePath>
+    </parent>
+
+    <artifactId>org.apache.sling.runmode</artifactId>
+    <version>2.0.3-incubator-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <name>Sling - RunMode service</name>
+    <description>
+        Used to enable/disable sets of components based on a list of
+        "run mode" strings.
+    </description>
+
+    <scm>
+        <connection>
+            scm:svn:http://svn.apache.org/repos/asf/incubator/sling/whiteboard/runmode
+        </connection>
+        <developerConnection>
+            scm:svn:https://svn.apache.org/repos/asf/incubator/sling/whiteboard/runmode
+        </developerConnection>
+        <url>
+            http://svn.apache.org/viewvc/incubator/sling/whiteboard/runmode
+        </url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Export-Package>
+                            org.apache.sling.runmode,
+                            !org.apache.sling.runmode.impl
+                        </Export-Package>
+                        <Private-Package>
+                            org.apache.sling.runmode.impl.*
+                        </Private-Package>
+                        <Import-Package>
+                            javax.servlet.*;
+                            org.apache.felix.shell;
+                            org.apache.felix.webconsole;
+                            resolution:=optional, *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+        </dependency>
+
+        <!-- Shell and WebConsole integration -->
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.shell</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.webconsole</artifactId>
+            <version>1.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
 </project>

Added: incubator/sling/trunk/extensions/runmode/src/main/java/org/apache/sling/runmode/impl/RunModeCommand.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/runmode/src/main/java/org/apache/sling/runmode/impl/RunModeCommand.java?rev=713998&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/runmode/src/main/java/org/apache/sling/runmode/impl/RunModeCommand.java
(added)
+++ incubator/sling/trunk/extensions/runmode/src/main/java/org/apache/sling/runmode/impl/RunModeCommand.java
Fri Nov 14 05:31:57 2008
@@ -0,0 +1,57 @@
+/*
+ * $Url: $
+ * $Id: $
+ *
+ * Copyright 1997-2005 Day Management AG
+ * Barfuesserplatz 6, 4001 Basel, Switzerland
+ * All Rights Reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * Day Management AG, ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with Day.
+ */
+package org.apache.sling.runmode.impl;
+
+import java.io.PrintStream;
+import java.util.Arrays;
+
+import org.apache.felix.shell.Command;
+import org.apache.sling.runmode.RunMode;
+
+/**
+ * @scr.component metatype="no"
+ * @scr.service
+ */
+public class RunModeCommand implements Command {
+
+    private static final String CMD_NAME = "runmodes";
+
+    /** @scr.reference */
+    private RunMode runMode;
+
+    public String getName() {
+        return CMD_NAME;
+    }
+
+    public String getShortDescription() {
+        return "lists current run modes";
+    }
+
+    public String getUsage() {
+        return CMD_NAME;
+    }
+
+    public void execute(String command, PrintStream out, PrintStream err) {
+
+        out.print("Current Run Modes: ");
+
+        String[] modes = runMode.getCurrentRunModes();
+        if (modes == null || modes.length == 0) {
+            out.println("-");
+        } else {
+            out.println(Arrays.asList(runMode.getCurrentRunModes()));
+        }
+    }
+}

Added: incubator/sling/trunk/extensions/runmode/src/main/java/org/apache/sling/runmode/impl/RunModePanel.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/runmode/src/main/java/org/apache/sling/runmode/impl/RunModePanel.java?rev=713998&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/runmode/src/main/java/org/apache/sling/runmode/impl/RunModePanel.java
(added)
+++ incubator/sling/trunk/extensions/runmode/src/main/java/org/apache/sling/runmode/impl/RunModePanel.java
Fri Nov 14 05:31:57 2008
@@ -0,0 +1,113 @@
+/*
+ * $Url: $
+ * $Id: $
+ *
+ * Copyright 1997-2005 Day Management AG
+ * Barfuesserplatz 6, 4001 Basel, Switzerland
+ * All Rights Reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * Day Management AG, ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with Day.
+ */
+package org.apache.sling.runmode.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+
+import javax.servlet.Servlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.felix.webconsole.AbstractWebConsolePlugin;
+import org.apache.felix.webconsole.ConfigurationPrinter;
+import org.apache.sling.runmode.RunMode;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * @scr.component metatype="no"
+ * @scr.service
+ * @scr.property name="felix.webconsole.label" valueRef="LABEL"
+ */
+public class RunModePanel extends AbstractWebConsolePlugin implements Servlet,
+        ConfigurationPrinter {
+
+    private static final String LABEL = "runmodes";
+
+    private static final String TITLE = "Run Modes";
+
+    /** @scr.reference */
+    private RunMode runMode;
+
+    // ---------- AbstractWebConsolePlugin API
+
+    @Override
+    public String getLabel() {
+        return LABEL;
+    }
+
+    @Override
+    public String getTitle() {
+        return TITLE;
+    }
+
+    @Override
+    protected void renderContent(HttpServletRequest request,
+            HttpServletResponse response) throws IOException {
+        PrintWriter pw = response.getWriter();
+
+        pw.println("<pre>");
+        pw.println("</pre>");
+
+        pw.println("<table class='content' cellpadding='0' cellspacing='0' width='100%'>");
+
+        pw.println("<tr class='content'>");
+        pw.println("<th class='content container' colspan='2'>" + getTitle()
+            + "</th>");
+        pw.println("</tr>");
+
+        pw.println("<tr class='content'>");
+        pw.println("<td class='content'>Current Run Modes</td>");
+        pw.println("<td class='content'>");
+
+        String[] modes = runMode.getCurrentRunModes();
+        if (modes == null || modes.length == 0) {
+            pw.println("-");
+        } else {
+            for (String mode : modes) {
+                pw.print(mode);
+                pw.println("<br>");
+            }
+        }
+
+        pw.println("</td>");
+        pw.println("</tr>");
+        pw.println("</table>");
+    }
+
+    // ---------- ConfigurationPrinter
+
+    public void printConfiguration(PrintWriter pw) {
+        pw.print("Current Run Modes: ");
+
+        String[] modes = runMode.getCurrentRunModes();
+        if (modes == null || modes.length == 0) {
+            pw.println("-");
+        } else {
+            pw.println(Arrays.asList(runMode.getCurrentRunModes()));
+        }
+    }
+
+    // ---------- SCR integration
+
+    protected void activate(ComponentContext context) {
+        activate(context.getBundleContext());
+    }
+
+    protected void deactivate(ComponentContext context) {
+        deactivate();
+    }
+}



Mime
View raw message