felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r805383 - in /felix/trunk/ipojo/webconsole-plugin: pom.xml src/main/java/org/apache/felix/org/apache/felix/ipojo/webconsole/IPOJOServlet.java
Date Tue, 18 Aug 2009 12:19:24 GMT
Author: clement
Date: Tue Aug 18 12:19:24 2009
New Revision: 805383

URL: http://svn.apache.org/viewvc?rev=805383&view=rev
Log:
Fix FELIX-1497.
NPE were thrown when the matching service reference list of the used service reference list
were null.

Modified:
    felix/trunk/ipojo/webconsole-plugin/pom.xml
    felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/org/apache/felix/ipojo/webconsole/IPOJOServlet.java

Modified: felix/trunk/ipojo/webconsole-plugin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/webconsole-plugin/pom.xml?rev=805383&r1=805382&r2=805383&view=diff
==============================================================================
--- felix/trunk/ipojo/webconsole-plugin/pom.xml (original)
+++ felix/trunk/ipojo/webconsole-plugin/pom.xml Tue Aug 18 12:19:24 2009
@@ -27,7 +27,7 @@
   <packaging>bundle</packaging>
   <artifactId>org.apache.felix.ipojo.webconsole</artifactId>
   <version>1.5.0-SNAPSHOT</version>
-  <name>Apache Felix iPOJO WebConsole Plugin</name>
+  <name>Apache Felix iPOJO WebConsole Plugins</name>
   
   <description>
   iPOJO plugin for the Apache Felix Web Console. This plugin allows introspecting an iPOJO
system with the Apache Felix

Modified: felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/org/apache/felix/ipojo/webconsole/IPOJOServlet.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/org/apache/felix/ipojo/webconsole/IPOJOServlet.java?rev=805383&r1=805382&r2=805383&view=diff
==============================================================================
--- felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/org/apache/felix/ipojo/webconsole/IPOJOServlet.java
(original)
+++ felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/org/apache/felix/ipojo/webconsole/IPOJOServlet.java
Tue Aug 18 12:19:24 2009
@@ -92,7 +92,7 @@
      * Label used by the web console.
      */
     @ServiceProperty(name = "felix.webconsole.label")
