This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new 174e803eb1 FELIX-6624 : Clean up code
174e803eb1 is described below

commit 174e803eb124ee47a833ed8f46079c120702359d
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Fri Aug 18 11:28:22 2023 +0200

    FELIX-6624 : Clean up code
---
 .../felix/webconsole/AttachmentProvider.java       | 11 +++++----
 .../apache/felix/webconsole/BrandingPlugin.java    |  5 ++--
 .../felix/webconsole/ConfigurationPrinter.java     | 11 +++++----
 .../felix/webconsole/DefaultVariableResolver.java  | 27 ++++++----------------
 .../webconsole/ModeAwareConfigurationPrinter.java  |  8 ++++---
 .../apache/felix/webconsole/VariableResolver.java  |  7 +++---
 .../webconsole/WebConsoleSecurityProvider.java     |  5 ++--
 .../webconsole/WebConsoleSecurityProvider2.java    |  6 +++--
 .../webconsole/WebConsoleSecurityProvider3.java    |  5 ++--
 .../webconsole/internal/servlet/OsgiManager.java   |  4 ++++
 10 files changed, 45 insertions(+), 44 deletions(-)

diff --git 
a/webconsole/src/main/java/org/apache/felix/webconsole/AttachmentProvider.java 
b/webconsole/src/main/java/org/apache/felix/webconsole/AttachmentProvider.java
index a433e08785..7e286af4f9 100644
--- 
a/webconsole/src/main/java/org/apache/felix/webconsole/AttachmentProvider.java
+++ 
b/webconsole/src/main/java/org/apache/felix/webconsole/AttachmentProvider.java
@@ -18,9 +18,9 @@
  */
 package org.apache.felix.webconsole;
 
-
 import java.net.URL;
 
+import org.osgi.annotation.versioning.ConsumerType;
 
 /**
  * This is an optional extension of the {@link ConfigurationPrinter}.
@@ -32,12 +32,13 @@ import java.net.URL;
  * A service implementing this method must still register itself
  * as a {@link ConfigurationPrinter} but not as a
  * {@link AttachmentProvider} service.
+ *
  * @since 3.0
- * @deprecated This has been deprecated. Use the org.apache.felix.status
- *             API instead.
+ * @deprecated This has been deprecated. Use the org.apache.felix.inventory 
API instead.
  */
