sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r912596 - in /sling/trunk/bundles/scripting/core: pom.xml src/main/java/org/apache/sling/scripting/core/impl/ScriptEngineConsolePlugin.java
Date Mon, 22 Feb 2010 14:51:25 GMT
Author: cziegeler
Date: Mon Feb 22 14:51:25 2010
New Revision: 912596

URL: http://svn.apache.org/viewvc?rev=912596&view=rev
Log:
SLING-1388 : Web Console Plugin should be a configuration printer

Modified:
    sling/trunk/bundles/scripting/core/pom.xml
    sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptEngineConsolePlugin.java

Modified: sling/trunk/bundles/scripting/core/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/core/pom.xml?rev=912596&r1=912595&r2=912596&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/core/pom.xml (original)
+++ sling/trunk/bundles/scripting/core/pom.xml Mon Feb 22 14:51:25 2010
@@ -106,7 +106,13 @@
             <version>2.1.0</version>
             <scope>provided</scope>
         </dependency>
-
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.webconsole</artifactId>
+            <version>2.0.6</version>
+            <scope>provided</scope>
+        </dependency>
+        
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>

Modified: sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptEngineConsolePlugin.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptEngineConsolePlugin.java?rev=912596&r1=912595&r2=912596&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptEngineConsolePlugin.java
(original)
+++ sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/ScriptEngineConsolePlugin.java
Mon Feb 22 14:51:25 2010
@@ -18,7 +18,6 @@
  */
 package org.apache.sling.scripting.core.impl;
 
-import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Dictionary;
 import java.util.Hashtable;
@@ -27,17 +26,13 @@
 
 import javax.script.ScriptEngineFactory;
 import javax.script.ScriptEngineManager;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
+import org.apache.felix.webconsole.ConfigurationPrinter;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
 
-public class ScriptEngineConsolePlugin extends HttpServlet {
-
-    private static final String LABEL = "scriptengines";
+public class ScriptEngineConsolePlugin implements ConfigurationPrinter {
 
     // --------- setup and shutdown
 
@@ -73,64 +68,39 @@
         this.scriptAdapterFactory = scriptAdapterFactory;
     }
 
-    @Override
-    protected void service(HttpServletRequest req, HttpServletResponse res)
-            throws IOException {
-        PrintWriter pw = res.getWriter();
+    public String getTitle() {
+        return "Script Engines";
+    }
 
-        pw.println("<table class='content' cellpadding='0' cellspacing='0' width='100%'>");
+    public void printConfiguration(final PrintWriter pw) {
+        pw.println("Available Script Engines");
+        pw.println("========================");
 
         ScriptEngineManager manager = scriptAdapterFactory.getScriptEngineManager();
         List<?> factories = manager.getEngineFactories();
         for (Iterator<?> fi = factories.iterator(); fi.hasNext();) {
 
-            ScriptEngineFactory factory = (ScriptEngineFactory) fi.next();
+            final ScriptEngineFactory factory = (ScriptEngineFactory) fi.next();
 
-            pw.println("<tr class='content'>");
-            pw.println("<th colspan='3'class='content container'>");
+            pw.println();
             pw.print(factory.getEngineName());
-            pw.print(", ");
+            pw.print(" ");
             pw.println(factory.getEngineVersion());
-            pw.println("</th>");
-            pw.println("</tr>");
-
-            pw.println("<tr class='content'>");
-            pw.println("<td class='content'>&nbsp;</td>");
-            pw.println("<td class='content'>Language</td>");
-            pw.println("<td class='content'>");
+            pw.println("-------------------------------------");
+            pw.print("- Language : ");
             pw.print(factory.getLanguageName());
             pw.print(", ");
             pw.println(factory.getLanguageVersion());
-            pw.println("</td>");
-            pw.println("</tr>");
 
-            pw.println("<tr class='content'>");
-            pw.println("<td class='content'>&nbsp;</td>");
-            pw.println("<td class='content'>Extensions</td>");
-            pw.println("<td class='content'>");
+            pw.print("- Extensions : ");
             printArray(pw, factory.getExtensions());
-            pw.println("</td>");
-            pw.println("</tr>");
 
-            pw.println("<tr class='content'>");
-            pw.println("<td class='content'>&nbsp;</td>");
-            pw.println("<td class='content'>MIME Types</td>");
-            pw.println("<td class='content'>");
+            pw.print("- MIME Types : ");
             printArray(pw, factory.getMimeTypes());
-            pw.println("</td>");
-            pw.println("</tr>");
 
-            pw.println("<tr class='content'>");
-            pw.println("<td class='content'>&nbsp;</td>");
-            pw.println("<td class='content'>Names</td>");
-            pw.println("<td class='content'>");
+            pw.print("- Names : ");
             printArray(pw, factory.getNames());
-            pw.println("</td>");
-            pw.println("</tr>");
-
         }
-
-        pw.println("</table>");
     }
 
     private void printArray(PrintWriter pw, List<?> values) {
@@ -153,11 +123,9 @@
             "Web Console Plugin for ScriptEngine implementations");
         props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
         props.put(Constants.SERVICE_PID, getClass().getName());
-        props.put("felix.webconsole.label", LABEL);
-        props.put("felix.webconsole.title", "Script Engines");
 
         serviceRegistration = context.registerService(
-            "javax.servlet.Servlet", this, props);
+            ConfigurationPrinter.class.getName(), this, props);
     }
 
     public void deactivate() {



Mime
View raw message