-    private String m_label = "ipojo";
+    private String m_label = "iPOJO";
 
     /**
      * Title used by the web console.
@@ -161,7 +161,7 @@
      */
     private int getValidCount() {
         int i = 0;
-        for (Architecture a : m_archs) {
+        for (Architecture a : m_archs) { // Cannot be null, an empty list is returned.
             if (a.getInstanceDescription().getState() == ComponentInstance.VALID) {
                 i ++;
             }
@@ -175,7 +175,7 @@
      */
     private int getInvalidCount() {
         int i = 0;
-        for (Architecture a : m_archs) {
+        for (Architecture a : m_archs) {  // Cannot be null, an empty list is returned.
             if (a.getInstanceDescription().getState() == ComponentInstance.INVALID) {
                 i ++;
             }
@@ -271,7 +271,7 @@
      */
     private void printFactoryDetail(PrintWriter pw, String name) {
         List<ComponentTypeDescription> fs = new ArrayList<ComponentTypeDescription>();
-        for (Factory f : this.m_factories) {
+        for (Factory f : this.m_factories) { // Cannot be null, an empty list is returned.
             if (f.getName().equals(name)) {
                 fs.add(f.getComponentDescription());
             }
@@ -332,20 +332,20 @@
                 + "</tr>"
                 + "</thead>"
                 + "<tbody>";
-        for (PropertyDescription pd : properties) {
-            String name = pd.getName();
-            String type = pd.getType();
-            boolean mandatory = pd.isMandatory();
-            boolean immutable = pd.isImmutable();
-            String value = pd.getValue();
-            s += "<tr>"
-                + "<td>" + name + "</td>"
-                + "<td>" + type + "</td>"
-                + "<td>" + "" + mandatory + "</td>"
-                + "<td>" + "" + immutable + "</td>"
-                + "<td>" + (value == null ? "<i>No Value</i>" : value)
+ "</td>"
-                + "</tr>";
-        }
+        if (properties != null) {
+            for (PropertyDescription pd : properties) {
+                String name = pd.getName();
+                String type = pd.getType();
+                boolean mandatory = pd.isMandatory();
+                boolean immutable = pd.isImmutable();
+                String value = pd.getValue();
+                s += "<tr>" + "<td>" + name + "</td>" + "<td>" +
type + "</td>"
+                        + "<td>" + "" + mandatory + "</td>" + "<td>" +
""
+                        + immutable + "</td>" + "<td>"
+                        + (value == null ? "<i>No Value</i>" : value) + "</td>"
+                        + "</tr>";
+            }
+        }  // Else don't print anything.
         s += "</tbody></table>";
         return s;
     }
@@ -366,7 +366,7 @@
                 + "</thead>"
                 + "<tbody>");
 
-        for (Architecture arch : m_archs) {
+        for (Architecture arch : m_archs) { // Cannot be null, an empty list is returned.
             InstanceDescription id = arch.getInstanceDescription();
             String name = id.getName();
             String factory = id.getComponentDescription().getName();
@@ -414,8 +414,7 @@
      */
     private String getFactoryLinkIfPossible(InstanceDescription id) {
         String n = id.getComponentDescription().getName();
-        System.out.println("Look for " + n);
-        for (Factory f : m_factories) {
+        for (Factory f : m_factories) { // Cannot be null, an empty list is returned.
             if (f.getName().equals(n)) {
                 return "<a href=\"ipojo?factory=" + n + "\">" + n + "</a>";
             }
@@ -431,9 +430,11 @@
      */
     private String getInvalidHandlerList(HandlerDescription[] hl) {
         List<String> list = new ArrayList<String>();
-        for (HandlerDescription hd : hl) {
-            if (! hd.isValid()) {
-                list.add(hd.getHandlerName());
+        if (hl != null) {
+            for (HandlerDescription hd : hl) {
+                if (! hd.isValid()) {
+                    list.add(hd.getHandlerName());
+                }
             }
         }
         return list.toString();
@@ -503,7 +504,7 @@
      */
     private String getInstanceList(String factory) {
         String s = "<ul>";
-        for (Architecture arch : m_archs) {
+        for (Architecture arch : m_archs) { // Cannot be null, an empty list is returned.
             String n = arch.getInstanceDescription().getComponentDescription().getName();
             if (factory.equals(n)) {
                 s += "<li>" + getInstanceLink(arch.getInstanceDescription().getName())
+ "</li>";
@@ -521,16 +522,18 @@
      */
     private String getServiceReferenceList(List<ServiceReference> refs) {
         String s = "<ul>";
-        for (ServiceReference ref : refs) {
-            s += "<li>";
-            if (ref.getProperty("instance.name") == null) {
-                s += ref.getProperty(Constants.SERVICE_ID);
-            } else {
-                s += "<a href=\"ipojo?instance="
+        if (refs != null) {
+            for (ServiceReference ref : refs) {
+                s += "<li>";
+                if (ref.getProperty("instance.name") == null) {
+                    s += ref.getProperty(Constants.SERVICE_ID);
+                } else {
+                    s += "<a href=\"ipojo?instance="
                         + ref.getProperty("instance.name") + "\">"
                         + ref.getProperty("instance.name") + " (" +  ref.getProperty(Constants.SERVICE_ID)
+ ")</a>";
+                }
+                s += "</li>";
             }
-            s += "</li>";
         }
         s += "</ul>";
         return s;
@@ -609,7 +612,7 @@
      * @return the instance description or <code>null</code> if not found
      */
     private InstanceDescription getInstanceDescriptionByName(String name) {
-        for (Architecture arch : m_archs) {
+        for (Architecture arch : m_archs) { 
             if (name.equals(arch.getInstanceDescription().getName())) {
                 return arch.getInstanceDescription();
             }
@@ -644,7 +647,7 @@
             pw.write("<tr>"
                     + "<td><a href=\"ipojo?factory=" + name + "\">"
                         + (version == null ? name : name + " (" + version + ")")
-                        + "</a></td>" //TODO Link
+                        + "</a></td>"
                     + "<td>" + bundle + "</td>"
                     + "<td>" + state + "</td>"
                     + "</tr>");
@@ -699,7 +702,7 @@
      * @param state the state.
      * @return the String form of the state.
      */
-    private String getInstanceState(int state) {
+    private static String getInstanceState(int state) {
         switch(state) {
             case ComponentInstance.VALID :
                 return "valid";
@@ -719,7 +722,7 @@
      * @param state the state.
      * @return the String form of the state.
      */
-    private String getFactoryState(int state) {
+    private static String getFactoryState(int state) {
         switch(state) {
             case Factory.VALID :
                 return "valid";
@@ -735,7 +738,7 @@
      * @param state the state.
      * @return the String form of the state.
      */
-    private String getDependencyState(int state) {
+    private static String getDependencyState(int state) {
         switch(state) {
             case DependencyModel.RESOLVED :
                 return "resolved";
@@ -753,7 +756,7 @@
      * @param policy the policy.
      * @return the String form of the policy.
      */
-    private String getDependencyBindingPolicy(int policy) {
+    private static String getDependencyBindingPolicy(int policy) {
         switch(policy) {
             case DependencyModel.DYNAMIC_BINDING_POLICY :
                 return "dynamic";
@@ -771,7 +774,7 @@
      * @param state the state.
      * @return the String form of the state.
      */
-    private String getProvidedServiceState(int state) {
+    private static String getProvidedServiceState(int state) {
         switch(state) {
             case ProvidedService.REGISTERED :
                 return "registered";



Mime
View raw message