-public interface AttachmentProvider
-{
+@Deprecated
+@ConsumerType
+public interface AttachmentProvider {
 
     /**
      * Return an array of attachments for the given render mode.
diff --git 
a/webconsole/src/main/java/org/apache/felix/webconsole/BrandingPlugin.java 
b/webconsole/src/main/java/org/apache/felix/webconsole/BrandingPlugin.java
index d28edbdbf1..75774877f2 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/BrandingPlugin.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/BrandingPlugin.java
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.webconsole;
 
+import org.osgi.annotation.versioning.ConsumerType;
 
 /**
  * The <code>BrandingPlugin</code> is the service interface for the most
@@ -25,8 +26,8 @@ package org.apache.felix.webconsole;
  *
  * @see DefaultBrandingPlugin
  */
-public interface BrandingPlugin
-{
+@ConsumerType
+public interface BrandingPlugin {
     /**
      * Returns an indicative name of the branding plugin. This value is used
      * as the Window/Page title together with the title of the respective
diff --git 
a/webconsole/src/main/java/org/apache/felix/webconsole/ConfigurationPrinter.java
 
b/webconsole/src/main/java/org/apache/felix/webconsole/ConfigurationPrinter.java
index ce7cd54748..18e33bc17c 100644
--- 
a/webconsole/src/main/java/org/apache/felix/webconsole/ConfigurationPrinter.java
+++ 
b/webconsole/src/main/java/org/apache/felix/webconsole/ConfigurationPrinter.java
@@ -18,9 +18,9 @@
  */
 package org.apache.felix.webconsole;
 
-
 import java.io.PrintWriter;
 
+import org.osgi.annotation.versioning.ConsumerType;
 
 /**
  * The <code>ConfigurationPrinter</code> is a service interface to be used by
@@ -32,11 +32,12 @@ import java.io.PrintWriter;
  * With the {@link WebConsoleConstants#CONFIG_PRINTER_MODES} property this
  * service can specify when it should be included.
  * The default mode is {@link #MODE_ALWAYS}.
- * @deprecated This has been deprecated. Use the org.apache.felix.status
- *             API instead.
+ *
+ * @deprecated This has been deprecated. Use the org.apache.felix.inventory 
API instead.
  */
-public interface ConfigurationPrinter
-{
+@Deprecated
+@ConsumerType
+public interface ConfigurationPrinter {
 
     /**
      * The service name under which services of this class must be registered
diff --git 
a/webconsole/src/main/java/org/apache/felix/webconsole/DefaultVariableResolver.java
 
b/webconsole/src/main/java/org/apache/felix/webconsole/DefaultVariableResolver.java
index 0ec2f609c2..9fa37de286 100644
--- 
a/webconsole/src/main/java/org/apache/felix/webconsole/DefaultVariableResolver.java
+++ 
b/webconsole/src/main/java/org/apache/felix/webconsole/DefaultVariableResolver.java
@@ -32,21 +32,17 @@ import java.util.Map;
  * as the variable resolver if none has yet been assigned to the request.
  */
 @SuppressWarnings({ "rawtypes" })
-public class DefaultVariableResolver extends HashMap implements 
VariableResolver
-{
+public class DefaultVariableResolver extends HashMap implements 
VariableResolver {
 
     private static final long serialVersionUID = 4148807223433047780L;
 
-
     /**
      * Creates a new variable resolver with default capacity.
      */
-    public DefaultVariableResolver()
-    {
+    public DefaultVariableResolver() {
         super();
     }
 
-
     /**
      * Creates a new variable resolver and initializes both - capacity &amp; 
load factor
      * 
@@ -54,24 +50,20 @@ public class DefaultVariableResolver extends HashMap 
implements VariableResolver
      * @param loadFactor the load factor of the variable container
      * @see HashMap#HashMap(int, float)
      */
-    public DefaultVariableResolver( final int initialCapacity, final float 
loadFactor )
-    {
+    public DefaultVariableResolver( final int initialCapacity, final float 
loadFactor ) {
         super( initialCapacity, loadFactor );
     }
 
-
     /**
      * Creates a new variable resolver with specified initial capacity
      * 
      * @param initialCapacity  the initial capacity of the variable container
      * @see HashMap#HashMap(int)
      */
-    public DefaultVariableResolver( final int initialCapacity )
-    {
+    public DefaultVariableResolver( final int initialCapacity ) {
         super( initialCapacity );
     }
 
-
     /**
      * Creates a new variable resolver copying the variables from the given 
map.
      * 
@@ -79,12 +71,10 @@ public class DefaultVariableResolver extends HashMap 
implements VariableResolver
      * @see HashMap#HashMap(Map)
      */
     @SuppressWarnings({"unchecked"})
-    public DefaultVariableResolver( final Map source )
-    {
+    public DefaultVariableResolver( final Map source ) {
         super( source );
     }
 
-
     /**
      * Returns the string representation of the value stored under the variable
      * name in this map. If no value is stored under the variable name,
@@ -94,14 +84,11 @@ public class DefaultVariableResolver extends HashMap 
implements VariableResolver
      * @return The variable value or <code>null</code> if there is no entry
      *      with the given name in this map.
      */
-    public String resolve( final String variable )
-    {
+    public String resolve( final String variable ) {
         Object value = get( variable );
-        if ( value != null )
-        {
+        if ( value != null ) {
             return value.toString();
         }
         return null;
     }
-
 }
diff --git 
a/webconsole/src/main/java/org/apache/felix/webconsole/ModeAwareConfigurationPrinter.java
 
b/webconsole/src/main/java/org/apache/felix/webconsole/ModeAwareConfigurationPrinter.java
index 309ef7351c..521c5b0804 100644
--- 
a/webconsole/src/main/java/org/apache/felix/webconsole/ModeAwareConfigurationPrinter.java
+++ 
b/webconsole/src/main/java/org/apache/felix/webconsole/ModeAwareConfigurationPrinter.java
@@ -21,6 +21,8 @@ package org.apache.felix.webconsole;
 
 import java.io.PrintWriter;
 
+import org.osgi.annotation.versioning.ConsumerType;
+
 
 /**
  * This is an optional extension of the {@link ConfigurationPrinter}.
@@ -37,9 +39,9 @@ import java.io.PrintWriter;
  * @deprecated This has been deprecated. Use the org.apache.felix.status
  *             API instead.
  */
-public interface ModeAwareConfigurationPrinter
-    extends ConfigurationPrinter
-{
+@Deprecated
+@ConsumerType
+public interface ModeAwareConfigurationPrinter extends ConfigurationPrinter {
 
     /**
      * Prints the configuration report to the given <code>printWriter</code>.
diff --git 
a/webconsole/src/main/java/org/apache/felix/webconsole/VariableResolver.java 
b/webconsole/src/main/java/org/apache/felix/webconsole/VariableResolver.java
index 833a97bf6e..7065437a91 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/VariableResolver.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/VariableResolver.java
@@ -18,6 +18,8 @@
  */
 package org.apache.felix.webconsole;
 
+import org.osgi.annotation.versioning.ConsumerType;
+import org.osgi.annotation.versioning.ProviderType;
 
 /**
  * The <code>VariableResolver</code> interface defines the API for an object
@@ -40,8 +42,8 @@ package org.apache.felix.webconsole;
  * @see WebConsoleUtil#getVariableResolver(javax.servlet.ServletRequest)
  * @see WebConsoleUtil#setVariableResolver(javax.servlet.ServletRequest, 
VariableResolver)
  */
-public interface VariableResolver
-{
+@ConsumerType
+public interface VariableResolver {
 
     /**
      * Returns a replacement value for the named variable or <code>null</code>
@@ -53,5 +55,4 @@ public interface VariableResolver
      *      available.
      */
     String resolve( String variable );
-
 }
diff --git 
a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider.java
 
b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider.java
index 39b0e07da6..7d18e7bf85 100644
--- 
a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider.java
+++ 
b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider.java
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.webconsole;
 
+import org.osgi.annotation.versioning.ConsumerType;
 
 /**
  * The <code>WebConsoleSecurityProvider</code> is a service interface allowing
@@ -26,8 +27,8 @@ package org.apache.felix.webconsole;
  *
  * @since 3.1.0; Web Console Bundle 3.1.0
  */
-public interface WebConsoleSecurityProvider
-{
+@ConsumerType
+public interface WebConsoleSecurityProvider {
 
     /**
      * Authenticates the user with the given user name and password.
diff --git 
a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider2.java
 
b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider2.java
index 87340023ba..3a78b8aa9d 100644
--- 
a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider2.java
+++ 
b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider2.java
@@ -22,6 +22,8 @@ package org.apache.felix.webconsole;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.osgi.annotation.versioning.ConsumerType;
+
 
 /**
  * The <code>WebConsoleSecurityProvider2</code> extends the
@@ -35,8 +37,8 @@ import javax.servlet.http.HttpServletResponse;
  *
  * @since 3.1.2; Web Console Bundle 3.1.4
  */
-public interface WebConsoleSecurityProvider2 extends WebConsoleSecurityProvider
-{
+@ConsumerType
+public interface WebConsoleSecurityProvider2 extends 
WebConsoleSecurityProvider {
 
     /**
      * The name of the request attribute providing the object representing the
diff --git 
a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider3.java
 
b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider3.java
index 0b96f5b9d5..9f479807bd 100644
--- 
a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider3.java
+++ 
b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider3.java
@@ -21,6 +21,7 @@ package org.apache.felix.webconsole;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.osgi.annotation.versioning.ConsumerType;
 import org.osgi.service.http.context.ServletContextHelper;
 
 /**
@@ -38,8 +39,8 @@ import org.osgi.service.http.context.ServletContextHelper;
  * 
  * @since 4.2.8; Web Console Bundle 4.2.8
  */
-public interface WebConsoleSecurityProvider3 extends 
WebConsoleSecurityProvider2
-{
+@ConsumerType
+public interface WebConsoleSecurityProvider3 extends 
WebConsoleSecurityProvider2 {
 
     /**
      * This method will be called by the web console when the user clicks the 
logout button. The security provider
diff --git 
a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
 
b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
index eff053801c..3945fc4762 100644
--- 
a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
+++ 
b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
@@ -58,6 +58,7 @@ import org.apache.felix.webconsole.WebConsoleConstants;
 import org.apache.felix.webconsole.WebConsoleSecurityProvider;
 import org.apache.felix.webconsole.WebConsoleSecurityProvider2;
 import org.apache.felix.webconsole.WebConsoleSecurityProvider3;
+import org.apache.felix.webconsole.WebConsoleUtil;
 import org.apache.felix.webconsole.internal.OsgiManagerPlugin;
 import org.apache.felix.webconsole.internal.Util;
 import org.apache.felix.webconsole.internal.core.BundlesServlet;
@@ -628,6 +629,9 @@ public class OsgiManager extends GenericServlet {
         request = wrapRequest(request, locale);
         response = wrapResponse(request, response, plugin);
 
+        // make sure to set the variable resolver
+        WebConsoleUtil.getVariableResolver(request);
+
         plugin.service(request, response);
     }
 

Reply via email to