felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1215540 [2/2] - in /felix/trunk/webconsole: ./ src/main/java/org/apache/felix/webconsole/ src/main/java/org/apache/felix/webconsole/internal/ src/main/java/org/apache/felix/webconsole/internal/compendium/ src/main/java/org/apache/felix/web...
Date Sat, 17 Dec 2011 18:11:17 GMT
Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationUtil.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationUtil.java?rev=1215540&r1=1215539&r2=1215540&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationUtil.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationUtil.java
Sat Dec 17 18:11:16 2011
@@ -42,7 +42,7 @@ public class ConfigurationUtil
      * @return The value of the named property as a string or <code>def</code>
      *         if the property does not exist
      */
-    public static final String getProperty(Dictionary config, String name, String def)
+    public static final String getProperty(Dictionary<String, ?> config, String name,
String def)
     {
         Object value = config.get(name);
         if (value instanceof String)
@@ -68,7 +68,7 @@ public class ConfigurationUtil
      * @return The value of the named property as a string or <code>def</code>
      *         if the property does not exist
      */
-    public static final int getProperty(Dictionary config, String name, int def)
+    public static final int getProperty(Dictionary<String, ?> config, String name,
int def)
     {
         Object value = config.get(name);
         if (value instanceof Number)
@@ -95,12 +95,12 @@ public class ConfigurationUtil
 
     /**
      * Gets a property as String[]
-     * 
+     *
      * @param config The properties from which to returned the named one
      * @param name The name of the property to return
      * @return the property value as string array - no matter if originally it was other
kind of array, collection or comma-separated string. Returns <code>null</code>
if the property is not set.
      */
-    public static final String[] getStringArrayProperty(Dictionary config, String name)
+    public static final String[] getStringArrayProperty(Dictionary<String, ?> config,
String name)
     {
         Object value = config.get(name);
         if (value == null)
@@ -120,10 +120,10 @@ public class ConfigurationUtil
         }
         else if (value instanceof Collection)
         {
-            Collection collection = (Collection) value;
+            Collection<?> collection = (Collection<?>) value;
             ret = new String[collection.size()];
             int i = 0;
-            for (Iterator iter = collection.iterator(); iter.hasNext();)
+            for (Iterator<?> iter = collection.iterator(); iter.hasNext();)
             {
                 ret[i] = String.valueOf(iter.next());
                 i++;

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java?rev=1215540&r1=1215539&r2=1215540&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
Sat Dec 17 18:11:16 2011
@@ -180,7 +180,7 @@ public class OsgiManager extends Generic
 
     // list of OsgiManagerPlugin instances activated during init. All these
     // instances will have to be deactivated during destroy
-    private List osgiManagerPlugins = new ArrayList();
+    private List<OsgiManagerPlugin> osgiManagerPlugins = new ArrayList<OsgiManagerPlugin>();
 
     private String webManagerRoot;
 
@@ -190,12 +190,12 @@ public class OsgiManager extends Generic
     // true if the resources have been registered with the HttpService
     private boolean httpResourcesRegistered;
 
-    private Dictionary configuration;
+    private Dictionary<String, ?> configuration;
 
     // See https://issues.apache.org/jira/browse/FELIX-2267
     private Locale configuredLocale;
 
-    private Set enabledPlugins;
+    private Set<String> enabledPlugins;
 
     ResourceBundleManager resourceBundleManager;
 
@@ -222,13 +222,13 @@ public class OsgiManager extends Generic
 
             try
             {
-                Class pluginClass = classLoader.loadClass(pluginClassName);
+                Class<?> pluginClass = classLoader.loadClass(pluginClassName);
                 Object plugin = pluginClass.newInstance();
 
                 if (plugin instanceof OsgiManagerPlugin)
                 {
                     ((OsgiManagerPlugin) plugin).activate(bundleContext);
-                    osgiManagerPlugins.add(plugin);
+                    osgiManagerPlugins.add((OsgiManagerPlugin) plugin);
                 }
                 if (plugin instanceof BrandingPlugin)
                 {
@@ -321,10 +321,9 @@ public class OsgiManager extends Generic
         }
 
         // deactivate any remaining plugins
-        for (Iterator pi = osgiManagerPlugins.iterator(); pi.hasNext();)
+        for ( Iterator<OsgiManagerPlugin> pi = osgiManagerPlugins.iterator(); pi.hasNext();
)
         {
-            Object plugin = pi.next();
-            ((OsgiManagerPlugin) plugin).deactivate();
+            pi.next().deactivate();
         }
 
         // simply remove all operations, we should not be used anymore
@@ -410,8 +409,7 @@ public class OsgiManager extends Generic
         AbstractWebConsolePlugin plugin = getConsolePlugin(label);
         if (plugin != null)
         {
-            final Map labelMap = holder.getLocalizedLabelMap(resourceBundleManager,
-                locale);
+            final Map<String, String> labelMap = holder.getLocalizedLabelMap( resourceBundleManager,
locale );
 
             // the official request attributes
             request.setAttribute(WebConsoleConstants.ATTR_LANG_MAP, getLangMap());
@@ -667,12 +665,9 @@ public class OsgiManager extends Generic
 
     private static class BrandingServiceTracker extends ServiceTracker
     {
-        private final OsgiManager osgiManager; // FIXME: never read locally
-
         BrandingServiceTracker(OsgiManager osgiManager)
         {
             super(osgiManager.getBundleContext(), BrandingPlugin.class.getName(), null);
-            this.osgiManager = osgiManager;
         }
 
         public Object addingService(ServiceReference reference)
@@ -706,7 +701,7 @@ public class OsgiManager extends Generic
             return;
         }
 
-        Dictionary config = getConfiguration();
+        Dictionary<String, ?> config = getConfiguration();
 
         // get authentication details
         String realm = ConfigurationUtil.getProperty(config, PROP_REALM, DEFAULT_REALM);
@@ -719,7 +714,7 @@ public class OsgiManager extends Generic
             HttpContext httpContext = new OsgiManagerHttpContext(httpService,
                 securityProviderTracker, userId, password, realm);
 
-            Dictionary servletConfig = toStringConfig(config);
+            Dictionary<String, String> servletConfig = toStringConfig(config);
 
             // register this servlet and take note of this
             httpService.registerServlet(this.webManagerRoot, this, servletConfig,
@@ -781,16 +776,16 @@ public class OsgiManager extends Generic
         }
     }
 
-    private Dictionary getConfiguration()
+    private Dictionary<String, ?> getConfiguration()
     {
         return configuration;
     }
 
-    synchronized void updateConfiguration(Dictionary config)
+    synchronized void updateConfiguration(Dictionary<String, ?> config)
     {
         if (config == null)
         {
-            config = new Hashtable();
+            config = new Hashtable<String, Object>();
         }
 
         configuration = config;
@@ -825,7 +820,7 @@ public class OsgiManager extends Generic
 
         // get enabled plugins
         String[] plugins = ConfigurationUtil.getStringArrayProperty(config, PROP_ENABLED_PLUGINS);
-        enabledPlugins = null == plugins ? null : new HashSet(Arrays.asList(plugins));
+        enabledPlugins = null == plugins ? null : new HashSet<String>(Arrays.asList(plugins));
         initInternalPlugins();
 
         // might update HTTP service registration
@@ -891,36 +886,41 @@ public class OsgiManager extends Generic
         return enabledPlugins != null && !enabledPlugins.contains(pluginClass);
     }
 
-    private Dictionary toStringConfig(Dictionary config)
+    private Dictionary<String, String> toStringConfig(Dictionary<String, ?> config)
     {
-        Dictionary stringConfig = new Hashtable();
-        for (Enumeration ke = config.keys(); ke.hasMoreElements();)
+        Dictionary<String, String> stringConfig = new Hashtable<String, String>();
+        for (Enumeration<String> ke = config.keys(); ke.hasMoreElements();)
         {
-            Object key = ke.nextElement();
-            stringConfig.put(key.toString(), String.valueOf(config.get(key)));
+            String key = ke.nextElement();
+            stringConfig.put(key, String.valueOf(config.get(key)));
         }
         return stringConfig;
     }
 
-    private Map langMap;
+    private Map<String, String> langMap;
 
-    private final Map getLangMap()
+
+    private final Map<String, String> getLangMap()
     {
-        if (null != langMap)
+        if ( null != langMap )
+        {
             return langMap;
-        final Map map = new HashMap();
+        }
+
+        final Map<String, String> map = new HashMap<String, String>();
         final Bundle bundle = bundleContext.getBundle();
-        final Enumeration e = bundle.findEntries("res/flags", null, false); //$NON-NLS-1$
-        while (e != null && e.hasMoreElements())
+        @SuppressWarnings("unchecked")
+        final Enumeration<URL> e = bundle.findEntries( "res/flags", null, false );
//$NON-NLS-1$
+        while ( e != null && e.hasMoreElements() )
         {
-            final URL img = (URL) e.nextElement();
-            final String name = FilenameUtils.getBaseName(img.getFile());
+            final URL img = e.nextElement();
+            final String name = FilenameUtils.getBaseName( img.getFile() );
             try
             {
-                final String locale = new Locale(name, "").getDisplayLanguage(); //$NON-NLS-1$
-                map.put(name, null != locale ? locale : name);
+                final String locale = new Locale( name, "" ).getDisplayLanguage(); //$NON-NLS-1$
+                map.put( name, null != locale ? locale : name );
             }
-            catch (Throwable t)
+            catch ( Throwable t )
             {
                 t.printStackTrace();
                 /* ignore invalid locale? */

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/PluginHolder.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/PluginHolder.java?rev=1215540&r1=1215539&r2=1215540&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/PluginHolder.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/PluginHolder.java
Sat Dec 17 18:11:16 2011
@@ -57,7 +57,7 @@ class PluginHolder implements ServiceLis
     private final BundleContext bundleContext;
 
     // registered plugins (Map<String label, Plugin plugin>)
-    private final Map plugins;
+    private final Map<String, Plugin> plugins;
 
     // The servlet context used to initialize plugin services
     private ServletContext servletContext;
@@ -69,7 +69,7 @@ class PluginHolder implements ServiceLis
     PluginHolder( final BundleContext context )
     {
         this.bundleContext = context;
-        this.plugins = new HashMap();
+        this.plugins = new HashMap<String, Plugin>();
     }
 
 
@@ -197,7 +197,7 @@ class PluginHolder implements ServiceLis
             final Plugin plugin;
             synchronized ( plugins )
             {
-                plugin = ( Plugin ) plugins.get( label );
+                plugin = plugins.get( label );
             }
 
             if ( plugin != null )
@@ -232,9 +232,9 @@ class PluginHolder implements ServiceLis
      *
      * @return The localized map of labels to titles
      */
-    Map getLocalizedLabelMap( final ResourceBundleManager resourceBundleManager, final Locale
locale )
+    Map<String, String> getLocalizedLabelMap( final ResourceBundleManager resourceBundleManager,
final Locale locale )
     {
-        final Map map = new HashMap();
+        final Map<String, String> map = new HashMap<String, String>();
         Plugin[] plugins = getPlugins();
         for ( int i = 0; i < plugins.length; i++ )
         {
@@ -386,7 +386,7 @@ class PluginHolder implements ServiceLis
         final Plugin oldPlugin;
         synchronized ( plugins )
         {
-            oldPlugin = ( Plugin ) plugins.remove( label );
+            oldPlugin = plugins.remove( label );
         }
 
         if ( oldPlugin != null )
@@ -400,7 +400,7 @@ class PluginHolder implements ServiceLis
     {
         synchronized ( plugins )
         {
-            return ( Plugin[] ) plugins.values().toArray( new Plugin[plugins.size()] );
+            return plugins.values().toArray( new Plugin[plugins.size()] );
         }
     }
 
@@ -562,7 +562,7 @@ class PluginHolder implements ServiceLis
         }
 
 
-        protected void doUngetConsolePlugin( AbstractWebConsolePlugin consolePlugin )
+        protected void doUngetConsolePlugin( @SuppressWarnings("unused") AbstractWebConsolePlugin
consolePlugin )
         {
         }
 
@@ -575,9 +575,9 @@ class PluginHolder implements ServiceLis
         }
 
 
-        public Enumeration getInitParameterNames()
+        public Enumeration<String> getInitParameterNames()
         {
-            return new Enumeration()
+            return new Enumeration<String>()
             {
                 public boolean hasMoreElements()
                 {
@@ -585,7 +585,7 @@ class PluginHolder implements ServiceLis
                 }
 
 
-                public Object nextElement()
+                public String nextElement()
                 {
                     throw new NoSuchElementException();
                 }
@@ -643,22 +643,6 @@ class PluginHolder implements ServiceLis
             return super.doGetTitle();
         }
 
-        /**
-         * If the plugin is registered as a regular OSGi service, this method
-         * behaves the same as {@link #dispose()}. If the plugin is built
-         * into the web console, this method does nothing.
-         * <p>
-         * After this method is called, the plugin may still be used because
-         * the {@link #getConsolePlugin()} method will re-acquire the service
-         * again on-demand.
-         */
-        final void ungetService()
-        {
-            // FIXME: this method is used by nobody!?!?
-            dispose();
-        }
-
-
         protected AbstractWebConsolePlugin doGetConsolePlugin()
         {
             Object service = getHolder().getBundleContext().getService( serviceReference
);
@@ -698,10 +682,10 @@ class PluginHolder implements ServiceLis
         }
 
 
-        public Enumeration getInitParameterNames()
+        public Enumeration<String> getInitParameterNames()
         {
             final String[] keys = serviceReference.getPropertyKeys();
-            return new Enumeration()
+            return new Enumeration<String>()
             {
                 int idx = 0;
 
@@ -712,7 +696,7 @@ class PluginHolder implements ServiceLis
                 }
 
 
-                public Object nextElement()
+                public String nextElement()
                 {
                     if ( hasMoreElements() )
                     {
@@ -760,7 +744,7 @@ class PluginHolder implements ServiceLis
 
                 try
                 {
-                    Class pluginClass = getClass().getClassLoader().loadClass(pluginClassName);
+                    Class<?> pluginClass = getClass().getClassLoader().loadClass(pluginClassName);
                     plugin = (AbstractWebConsolePlugin) pluginClass.newInstance();
 
                     if (plugin instanceof OsgiManagerPlugin)

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java?rev=1215540&r1=1215539&r2=1215540&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
Sat Dec 17 18:11:16 2011
@@ -43,6 +43,7 @@ import org.osgi.service.startlevel.Start
  * VMStatPlugin provides the System Information tab. This particular plugin uses
  * more than one templates.
  */
+@SuppressWarnings("serial")
 public class VMStatPlugin extends SimpleWebConsolePlugin implements OsgiManagerPlugin
 {
 
@@ -166,8 +167,7 @@ public class VMStatPlugin extends Simple
     /**
      * @see org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse)
      */
-    protected void renderContent( HttpServletRequest request, HttpServletResponse response
) throws ServletException,
-        IOException
+    protected void renderContent( HttpServletRequest request, HttpServletResponse response
) throws IOException
     {
         String body;
 

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/package-info.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/package-info.java?rev=1215540&r1=1215539&r2=1215540&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/package-info.java (original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/package-info.java Sat
Dec 17 18:11:16 2011
@@ -30,7 +30,7 @@
  * <dd>Service API to provide custom authentication and access control.</dd>
  * </dl>
  */
-@Version("3.1.2")
+@Version("3.1.4")
 @Export(optional = "provide:=true")
 package org.apache.felix.webconsole;
 

Modified: felix/trunk/webconsole/src/test/java/org/apache/felix/webconsole/AbstractWebConsolePluginTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/test/java/org/apache/felix/webconsole/AbstractWebConsolePluginTest.java?rev=1215540&r1=1215539&r2=1215540&view=diff
==============================================================================
--- felix/trunk/webconsole/src/test/java/org/apache/felix/webconsole/AbstractWebConsolePluginTest.java
(original)
+++ felix/trunk/webconsole/src/test/java/org/apache/felix/webconsole/AbstractWebConsolePluginTest.java
Sat Dec 17 18:11:16 2011
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletRes
 import junit.framework.TestCase;
 
 
+@SuppressWarnings("serial")
 public class AbstractWebConsolePluginTest extends TestCase
 {
 
@@ -38,7 +39,8 @@ public class AbstractWebConsolePluginTes
     {
         super.setUp();
 
-        getGetResourceMethod = AbstractWebConsolePlugin.class.getDeclaredMethod( "getGetResourceMethod",
null );
+        getGetResourceMethod = AbstractWebConsolePlugin.class.getDeclaredMethod( "getGetResourceMethod",
+            ( Class<?>[] ) null );
         getGetResourceMethod.setAccessible( true );
     }
 
@@ -55,12 +57,12 @@ public class AbstractWebConsolePluginTes
             }
         };
         assertNull( test.getResourceProvider() );
-        assertNull( getGetResourceMethod.invoke( test, null ) );
+        assertNull( getGetResourceMethod.invoke( test, (Object[]) null ) );
 
         // test with default resource provider but no method
         final TestPlugin test2 = new TestPlugin();
         assertEquals( test2, test2.getResourceProvider() );
-        assertNull( getGetResourceMethod.invoke( test2, null ) );
+        assertNull( getGetResourceMethod.invoke( test2, (Object[]) null ) );
     }
 
 
@@ -69,22 +71,22 @@ public class AbstractWebConsolePluginTes
         // test with default resource provider, public method
         final TestPlugin testPublic = new PublicTestPlugin();
         assertEquals( testPublic, testPublic.getResourceProvider() );
-        assertNotNull( getGetResourceMethod.invoke( testPublic, null ) );
+        assertNotNull( getGetResourceMethod.invoke( testPublic, (Object[]) null ) );
 
         // test with default resource provider, package private method
         final TestPlugin testDefault = new PackageTestPlugin();
         assertEquals( testDefault, testDefault.getResourceProvider() );
-        assertNull( getGetResourceMethod.invoke( testDefault, null ) );
+        assertNull( getGetResourceMethod.invoke( testDefault, (Object[]) null ) );
 
         // test with default resource provider, protected method
         final TestPlugin testProtected = new ProtectedTestPlugin();
         assertEquals( testProtected, testProtected.getResourceProvider() );
-        assertNotNull( getGetResourceMethod.invoke( testProtected, null ) );
+        assertNotNull( getGetResourceMethod.invoke( testProtected, (Object[]) null ) );
 
         // test with default resource provider, private method
         final TestPlugin testPrivate = new PrivateTestPlugin();
         assertEquals( testPrivate, testPrivate.getResourceProvider() );
-        assertNotNull( getGetResourceMethod.invoke( testPrivate, null ) );
+        assertNotNull( getGetResourceMethod.invoke( testPrivate, (Object[]) null ) );
     }
 
 
@@ -95,32 +97,33 @@ public class AbstractWebConsolePluginTes
         {
         };
         assertEquals( testPublic, testPublic.getResourceProvider() );
-        assertNotNull( getGetResourceMethod.invoke( testPublic, null ) );
+        assertNotNull( getGetResourceMethod.invoke( testPublic, (Object[]) null ) );
 
         // test with default resource provider, package private method
         final TestPlugin testDefault = new PackageTestPlugin()
         {
         };
         assertEquals( testDefault, testDefault.getResourceProvider() );
-        assertNull( getGetResourceMethod.invoke( testDefault, null ) );
+        assertNull( getGetResourceMethod.invoke( testDefault, (Object[]) null ) );
 
         // test with default resource provider, protected method
         final TestPlugin testProtected = new ProtectedTestPlugin()
         {
         };
         assertEquals( testProtected, testProtected.getResourceProvider() );
-        assertNotNull( getGetResourceMethod.invoke( testProtected, null ) );
+        assertNotNull( getGetResourceMethod.invoke( testProtected, (Object[]) null ) );
 
         // test with default resource provider, private method
         final TestPlugin testPrivate = new PrivateTestPlugin()
         {
         };
         assertEquals( testPrivate, testPrivate.getResourceProvider() );
-        assertNull( getGetResourceMethod.invoke( testPrivate, null ) );
+        assertNull( getGetResourceMethod.invoke( testPrivate, (Object[]) null ) );
     }
 
     private static class PrivateTestPlugin extends TestPlugin
     {
+        @SuppressWarnings("unused")
         private URL getResource( String name )
         {
             return null;
@@ -129,6 +132,7 @@ public class AbstractWebConsolePluginTes
 
     private static class ProtectedTestPlugin extends TestPlugin
     {
+        @SuppressWarnings("unused")
         protected URL getResource( String name )
         {
             return null;
@@ -137,6 +141,7 @@ public class AbstractWebConsolePluginTes
 
     private static class PackageTestPlugin extends TestPlugin
     {
+        @SuppressWarnings("unused")
         URL getResource( String name )
         {
             return null;
@@ -145,6 +150,7 @@ public class AbstractWebConsolePluginTes
 
     private static class PublicTestPlugin extends TestPlugin
     {
+        @SuppressWarnings("unused")
         public URL getResource( String name )
         {
             return null;



Mime
View raw message