ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1718462 - /webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/
Date Mon, 07 Dec 2015 20:54:25 GMT
Author: veithen
Date: Mon Dec  7 20:54:25 2015
New Revision: 1718462

URL: http://svn.apache.org/viewvc?rev=1718462&view=rev
Log:
Use generics for some internal APIs and their implementations.

Modified:
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/DefaultLoader.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/DefaultOMMetaFactoryLocator.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/ImplementationFactory.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/Loader.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiLoader.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiOMMetaFactoryLocator.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/PriorityBasedOMMetaFactoryLocator.java

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/DefaultLoader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/DefaultLoader.java?rev=1718462&r1=1718461&r2=1718462&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/DefaultLoader.java
(original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/DefaultLoader.java
Mon Dec  7 20:54:25 2015
@@ -25,7 +25,7 @@ final class DefaultLoader extends Loader
         this.classLoader = classLoader;
     }
 
-    Class load(String className) throws ClassNotFoundException {
+    Class<?> load(String className) throws ClassNotFoundException {
         return classLoader.loadClass(className);
     }
 }

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/DefaultOMMetaFactoryLocator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/DefaultOMMetaFactoryLocator.java?rev=1718462&r1=1718461&r2=1718462&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/DefaultOMMetaFactoryLocator.java
(original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/DefaultOMMetaFactoryLocator.java
Mon Dec  7 20:54:25 2015
@@ -40,7 +40,7 @@ public final class DefaultOMMetaFactoryL
         
         Loader loader = new DefaultLoader(classLoader);
         
-        List/*<Implementation>*/ implementations = new ArrayList();
+        List<Implementation> implementations = new ArrayList<Implementation>();
         
         // If a meta factory is specified using the system property, we register it as an
         // implementation with feature "default" and maximum priority, so that it will always
@@ -68,7 +68,7 @@ public final class DefaultOMMetaFactoryL
 
         // Now discover the available implementations by looking for the axiom.xml descriptor.
         log.debug("Starting class path based discovery");
-        Enumeration e;
+        Enumeration<URL> e;
         try {
             e = classLoader.getResources(ImplementationFactory.DESCRIPTOR_RESOURCE);
         } catch (IOException ex) {
@@ -77,7 +77,7 @@ public final class DefaultOMMetaFactoryL
         }
         if (e != null) {
             while (e.hasMoreElements()) {
-                implementations.addAll(ImplementationFactory.parseDescriptor(loader, (URL)e.nextElement()));
+                implementations.addAll(ImplementationFactory.parseDescriptor(loader, e.nextElement()));
             }
         }
         

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/ImplementationFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/ImplementationFactory.java?rev=1718462&r1=1718461&r2=1718462&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/ImplementationFactory.java
(original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/ImplementationFactory.java
Mon Dec  7 20:54:25 2015
@@ -58,7 +58,7 @@ final class ImplementationFactory {
     }
     
     private static Object load(Loader loader, String className) {
-        Class clazz;
+        Class<?> clazz;
         try {
             clazz = loader.load(className);
         } catch (ClassNotFoundException ex) {
@@ -73,11 +73,11 @@ final class ImplementationFactory {
         }
     }
     
-    static List/*<Implementation>*/ parseDescriptor(Loader loader, URL url) {
+    static List<Implementation> parseDescriptor(Loader loader, URL url) {
         if (log.isDebugEnabled()) {
             log.debug("Loading " + url);
         }
-        List implementations = new ArrayList();
+        List<Implementation> implementations = new ArrayList<Implementation>();
         try {
             // Since this code is used to discover Axiom implementations, we have to use
DOM here.
             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
@@ -134,7 +134,7 @@ final class ImplementationFactory {
         if (metaFactory == null) {
             return null;
         }
-        List/*<Feature>*/ features = new ArrayList();
+        List<Feature> features = new ArrayList<Feature>();
         Node child = implementation.getFirstChild();
         while (child != null) {
             if (child instanceof Element) {
@@ -151,7 +151,7 @@ final class ImplementationFactory {
             }
             child = child.getNextSibling();
         }
-        return new Implementation(name, metaFactory, (Feature[])features.toArray(new Feature[features.size()]));
+        return new Implementation(name, metaFactory, features.toArray(new Feature[features.size()]));
     }
 
     private static Feature parseFeature(Element feature) {

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/Loader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/Loader.java?rev=1718462&r1=1718461&r2=1718462&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/Loader.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/Loader.java Mon
Dec  7 20:54:25 2015
@@ -19,5 +19,5 @@
 package org.apache.axiom.locator;
 
 abstract class Loader {
-    abstract Class load(String className) throws ClassNotFoundException;
+    abstract Class<?> load(String className) throws ClassNotFoundException;
 }

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiLoader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiLoader.java?rev=1718462&r1=1718461&r2=1718462&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiLoader.java
(original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiLoader.java
Mon Dec  7 20:54:25 2015
@@ -27,7 +27,7 @@ final class OSGiLoader extends Loader {
         this.bundle = bundle;
     }
 
-    Class load(String className) throws ClassNotFoundException {
+    Class<?> load(String className) throws ClassNotFoundException {
         return bundle.loadClass(className);
     }
 }

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiOMMetaFactoryLocator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiOMMetaFactoryLocator.java?rev=1718462&r1=1718461&r2=1718462&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiOMMetaFactoryLocator.java
(original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiOMMetaFactoryLocator.java
Mon Dec  7 20:54:25 2015
@@ -21,7 +21,6 @@ package org.apache.axiom.locator;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.axiom.om.OMMetaFactory;
@@ -34,7 +33,7 @@ import org.osgi.util.tracker.BundleTrack
 
 final class OSGiOMMetaFactoryLocator extends PriorityBasedOMMetaFactoryLocator implements
BundleTrackerCustomizer {
     private final BundleContext apiBundleContext;
-    private final List/*<Implementation>*/ implementations = new ArrayList();
+    private final List<Implementation> implementations = new ArrayList<Implementation>();
     
     OSGiOMMetaFactoryLocator(BundleContext apiBundleContext) {
         this.apiBundleContext = apiBundleContext;
@@ -48,15 +47,14 @@ final class OSGiOMMetaFactoryLocator ext
     public Object addingBundle(Bundle bundle, BundleEvent event) {
         URL descriptorUrl = bundle.getEntry(ImplementationFactory.DESCRIPTOR_RESOURCE);
         if (descriptorUrl != null) {
-            List/*<Implementation>*/ discoveredImplementations = ImplementationFactory.parseDescriptor(new
OSGiLoader(bundle), descriptorUrl);
-            List/*<RegisteredImplementation>*/ registeredImplementations = new ArrayList(discoveredImplementations.size());
+            List<Implementation> discoveredImplementations = ImplementationFactory.parseDescriptor(new
OSGiLoader(bundle), descriptorUrl);
+            List<RegisteredImplementation> registeredImplementations = new ArrayList<RegisteredImplementation>(discoveredImplementations.size());
             synchronized (this) {
                 implementations.addAll(discoveredImplementations);
                 loadImplementations(implementations);
             }
-            for (Iterator it = discoveredImplementations.iterator(); it.hasNext(); ) {
-                Implementation implementation = (Implementation)it.next();
-                Hashtable properties = new Hashtable();
+            for (Implementation implementation : discoveredImplementations) {
+                Hashtable<String,String> properties = new Hashtable<String,String>();
                 properties.put("implementationName", implementation.getName());
                 // TODO: we should add the features and priorities to the properties as well
                 ServiceRegistration registration = bundle.getBundleContext().registerService(OMMetaFactory.class.getName(),
implementation.getMetaFactory(), properties);
@@ -75,8 +73,7 @@ final class OSGiOMMetaFactoryLocator ext
     }
 
     public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
-        for (Iterator it = ((List)object).iterator(); it.hasNext(); ) {
-            RegisteredImplementation registeredImplementation = (RegisteredImplementation)it.next();
+        for (RegisteredImplementation registeredImplementation : ((List<RegisteredImplementation>)object))
{
             apiBundleContext.ungetService(registeredImplementation.getReference());
             registeredImplementation.getRegistration().unregister();
             synchronized (this) {

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/PriorityBasedOMMetaFactoryLocator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/PriorityBasedOMMetaFactoryLocator.java?rev=1718462&r1=1718461&r2=1718462&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/PriorityBasedOMMetaFactoryLocator.java
(original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/PriorityBasedOMMetaFactoryLocator.java
Mon Dec  7 20:54:25 2015
@@ -19,7 +19,6 @@
 package org.apache.axiom.locator;
 
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -31,13 +30,12 @@ import org.apache.commons.logging.LogFac
 class PriorityBasedOMMetaFactoryLocator implements OMMetaFactoryLocator {
     private static final Log log = LogFactory.getLog(PriorityBasedOMMetaFactoryLocator.class);
     
-    private final Map/*<String,OMMetaFactory>*/ factories = new HashMap();
+    private final Map<String,OMMetaFactory> factories = new HashMap<String,OMMetaFactory>();
     
-    void loadImplementations(List/*<Implementation>*/ implementations) {
-        Map/*<String,Integer>*/ priorityMap = new HashMap();
+    void loadImplementations(List<Implementation> implementations) {
+        Map<String,Integer> priorityMap = new HashMap<String,Integer>();
         factories.clear();
-        for (Iterator it = implementations.iterator(); it.hasNext(); ) {
-            Implementation implementation = (Implementation)it.next();
+        for (Implementation implementation : implementations) {
             Feature[] features = implementation.getFeatures();
             for (int i=0; i<features.length; i++) {
                 Feature feature = features[i];
@@ -52,8 +50,7 @@ class PriorityBasedOMMetaFactoryLocator
         }
         if (log.isDebugEnabled()) {
             StringBuilder buffer = new StringBuilder("Meta factories:");
-            for (Iterator it = factories.entrySet().iterator(); it.hasNext(); ) {
-                Map.Entry entry = (Map.Entry)it.next();
+            for (Map.Entry<String,OMMetaFactory> entry : factories.entrySet()) {
                 buffer.append("\n  ");
                 buffer.append(entry.getKey());
                 buffer.append(": ");



Mime
View raw message