felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1688820 - /felix/trunk/webconsole-plugins/subsystems/src/main/java/org/apache/felix/webconsole/plugins/subsystem/internal/WebConsolePlugin.java
Date Thu, 02 Jul 2015 13:10:32 GMT
Author: davidb
Date: Thu Jul  2 13:10:31 2015
New Revision: 1688820

URL: http://svn.apache.org/r1688820
Log:
FELIX-4947 Webconsole plugin for OSGi Subsystems

Honour the 'start' option when installing a new subsystem.

Modified:
    felix/trunk/webconsole-plugins/subsystems/src/main/java/org/apache/felix/webconsole/plugins/subsystem/internal/WebConsolePlugin.java

Modified: felix/trunk/webconsole-plugins/subsystems/src/main/java/org/apache/felix/webconsole/plugins/subsystem/internal/WebConsolePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/subsystems/src/main/java/org/apache/felix/webconsole/plugins/subsystem/internal/WebConsolePlugin.java?rev=1688820&r1=1688819&r2=1688820&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/subsystems/src/main/java/org/apache/felix/webconsole/plugins/subsystem/internal/WebConsolePlugin.java
(original)
+++ felix/trunk/webconsole-plugins/subsystems/src/main/java/org/apache/felix/webconsole/plugins/subsystem/internal/WebConsolePlugin.java
Thu Jul  2 13:10:31 2015
@@ -146,6 +146,7 @@ public class WebConsolePlugin extends Si
         @SuppressWarnings("rawtypes")
         Map params = (Map) req.getAttribute( AbstractWebConsolePlugin.ATTR_FILEUPLOAD );
 
+        final boolean start = getParameter(params, "subsystemstart") != null;
         FileItem[] subsystemItems = getFileItems(params, "subsystemfile");
 
         for (final FileItem subsystemItem : subsystemItems)
@@ -187,7 +188,9 @@ public class WebConsolePlugin extends Si
                             InputStream is = new FileInputStream(file);
                             try
                             {
-                                ss.install("inputstream:" + subsystemItem.getName(), is);
+                                Subsystem nss = ss.install("inputstream:" + subsystemItem.getName(),
is);
+                                if (start)
+                                    nss.start();
                             }
                             finally
                             {
@@ -277,13 +280,32 @@ public class WebConsolePlugin extends Si
     }
 
     @SuppressWarnings("rawtypes")
+    private FileItem getParameter(Map params, String name)
+    {
+        FileItem[] items = (FileItem[]) params.get(name);
+        if (items != null)
+        {
+            for (int i = 0; i < items.length; i++)
+            {
+                if (items[i].isFormField())
+                {
+                    return items[i];
+                }
+            }
+        }
+
+        // nothing found, fail
+        return null;
+    }
+
+    @SuppressWarnings("rawtypes")
     private FileItem[] getFileItems(Map params, String name)
     {
         final List<FileItem> files = new ArrayList<FileItem>();
-        FileItem[] items = (FileItem[]) params.get( name );
-        if ( items != null )
+        FileItem[] items = (FileItem[]) params.get(name);
+        if (items != null)
         {
-            for ( int i = 0; i < items.length; i++ )
+            for (int i = 0; i < items.length; i++)
             {
                 if (!items[i].isFormField() && items[i].getSize() > 0)
                 {
@@ -292,7 +314,7 @@ public class WebConsolePlugin extends Si
             }
         }
 
-        return files.toArray( new FileItem[files.size()] );
+        return files.toArray(new FileItem[files.size()]);
     }
 
     @Override



Mime
View raw message