felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1468913 - in /felix/trunk/inventory: ./ src/main/java/org/apache/felix/inventory/impl/ src/main/java/org/apache/felix/inventory/impl/webconsole/
Date Wed, 17 Apr 2013 13:52:44 GMT
Author: fmeschbe
Date: Wed Apr 17 13:52:43 2013
New Revision: 1468913

URL: http://svn.apache.org/r1468913
Log:
FELIX-4026 Ensure Java 1.4 API use and class files

- generate 1.4 class files
- check Java 1.4 API use
- Resolve current non-Java 1.4 API use

Modified:
    felix/trunk/inventory/pom.xml
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java

Modified: felix/trunk/inventory/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/pom.xml?rev=1468913&r1=1468912&r2=1468913&view=diff
==============================================================================
--- felix/trunk/inventory/pom.xml (original)
+++ felix/trunk/inventory/pom.xml Wed Apr 17 13:52:43 2013
@@ -41,6 +41,44 @@
 
     <build>
         <plugins>
+            <!-- Make sure to not use non Java 1.4 API -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.4</source>
+                    <target>1.4</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>animal-sniffer-maven-plugin</artifactId>
+                <version>1.7</version>
+                <configuration>
+                    <signature>
+                        <groupId>org.codehaus.mojo.signature</groupId>
+                        <artifactId>java14</artifactId>
+                        <version>1.0</version>
+                    </signature>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        
+            <plugin>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <excludePackageNames>
+                        *.impl
+                    </excludePackageNames>
+                </configuration>
+            </plugin>
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java?rev=1468913&r1=1468912&r2=1468913&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java
(original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java
Wed Apr 17 13:52:43 2013
@@ -157,24 +157,28 @@ public class InventoryPrinterAdapter imp
         }
     }
 
-    /**
-     * @see java.lang.Object#toString()
-     */
-    public String toString()
+    public InventoryPrinterDescription getDescription()
     {
-        return printer.getClass() + "(" + super.toString() + ")";
+        return this.description;
     }
 
-    /**
-     * @see java.lang.Comparable#compareTo(java.lang.Object)
-     */
     public int compareTo(final Object spa)
     {
         return this.description.getSortKey().compareTo(((InventoryPrinterAdapter) spa).description.getSortKey());
     }
 
