FELIX-1569 Remove the Render interface and RenderBridge and modify
remaining Render implementations to extend from AbstractWebConsolePlugin
directly.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@812507 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/Render.java b/webconsole/src/main/java/org/apache/felix/webconsole/Render.java
deleted file mode 100644
index 41fefbf..0000000
--- a/webconsole/src/main/java/org/apache/felix/webconsole/Render.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.webconsole;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * The <code>Render</code> interface defines a service interface for
- * information renderings to be plugged into the web console.
- * <p>
- * <strong>NOTE: This interface is just an intermediate solution for making the
- * web console extensible. Future releases of the web console will remove this
- * and the {@link Action} interfaces and use the
- * <code>javax.servlet.Servlet</code> interface with predefined service
- * registration properties instead.</strong>
- *
- * @deprecated This interface will be removed when <a
- * href="https://issues.apache.org/jira/browse/FELIX-574">FELIX-574</a>
- * will be implemented.
- */
-public interface Render {
-
- static final String SERVICE = Render.class.getName();
-
- String getName();
-
- String getLabel();
-
- void render(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException;
-
-}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
index 1f1e137..55a38f6 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
@@ -39,8 +39,7 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.felix.webconsole.ConfigurationPrinter;
-import org.apache.felix.webconsole.Render;
-import org.apache.felix.webconsole.internal.BaseManagementPlugin;
+import org.apache.felix.webconsole.internal.BaseWebConsolePlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
@@ -53,12 +52,12 @@
import org.osgi.util.tracker.ServiceTracker;
-public class ConfigurationRender extends BaseManagementPlugin implements Render
+public class ConfigurationRender extends BaseWebConsolePlugin
{
- public static final String NAME = "config";
+ public static final String LABEL = "config";
- public static final String LABEL = "Configuration Status";
+ public static final String TITLE = "Configuration Status";
private ServiceTracker cfgPrinterTracker;
@@ -67,9 +66,9 @@
private SortedMap configurationPrinters = new TreeMap();
- public String getName()
+ public String getTitle()
{
- return NAME;
+ return TITLE;
}
@@ -79,7 +78,7 @@
}
- public void render( HttpServletRequest request, HttpServletResponse response ) throws IOException
+ protected void renderContent( HttpServletRequest request, HttpServletResponse response ) throws IOException
{
PrintWriter pw = response.getWriter();
@@ -283,27 +282,27 @@
return;
}
- PreferencesService ps = ( PreferencesService ) getBundleContext().getService( sr );
- try
- {
- this.printPreferences( pw, ps.getSystemPreferences() );
-
- String[] users = ps.getUsers();
- for ( int i = 0; users != null && i < users.length; i++ )
+ PreferencesService ps = ( PreferencesService ) getBundleContext().getService( sr );
+ try
{
- pw.println( "*** User Preferences " + users[i] + ":" );
- this.printPreferences( pw, ps.getUserPreferences( users[i] ) );
+ this.printPreferences( pw, ps.getSystemPreferences() );
+
+ String[] users = ps.getUsers();
+ for ( int i = 0; users != null && i < users.length; i++ )
+ {
+ pw.println( "*** User Preferences " + users[i] + ":" );
+ this.printPreferences( pw, ps.getUserPreferences( users[i] ) );
+ }
+ }
+ catch ( BackingStoreException bse )
+ {
+ // todo or not :-)
+ }
+ finally
+ {
+ getBundleContext().ungetService( sr );
}
}
- catch ( BackingStoreException bse )
- {
- // todo or not :-)
- }
- finally
- {
- getBundleContext().ungetService( sr );
- }
- }
private void printPreferences( PrintWriter pw, Preferences prefs ) throws BackingStoreException
@@ -538,7 +537,7 @@
pw.println( "*** Threads:" );
printThreadGroup( pw, rootGroup );
-
+
int numGroups = rootGroup.activeGroupCount();
ThreadGroup[] groups = new ThreadGroup[2 * numGroups];
rootGroup.enumerate( groups );
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/obr/BundleRepositoryRender.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/obr/BundleRepositoryRender.java
index 8a4cfac..eb2f583 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/obr/BundleRepositoryRender.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/obr/BundleRepositoryRender.java
@@ -21,7 +21,6 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -29,16 +28,14 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.SortedMap;
import java.util.SortedSet;
import java.util.StringTokenizer;
-import java.util.TreeMap;
import java.util.TreeSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.felix.webconsole.Render;
+import org.apache.felix.webconsole.internal.BaseWebConsolePlugin;
import org.apache.felix.webconsole.internal.Util;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -49,12 +46,12 @@
import org.osgi.service.obr.Resource;
-public class BundleRepositoryRender extends AbstractObrPlugin implements Render
+public class BundleRepositoryRender extends BaseWebConsolePlugin
{
- public static final String NAME = "bundlerepo";
+ public static final String LABEL = "bundlerepo";
- public static final String LABEL = "OSGi Repository";
+ public static final String TITLE = "OSGi Repository";
public static final String PARAM_REPO_ID = "repositoryId";
@@ -89,19 +86,19 @@
}
- public String getName()
- {
- return NAME;
- }
-
-
public String getLabel()
{
return LABEL;
}
- public void render( HttpServletRequest request, HttpServletResponse response ) throws IOException
+ public String getTitle()
+ {
+ return TITLE;
+ }
+
+
+ protected void renderContent( HttpServletRequest request, HttpServletResponse response ) throws IOException
{
PrintWriter pw = response.getWriter();
@@ -356,7 +353,7 @@
pw.println( "<td class='content' valign='top' align='center'>" );
pw.println( "<select class='select' name='bundle'>" );
- pw.print( "<option value='" + DONT_INSTALL_OPTION + "'>Select Version...</option>" );
+ pw.print( "<option value='" + AbstractObrPlugin.DONT_INSTALL_OPTION + "'>Select Version...</option>" );
for ( Iterator vi = versions.iterator(); vi.hasNext(); )
{
Version version = ( Version ) vi.next();
@@ -417,4 +414,10 @@
return bundles;
}
+
+ protected RepositoryAdmin getRepositoryAdmin()
+ {
+ return ( RepositoryAdmin ) getService( RepositoryAdmin.class.getName() );
+ }
+
}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/RenderBridge.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/RenderBridge.java
deleted file mode 100644
index b9cc343..0000000
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/RenderBridge.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.webconsole.internal.servlet;
-
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.felix.webconsole.AbstractWebConsolePlugin;
-import org.apache.felix.webconsole.Render;
-
-
-public class RenderBridge extends AbstractWebConsolePlugin
-{
-
- /** Pseudo class version ID to keep the IDE quite. */
- private static final long serialVersionUID = 1L;
-
- private final Render render;
-
-
- RenderBridge( Render render )
- {
- this.render = render;
- }
-
-
- public Render getRender()
- {
- return render;
- }
-
-
- public String getTitle()
- {
- return render.getLabel();
- }
-
-
- public String getLabel()
- {
- return render.getName();
- }
-
-
- protected void renderContent( HttpServletRequest request, HttpServletResponse response ) throws ServletException,
- IOException
- {
- render.render( request, response );
- }
-
-}