You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by do...@apache.org on 2007/05/09 23:22:59 UTC
svn commit: r536658 - in /felix/sandbox/donsez/http.webadmin: ./ doc/
src/main/java/org/apache/felix/http/util/
src/main/java/org/apache/felix/http/webadmin/ src/main/resources/OSGI-INF/
src/main/resources/webroot/
Author: donsez
Date: Wed May 9 14:22:58 2007
New Revision: 536658
URL: http://svn.apache.org/viewvc?view=rev&rev=536658
Log:
add docs
add a todo list
add license banners in java files
implements doPostXML() method
add startlevel
Added:
felix/sandbox/donsez/http.webadmin/doc/README.txt (with props)
felix/sandbox/donsez/http.webadmin/doc/TODOLIST.txt (with props)
felix/sandbox/donsez/http.webadmin/src/main/resources/webroot/bundles2html.xsl (with props)
Modified:
felix/sandbox/donsez/http.webadmin/doc/url.txt
felix/sandbox/donsez/http.webadmin/pom.xml
felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/util/GenericHttpContext.java
felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/util/MIMETypeUtil.java
felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/webadmin/WebAdmin.java
felix/sandbox/donsez/http.webadmin/src/main/resources/OSGI-INF/component.xml
Added: felix/sandbox/donsez/http.webadmin/doc/README.txt
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/http.webadmin/doc/README.txt?view=auto&rev=536658
==============================================================================
--- felix/sandbox/donsez/http.webadmin/doc/README.txt (added)
+++ felix/sandbox/donsez/http.webadmin/doc/README.txt Wed May 9 14:22:58 2007
@@ -0,0 +1,17 @@
+http.webadmin
+-------------
+
+Author: Apache Felix Team
+
+This bundle provides a web-based GUI to manage an OSGi platform (thru HTTP).
+
+1) Start a HTTP Service
+2) Start http.webadmin (requires the scr)
+3) Try those URLs in your web browser !
+
+http://localhost:8080/admin/bundles
+http://localhost:8080/admin/index.html
+http://localhost:8080/admin/bundles?mimetype=text/javascript
+http://localhost:8080/admin/bundles?mimetype=text/xml
+
+Check the org.osgi.service.http.port=8080 in the felix/conf/config.properties
Propchange: felix/sandbox/donsez/http.webadmin/doc/README.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: felix/sandbox/donsez/http.webadmin/doc/TODOLIST.txt
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/http.webadmin/doc/TODOLIST.txt?view=auto&rev=536658
==============================================================================
--- felix/sandbox/donsez/http.webadmin/doc/TODOLIST.txt (added)
+++ felix/sandbox/donsez/http.webadmin/doc/TODOLIST.txt Wed May 9 14:22:58 2007
@@ -0,0 +1,9 @@
+http.webadmin TODOLIST
+----------------------
+
+* AJAX version (see src/main/resources/webroot/index.html)
+* add OBR panel
+* add Script panel
+* add Shell panel
+* implements action=info
+* add level control (~ commands startlevel, bundlelevel, ...)
Propchange: felix/sandbox/donsez/http.webadmin/doc/TODOLIST.txt
------------------------------------------------------------------------------
svn:eol-style = native
Modified: felix/sandbox/donsez/http.webadmin/doc/url.txt
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/http.webadmin/doc/url.txt?view=diff&rev=536658&r1=536657&r2=536658
==============================================================================
--- felix/sandbox/donsez/http.webadmin/doc/url.txt (original)
+++ felix/sandbox/donsez/http.webadmin/doc/url.txt Wed May 9 14:22:58 2007
@@ -1,9 +0,0 @@
-Try those URLs in your web browser !
-
-http://localhost:8080/admin/bundles
-
-http://localhost:8080/admin/index.html
-http://localhost:8080/admin/bundles?mimetype=text/javascript
-The 2 last ones do not work fine with IE
-
-
Modified: felix/sandbox/donsez/http.webadmin/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/http.webadmin/pom.xml?view=diff&rev=536658&r1=536657&r2=536658
==============================================================================
--- felix/sandbox/donsez/http.webadmin/pom.xml (original)
+++ felix/sandbox/donsez/http.webadmin/pom.xml Wed May 9 14:22:58 2007
@@ -17,35 +17,35 @@
under the License.
-->
<project>
-
+
<properties>
<repositoryLocation>http://www-adele.imag.fr/users/Didier.Donsez/dev/felix/sandbox/</repositoryLocation>
- <description>provides a HTML GUI to manage the framework.</description>
- </properties>
-
- <parent>
- <groupId>org.apache.felix</groupId>
- <artifactId>felix</artifactId>
- <version>0.9.0-incubator-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>Apache Felix WebAdmin</name>
- <artifactId>org.apache.felix.http.webadmin</artifactId>
- <description>${description}</description>
- <dependencies>
-
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>${pom.version}</version>
- </dependency>
+ <description>provides a HTML GUI to manage remotely the framework.</description>
+ </properties>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>${pom.version}</version>
- </dependency>
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>felix</artifactId>
+ <version>0.9.0-incubator-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>bundle</packaging>
+ <name>Apache Felix WebAdmin</name>
+ <artifactId>org.apache.felix.http.webadmin</artifactId>
+ <description>${description}</description>
+ <dependencies>
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
<!--
<dependency>
@@ -61,48 +61,47 @@
<scope>provided</scope>
</dependency>
-->
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>javax.servlet</artifactId>
- <version>${pom.version}</version>
- <scope>provided</scope>
- </dependency>
-
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>javax.servlet</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
-
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
+
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
<!-- docs in http://cwiki.apache.org/FELIX/bundle-plugin-for-maven-bnd.html and http://cwiki.apache.org/FELIX/osgi-plugin-for-maven-2.html -->
-
- <Private-Package>org.apache.felix.http.*</Private-Package>
- <Import-Package>*</Import-Package>
-
-
- <Import-Service>org.osgi.service.http.HttpService</Import-Service>
-
- <Service-Component>OSGI-INF/component.xml</Service-Component>
-
- <Bundle-DocURL>${repositoryLocation}${pom.artifactId}/index.html</Bundle-DocURL>
- <Bundle-Url>${repositoryLocation}${pom.artifactId}/${pom.artifactId}-${pom.version}.jar</Bundle-Url>
- <Bundle-Source>${repositoryLocation}${pom.artifactId}/${pom.artifactId}-${pom.version}-src.jar</Bundle-Source>
-
- <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
- <Bundle-Description>${description}</Bundle-Description>
- <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor>
-
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
+
+ <Private-Package>org.apache.felix.http.*</Private-Package>
+ <Import-Package>*</Import-Package>
+
+ <Import-Service>org.osgi.service.http.HttpService</Import-Service>
+
+ <Service-Component>OSGI-INF/component.xml</Service-Component>
+
+ <Bundle-DocURL>${repositoryLocation}${pom.artifactId}/index.html</Bundle-DocURL>
+ <Bundle-Url>${repositoryLocation}${pom.artifactId}/${pom.artifactId}-${pom.version}.jar</Bundle-Url>
+ <Bundle-Source>${repositoryLocation}${pom.artifactId}/${pom.artifactId}-${pom.version}-src.jar</Bundle-Source>
+
+ <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+ <Bundle-Description>${description}</Bundle-Description>
+ <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor>
+
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
<!--
<repositories>
<repository>
Modified: felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/util/GenericHttpContext.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/util/GenericHttpContext.java?view=diff&rev=536658&r1=536657&r2=536658
==============================================================================
--- felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/util/GenericHttpContext.java (original)
+++ felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/util/GenericHttpContext.java Wed May 9 14:22:58 2007
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.felix.http.util;
import java.io.InputStream;
@@ -12,7 +30,7 @@
/**
* provides a generic Http Context to register servlets and static docs
- * @author Didier Donsez
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class GenericHttpContext implements HttpContext {
Modified: felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/util/MIMETypeUtil.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/util/MIMETypeUtil.java?view=diff&rev=536658&r1=536657&r2=536658
==============================================================================
--- felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/util/MIMETypeUtil.java (original)
+++ felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/util/MIMETypeUtil.java Wed May 9 14:22:58 2007
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.felix.http.util;
import java.io.BufferedReader;
@@ -12,7 +30,7 @@
* TODO
* <p>For more information about MIME types
* please read RFC 2045, 2046, 2047, 2048, and 2077.
- * @author Didier Donsez
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*
*/
public class MIMETypeUtil {
Modified: felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/webadmin/WebAdmin.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/webadmin/WebAdmin.java?view=diff&rev=536658&r1=536657&r2=536658
==============================================================================
--- felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/webadmin/WebAdmin.java (original)
+++ felix/sandbox/donsez/http.webadmin/src/main/java/org/apache/felix/http/webadmin/WebAdmin.java Wed May 9 14:22:58 2007
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.felix.http.webadmin;
import java.io.IOException;
@@ -22,6 +40,7 @@
import org.osgi.service.http.HttpContext;
import org.osgi.service.http.HttpService;
import org.osgi.service.log.LogService;
+import org.osgi.service.startlevel.StartLevel;
/**
* Servlet to manage the framework. It is also a SCR component.
@@ -30,10 +49,10 @@
* <li>improve CSS default style</li>
* <li>add a info action displaying the bundle details (popup div, message div, ... ?)</li>
* <li>add a shell page</li>
+ * <li>add a script page</li>
* <li>add a obr page</li>
* </ul>
- * @author Didier Donsez
- *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class WebAdmin extends HttpServlet {
@@ -102,6 +121,16 @@
httpService=null;
}
+ // callback methods for <requires service="org.osgi.service.startlevel.StartLevel" ...
+ private StartLevel startLevel = null;
+
+ public void bindStartLevel(StartLevel ref){
+ startLevel=ref;
+ }
+
+ public void unbindStartLevel(StartLevel ref){
+ startLevel=null;
+ }
// callback methods for <requires service="org.osgi.service.log.LogService" ...
private LogService logService = null;
@@ -113,7 +142,7 @@
public void unbindLogService(LogService ref){
logService=null;
}
-
+
/**
* @param componentContext
*/
@@ -134,7 +163,7 @@
trace(this.toString()+": call desactivate()");
}
- /*
+ /**
* @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
*/
public void init(ServletConfig servletConfig){
@@ -151,7 +180,7 @@
}
}
- /*
+ /**
* @see javax.servlet.Servlet#destroy()
*/
public void destroy(){
@@ -270,9 +299,16 @@
pw.print(bundle.getLocation());
pw.println("\",");
+ if(startLevel!=null) {
+ pw.print("\"startlevel\":");
+ pw.print(startLevel.getBundleStartLevel(bundle));
+ pw.println(",");
+ }
+
pw.print("\"lastModified\":");
pw.print(bundle.getLastModified());
pw.println();
+
pw.println("}");
}
@@ -423,6 +459,12 @@
pw.println("</td>");
+
+ if(startLevel!=null) {
+ pw.println("<td class='startlevel'>");
+ pw.print(startLevel.getBundleStartLevel(bundle));
+ pw.println("</td>");
+ }
// Should be replaced by open-source icons (with alt)
pw.println("<td class='action'>");
@@ -563,13 +605,65 @@
response.setHeader("Cache-Control", "no-cache");
-// response.setContentType("text/xml");
- response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
-// PrintWriter pw = response.getWriter();
+ response.setContentType("text/xml");
+// response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
+ PrintWriter pw = response.getWriter();
+ pw.println("<?xml version='1.0' encoding='UTF-8' standalone='yes'?>");
// pw.println("<?xml version='1.0' encoding='UTF-8' standalone='yes|no'...?>");
-// pw.println("<!DOCTYPE rootelement PRIVATE ".." "http://../webadmin.dtd">");
-// pw.println("<bundles>");
-// pw.print("</bundles>");
+// pw.println("<!DOCTYPE rootelement PRIVATE ".." "http://../webadmin.dtd">");
+ if(xslt!=null) {
+ pw.println("<?xml-stylesheet type='text/xsl' href='"+xslt+"'?>");
+ }
+
+ pw.println("<bundles>");
+
+ Bundle[] bundles=bundleContext.getBundles();
+ for (int i = 0; i < bundles.length; i++) {
+ Bundle bundle = bundles[i];
+ pw.println("<bundle>");
+
+ long bid=bundle.getBundleId();
+ Dictionary headers=bundle.getHeaders();
+
+ pw.print("<id>");
+ pw.print(bid);
+ pw.println("</id>");
+
+ pw.print("<state>");
+ pw.print(bundle.getState());
+ pw.println("</state>");
+
+ pw.print("<symbolicname>");
+ pw.print(headers.get("Bundle-SymbolicName"));
+ //pw.println(bundle.getSymbolicName()); // something null and not supported by R3 !
+ pw.println("</symbolicname>");
+
+ pw.print("<version>");
+ pw.print(headers.get(Constants.BUNDLE_VERSION));
+ pw.println("</version>");
+
+ pw.print("<name>");
+ pw.print(headers.get(Constants.BUNDLE_NAME));
+ pw.println("</name>");
+
+ pw.print("<location>");
+ pw.print(bundle.getLocation());
+ pw.println("</location>");
+
+ pw.print("<lastmodified>");
+ pw.print(bundle.getLastModified());
+ pw.println("</lastmodified>");
+
+ if(startLevel!=null) {
+ pw.print("<startlevel>");
+ pw.print(startLevel.getBundleStartLevel(bundle));
+ pw.println("</startlevel>");
+ }
+
+ pw.println("</bundle>");
+ }
+
+ pw.println("</bundles>");
}
Modified: felix/sandbox/donsez/http.webadmin/src/main/resources/OSGI-INF/component.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/http.webadmin/src/main/resources/OSGI-INF/component.xml?view=diff&rev=536658&r1=536657&r2=536658
==============================================================================
--- felix/sandbox/donsez/http.webadmin/src/main/resources/OSGI-INF/component.xml (original)
+++ felix/sandbox/donsez/http.webadmin/src/main/resources/OSGI-INF/component.xml Wed May 9 14:22:58 2007
@@ -1,5 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
-<component name="WebAdmin" immediate="true">
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+@author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+-->
+<component name="http.webadmin" immediate="true">
<!-- for immediate="true", see 112.5.4 Delayed Component -->
<implementation class="org.apache.felix.http.webadmin.WebAdmin"/>
@@ -14,8 +36,26 @@
bind="bindHttpService"
unbind="unbindHttpService"
/>
-<!--
+ <reference
+ name="LOG"
+ interface="org.osgi.service.log.LogService"
+ cardinality="0..1"
+ policy="dynamic"
+ bind="bindLogService"
+ unbind="unbindLogService"
+ />
+
+ <reference
+ name="STARTLEVEL"
+ interface="org.osgi.service.startlevel.StartLevel"
+ cardinality="0..1"
+ policy="dynamic"
+ bind="bindStartLevel"
+ unbind="unbindStartLevel"
+ />
+
+ <!--
// TODO
<reference
name="OBR"
@@ -28,24 +68,12 @@
// TODO
<reference
- name="OBR"
+ name="SHELL"
interface="org.apache.felix.shell.ShellService"
cardinality="0..1"
policy="dynamic"
bind="bindShellService"
unbind="unbindShellService"
- />
-
- <reference
- name="LOG"
- interface="org.osgi.service.log.LogService"
- cardinality="0..1"
- policy="dynamic"
- bind="bindLogService"
- unbind="unbindLogService"
- />
-
+ />
-->
-</component>
-
-
+</component>
\ No newline at end of file
Added: felix/sandbox/donsez/http.webadmin/src/main/resources/webroot/bundles2html.xsl
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/http.webadmin/src/main/resources/webroot/bundles2html.xsl?view=auto&rev=536658
==============================================================================
--- felix/sandbox/donsez/http.webadmin/src/main/resources/webroot/bundles2html.xsl (added)
+++ felix/sandbox/donsez/http.webadmin/src/main/resources/webroot/bundles2html.xsl Wed May 9 14:22:58 2007
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
+
+ <xsl:template match="/">
+ <html>
+ <head></head>
+ <body>
+ <xsl:apply-templates/>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="bundles">
+ <table border="1">
+ <xsl:apply-templates/>
+ </table>
+ </xsl:template>
+
+ <xsl:template match="bundles[not(bundle)]">
+ No bundle in bundles element
+ </xsl:template>
+
+ <xsl:template match="bundle">
+ <tr>
+ <xsl:apply-templates/>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="bundle/*">
+ <td><xsl:value-of select="."/></td>
+ </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
Propchange: felix/sandbox/donsez/http.webadmin/src/main/resources/webroot/bundles2html.xsl
------------------------------------------------------------------------------
svn:eol-style = native