-    public InventoryPrinterDescription getDescription()
+    public int hashCode()
     {
-        return this.description;
+        return this.description.getSortKey().hashCode();
+    }
+
+    public boolean equals(final Object spa)
+    {
+        return this.description.getSortKey().equals(((InventoryPrinterAdapter) spa).description.getSortKey());
+    }
+
+    public String toString()
+    {
+        return printer.getClass() + "(" + super.toString() + ")";
     }
 }

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java?rev=1468913&r1=1468912&r2=1468913&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java
(original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java
Wed Apr 17 13:52:43 2013
@@ -163,7 +163,7 @@ public class InventoryPrinterDescription
 
     public String toString()
     {
-        return "InventoryPrinterDescription [title=" + title + ", name=" + name + ", formats="
+ Arrays.toString(formats)
+        return "InventoryPrinterDescription [title=" + title + ", name=" + name + ", formats="
+ Arrays.asList(formats)
             + ", sortKey=" + sortKey + "]";
     }
 }

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java?rev=1468913&r1=1468912&r2=1468913&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
(original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
Wed Apr 17 13:52:43 2013
@@ -27,8 +27,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
-import java.util.concurrent.ConcurrentSkipListSet;
-
+import java.util.TreeSet;
 import org.apache.felix.inventory.InventoryPrinter;
 import org.apache.felix.inventory.Format;
 import org.apache.felix.inventory.impl.webconsole.ConsoleConstants;
@@ -62,7 +61,7 @@ public class InventoryPrinterManagerImpl
     private final Map allAdapters = new HashMap();
 
     /** Used adapters. Type of the set: InventoryPrinterAdapter */
-    private final Set usedAdapters = new ConcurrentSkipListSet();
+    private final Set usedAdapters = new TreeSet();
 
     /** Registration for the web console. */
     private final ServiceRegistration pluginRegistration;
@@ -112,7 +111,10 @@ public class InventoryPrinterManagerImpl
         {
             this.allAdapters.clear();
         }
-        this.usedAdapters.clear();
+        synchronized (this.usedAdapters)
+        {
+            this.usedAdapters.clear();
+        }
     }
 
     /**
@@ -191,20 +193,18 @@ public class InventoryPrinterManagerImpl
         }
         if (removeAdapter != null)
         {
-            final Iterator i = this.usedAdapters.iterator();
-            while (i.hasNext())
+            removeAdapter.unregisterConsole();
+            synchronized (this.usedAdapters)
             {
-                if (i.next() == removeAdapter)
-                {
-                    i.remove();
-                    break;
-                }
+                this.usedAdapters.remove(removeAdapter);
             }
-            removeAdapter.unregisterConsole();
         }
         if (addAdapter != null)
         {
-            this.usedAdapters.add(addAdapter);
+            synchronized (this.usedAdapters)
+            {
+                this.usedAdapters.add(addAdapter);
+            }
             addAdapter.registerConsole(this.bundleContext, this);
         }
     }
@@ -222,7 +222,7 @@ public class InventoryPrinterManagerImpl
                 while (iter.hasNext())
                 {
                     final InventoryPrinterAdapter adapter = (InventoryPrinterAdapter) iter.next();
-                    if (adapter.getDescription().getServiceReference().compareTo(reference)
== 0)
+                    if (adapter.getDescription().getServiceReference().equals(reference))
                     {
                         iter.remove();
                         removed = true;
@@ -239,17 +239,26 @@ public class InventoryPrinterManagerImpl
                 }
             }
         }
-        final Iterator iter = this.usedAdapters.iterator();
-        while (iter.hasNext())
+
+        InventoryPrinterAdapter adapterToUnregister = null;
+        synchronized (this.usedAdapters)
         {
-            final InventoryPrinterAdapter adapter = (InventoryPrinterAdapter) iter.next();
-            if (adapter.getDescription().getServiceReference().compareTo(reference) == 0)
+            final Iterator iter = this.usedAdapters.iterator();
+            while (iter.hasNext())
             {
-                iter.remove();
-                adapter.unregisterConsole();
-                break;
+                final InventoryPrinterAdapter adapter = (InventoryPrinterAdapter) iter.next();
+                if (adapter.getDescription().getServiceReference().equals(reference))
+                {
+                    iter.remove();
+                    adapterToUnregister = adapter;
+                    break;
+                }
             }
         }
+        if (adapterToUnregister != null)
+        {
+            adapterToUnregister.unregisterConsole();
+        }
     }
 
     /**
@@ -259,8 +268,11 @@ public class InventoryPrinterManagerImpl
      */
     public InventoryPrinterHandler[] getAllHandlers()
     {
-        return (InventoryPrinterHandler[]) this.usedAdapters.toArray(new InventoryPrinterHandler[this.usedAdapters
-            .size()]);
+        synchronized (this.usedAdapters)
+        {
+            return (InventoryPrinterHandler[]) this.usedAdapters.toArray(new InventoryPrinterHandler[this.usedAdapters
+                .size()]);
+        }
     }
 
     /**
@@ -271,13 +283,16 @@ public class InventoryPrinterManagerImpl
     public InventoryPrinterHandler[] getHandlers(final Format format)
     {
         final List result = new ArrayList();
-        final Iterator i = this.usedAdapters.iterator();
-        while (i.hasNext())
+        synchronized (this.usedAdapters)
         {
-            final InventoryPrinterAdapter printer = (InventoryPrinterAdapter) i.next();
-            if (printer.supports(format))
+            final Iterator i = this.usedAdapters.iterator();
+            while (i.hasNext())
             {
-                result.add(printer);
+                final InventoryPrinterAdapter printer = (InventoryPrinterAdapter) i.next();
+                if (printer.supports(format))
+                {
+                    result.add(printer);
+                }
             }
         }
         return (InventoryPrinterHandler[]) result.toArray(new InventoryPrinterHandler[result.size()]);
@@ -290,13 +305,16 @@ public class InventoryPrinterManagerImpl
      */
     public InventoryPrinterHandler getHandler(final String name)
     {
-        final Iterator i = this.usedAdapters.iterator();
-        while (i.hasNext())
+        synchronized (this.usedAdapters)
         {
-            final InventoryPrinterAdapter printer = (InventoryPrinterAdapter) i.next();
-            if (name.equals(printer.getName()))
+            final Iterator i = this.usedAdapters.iterator();
+            while (i.hasNext())
             {
-                return printer;
+                final InventoryPrinterAdapter printer = (InventoryPrinterAdapter) i.next();
+                if (name.equals(printer.getName()))
+                {
+                    return printer;
+                }
             }
         }
         return null;

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java?rev=1468913&r1=1468912&r2=1468913&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java
(original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java
Wed Apr 17 13:52:43 2013
@@ -96,16 +96,22 @@ public class WebConsoleAdapter implement
         {
             if (cpa.title.startsWith("%"))
             {
-                final String key = cpa.title.substring(1);
+                String title = cpa.title.substring(1);
+
                 final ResourceBundle rb = this.rbManager.getResourceBundle(reference.getBundle());
-                if (rb == null || !rb.containsKey(key))
-                {
-                    cpa.title = key;
-                }
-                else
+                if (rb != null)
                 {
-                    cpa.title = rb.getString(key);
+                    try
+                    {
+                        title = rb.getString(title);
+                    }
+                    catch (Exception e)
+                    {
+                        // ClassCastException, MissingResourceException
+                        // ignore
+                    }
                 }
+                cpa.title = title;
             }
             if (cpa.label == null)
             {



Mime
View raw message