FELIX-3947 Fix ClassDefNotFoundError if Servlet API cannot be wired
* Move Web Console Plugin registration from DefaultWebConsolePlugin
class (static method with DefaultWebConsolePlugin creation) to
InventoryPrinterManagerImpl
* Define constants for the DefaultWebConsolePlugin in ConsoleConstants
to prevent loading the class
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1452205 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java b/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java
index f0e3424..3e04b15 100644
--- a/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java
+++ b/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java
@@ -5,9 +5,9 @@
* 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.
@@ -18,16 +18,10 @@
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Dictionary;
-import java.util.Hashtable;
import java.util.zip.ZipOutputStream;
import org.apache.felix.inventory.PrinterMode;
import org.apache.felix.inventory.impl.webconsole.ConsoleConstants;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceRegistration;
/**
* The web console plugin for a inventory printer.
@@ -39,7 +33,7 @@
/**
* Constructor
- *
+ *
* @param inventoryPrinterAdapter The adapter
*/
DefaultWebConsolePlugin(final InventoryPrinterManagerImpl inventoryPrinterManager)
@@ -57,7 +51,7 @@
*/
public String getTitle()
{
- return "Overview";
+ return ConsoleConstants.TITLE;
}
/**
@@ -65,7 +59,7 @@
*/
public String getName()
{
- return "config";
+ return ConsoleConstants.NAME;
}
/**
@@ -110,28 +104,4 @@
{
// no attachments support
}
-
- public static ServiceRegistration register(final BundleContext context, final InventoryPrinterManagerImpl manager)
- {
- final DefaultWebConsolePlugin dwcp = new DefaultWebConsolePlugin(manager);
-
- final Dictionary props = new Hashtable();
- props.put(ConsoleConstants.PLUGIN_LABEL, dwcp.getName());
- props.put(ConsoleConstants.PLUGIN_TITLE, dwcp.getTitle());
- props.put(ConsoleConstants.PLUGIN_CATEGORY, ConsoleConstants.WEB_CONSOLE_CATEGORY);
- return context.registerService(ConsoleConstants.INTERFACE_SERVLET, new ServiceFactory()
- {
-
- public void ungetService(final Bundle bundle, final ServiceRegistration registration, final Object service)
- {
- // nothing to do
- }
-
- public Object getService(final Bundle bundle, final ServiceRegistration registration)
- {
- return dwcp;
- }
-
- }, props);
- }
}
\ No newline at end of file
diff --git a/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java b/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
index 82d8d6d..9eee00e 100644
--- a/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
+++ b/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
@@ -18,7 +18,9 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Dictionary;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -29,8 +31,11 @@
import org.apache.felix.inventory.InventoryPrinter;
import org.apache.felix.inventory.PrinterMode;
+import org.apache.felix.inventory.impl.webconsole.ConsoleConstants;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.log.LogService;
@@ -78,7 +83,22 @@
+ InventoryPrinter.CONFIG_TITLE + "=*))"), this);
this.cfgPrinterTracker.open();
- this.pluginRegistration = DefaultWebConsolePlugin.register(btx, this);
+ final Dictionary props = new Hashtable();
+ props.put(ConsoleConstants.PLUGIN_LABEL, ConsoleConstants.NAME);
+ props.put(ConsoleConstants.PLUGIN_TITLE, ConsoleConstants.TITLE);
+ props.put(ConsoleConstants.PLUGIN_CATEGORY, ConsoleConstants.WEB_CONSOLE_CATEGORY);
+ this.pluginRegistration = btx.registerService(ConsoleConstants.INTERFACE_SERVLET, new ServiceFactory()
+ {
+ public void ungetService(final Bundle bundle, final ServiceRegistration registration, final Object service)
+ {
+ // nothing to do
+ }
+
+ public Object getService(final Bundle bundle, final ServiceRegistration registration)
+ {
+ return new DefaultWebConsolePlugin(InventoryPrinterManagerImpl.this);
+ }
+ }, props);
}
/**
diff --git a/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConsoleConstants.java b/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConsoleConstants.java
index 1a33ebd..eca29e8 100644
--- a/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConsoleConstants.java
+++ b/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConsoleConstants.java
@@ -5,9 +5,9 @@
* 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.
@@ -44,4 +44,8 @@
public static final String PROPERTY_MODES = "modes"; //$NON-NLS-1$
public static final String WEB_CONSOLE_CATEGORY = "Status"; //$NON-NLS-1$
+
+ public static final String NAME = "config"; //$NON-NLS-1$
+
+ public static final String TITLE = "Overview"; //$NON-NLS-1$
}