karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r1478453 - in /karaf/branches/karaf-2.3.x/webconsole/gogo/src/main: java/org/apache/karaf/webconsole/gogo/ resources/OSGI-INF/blueprint/
Date Thu, 02 May 2013 17:16:35 GMT
Author: jbonofre
Date: Thu May  2 17:16:34 2013
New Revision: 1478453

URL: http://svn.apache.org/r1478453
Log:
[KARAF-2285] Fixed Gogo WebConsole plugin for Equinox

Modified:
    karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/GogoPlugin.java
    karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java
    karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/WebTerminal.java
    karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/resources/OSGI-INF/blueprint/webconsole-gogo.xml

Modified: karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/GogoPlugin.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/GogoPlugin.java?rev=1478453&r1=1478452&r2=1478453&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/GogoPlugin.java
(original)
+++ karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/GogoPlugin.java
Thu May  2 17:16:34 2013
@@ -19,7 +19,6 @@
  * Based on http://antony.lesuisse.org/software/ajaxterm/
  *  Public Domain License
  */
-
 package org.apache.karaf.webconsole.gogo;
 
 import java.io.ByteArrayInputStream;
@@ -47,86 +46,67 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * The <code>GogoPlugin</code>
+ * WebConsole plugin for Gogo shell.
  */
 public class GogoPlugin extends AbstractWebConsolePlugin {
 
-    /** Pseudo class version ID to keep the IDE quite. */
-    private static final long serialVersionUID = 1L;
-
     private final Logger logger = LoggerFactory.getLogger(GogoPlugin.class);
 
     public static final String NAME = "gogo";
-
     public static final String LABEL = "Gogo";
-
     public static final int TERM_WIDTH = 120;
     public static final int TERM_HEIGHT = 39;
 
-
-
     private BundleContext bundleContext;
-
     private CommandProcessor commandProcessor;
 
-    public void setBundleContext(BundleContext bundleContext)
-    {
+    public void setBundleContext(BundleContext bundleContext) {
         this.bundleContext = bundleContext;
     }
 
-    public void setCommandProcessor(CommandProcessor commandProcessor)
-    {
+    public void setCommandProcessor(CommandProcessor commandProcessor) {
         this.commandProcessor = commandProcessor;
     }
 
-    /*
-    * Blueprint lifecycle callback methods
-    */
-
-    public void start()
-    {
-        super.activate( bundleContext );
-        this.logger.info( LABEL + " plugin activated" );
+    public void start() {
+        super.activate(bundleContext);
+        this.logger.info(LABEL + " plugin activated");
     }
 
-    public void stop()
-    {
-        this.logger.info( LABEL + " plugin deactivated" );
+    public void stop() {
+        this.logger.info(LABEL + " plugin deactivated");
         super.deactivate();
     }
 
-    //
-    // AbstractWebConsolePlugin interface
-    //
-    public String getLabel()
-    {
+    @Override
+    public String getLabel() {
         return NAME;
     }
 
-
-    public String getTitle()
-    {
+    @Override
+    public String getTitle() {
         return LABEL;
     }
 
-
-    protected void renderContent( HttpServletRequest request, HttpServletResponse response
) throws IOException
-    {
+    @Override
+    protected void renderContent(HttpServletRequest request, HttpServletResponse response)
throws IOException {
         PrintWriter pw = response.getWriter();
 
         String appRoot = request.getContextPath() + request.getServletPath();
-        pw.println( "<link href=\"" + appRoot + "/gogo/res/ui/gogo.css\" rel=\"stylesheet\"
type=\"text/css\" />" );
-        pw.println( "<script src=\"" + appRoot + "/gogo/res/ui/gogo.js\" type=\"text/javascript\"></script>"
);
-        pw.println( "<div id='console'><div id='term'></div></div>"
);
-        pw.println( "<script type=\"text/javascript\"><!--" );
-        pw.println( "window.onload = function() { gogo.Terminal(document.getElementById(\"term\"),
" + TERM_WIDTH + ", " + TERM_HEIGHT + "); }" );
-        pw.println( "--></script>" );
+        pw.println("<link href=\"" + appRoot + "/gogo/res/ui/gogo.css\" rel=\"stylesheet\"
type=\"text/css\" />");
+        pw.println("<script src=\"" + appRoot + "/gogo/res/ui/gogo.js\" type=\"text/javascript\"></script>");
+        pw.println("<div id='console'><div id='term'></div></div>");
+        pw.println("<script type=\"text/javascript\"><!--");
+        pw.println("window.onload = function() { gogo.Terminal(document.getElementById(\"term\"),
" + TERM_WIDTH + ", " + TERM_HEIGHT + "); }");
+        pw.println("--></script>");
     }
 
-    protected URL getResource( String path )
-    {
-        path = path.substring( NAME.length() + 1 );
-        URL url = this.getClass().getClassLoader().getResource( path );
+    protected URL getResource(String path) {
+        path = path.substring(NAME.length() + 1);
+        if (path == null || path.isEmpty()) {
+            return null;
+        }
+        URL url = this.getClass().getClassLoader().getResource(path);
         if (url != null) {
             InputStream ins = null;
             try {
@@ -168,7 +148,7 @@ public class GogoPlugin extends Abstract
                 response.setHeader("Content-Encoding", "gzip");
                 response.setHeader("Content-Type", "text/html");
                 try {
-                    GZIPOutputStream gzos =  new GZIPOutputStream(response.getOutputStream());
+                    GZIPOutputStream gzos = new GZIPOutputStream(response.getOutputStream());
                     gzos.write(dump.getBytes());
                     gzos.close();
                 } catch (IOException ie) {
@@ -181,7 +161,6 @@ public class GogoPlugin extends Abstract
         }
     }
 
-
     public class SessionTerminal implements Runnable {
 
         private Terminal terminal;
@@ -200,12 +179,12 @@ public class GogoPlugin extends Abstract
                 PrintStream pipedOut = new PrintStream(new PipedOutputStream(out), true);
 
                 console = new Console(commandProcessor,
-                                      new PipedInputStream(in),
-                                      pipedOut,
-                                      pipedOut,
-                                      new WebTerminal(TERM_WIDTH, TERM_HEIGHT),
-                                      null,
-                                      null);
+                        new PipedInputStream(in),
+                        pipedOut,
+                        pipedOut,
+                        new WebTerminal(TERM_WIDTH, TERM_HEIGHT),
+                        null,
+                        null);
                 CommandSession session = console.getSession();
                 session.put("APPLICATION", System.getProperty("karaf.name", "root"));
                 session.put("USER", "karaf");
@@ -248,12 +227,12 @@ public class GogoPlugin extends Abstract
 
         public void run() {
             try {
-                for (;;) {
+                for (; ; ) {
                     byte[] buf = new byte[8192];
                     int l = out.read(buf);
                     InputStreamReader r = new InputStreamReader(new ByteArrayInputStream(buf,
0, l));
                     StringBuilder sb = new StringBuilder();
-                    for (;;) {
+                    for (; ; ) {
                         int c = r.read();
                         if (c == -1) {
                             break;
@@ -277,4 +256,5 @@ public class GogoPlugin extends Abstract
         }
 
     }
+
 }

Modified: karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java?rev=1478453&r1=1478452&r2=1478453&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java
(original)
+++ karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java
Thu May  2 17:16:34 2013
@@ -24,7 +24,6 @@
  * See http://www.ecma-international.org/publications/standards/Ecma-048.htm
  *       and http://vt100.net/docs/vt510-rm/
  */
-
 package org.apache.karaf.webconsole.gogo;
 
 import java.util.Arrays;

Modified: karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/WebTerminal.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/WebTerminal.java?rev=1478453&r1=1478452&r2=1478453&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/WebTerminal.java
(original)
+++ karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/WebTerminal.java
Thu May  2 17:16:34 2013
@@ -30,9 +30,11 @@ public class WebTerminal extends Termina
     }
 
     public void init() throws Exception {
+        // nothing to do
     }
 
     public void restore() throws Exception {
+        // nothing to do
     }
 
     public int getWidth() {

Modified: karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/resources/OSGI-INF/blueprint/webconsole-gogo.xml
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/resources/OSGI-INF/blueprint/webconsole-gogo.xml?rev=1478453&r1=1478452&r2=1478453&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/resources/OSGI-INF/blueprint/webconsole-gogo.xml
(original)
+++ karaf/branches/karaf-2.3.x/webconsole/gogo/src/main/resources/OSGI-INF/blueprint/webconsole-gogo.xml
Thu May  2 17:16:34 2013
@@ -25,7 +25,6 @@
         <property name="commandProcessor" ref="commandProcessor" />
         <property name="bundleContext" ref="blueprintBundleContext" />
     </bean>
-
     <service ref="gogoPlugin" interface="javax.servlet.Servlet" >
         <service-properties>
             <entry key="felix.webconsole.label" value="gogo"/>



Mime
View raw message