Fix FELIX-1497.
NPE were thrown when the matching service reference list of the used service reference list were null.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@805383 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/webconsole-plugin/pom.xml b/ipojo/webconsole-plugin/pom.xml
index a51d34f..a2f9b1b 100644
--- a/ipojo/webconsole-plugin/pom.xml
+++ b/ipojo/webconsole-plugin/pom.xml
@@ -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
diff --git a/ipojo/webconsole-plugin/src/main/java/org/apache/felix/org/apache/felix/ipojo/webconsole/IPOJOServlet.java b/ipojo/webconsole-plugin/src/main/java/org/apache/felix/org/apache/felix/ipojo/webconsole/IPOJOServlet.java
index 1ccc53e..d6d3b2a 100644
--- a/ipojo/webconsole-plugin/src/main/java/org/apache/felix/org/apache/felix/ipojo/webconsole/IPOJOServlet.java
+++ b/ipojo/webconsole-plugin/src/main/java/org/apache/felix/org/apache/felix/ipojo/webconsole/IPOJOServlet.java
@@ -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";