You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2014/11/01 10:55:57 UTC

svn commit: r1635910 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion: CollectionConverters.java Converters.java GenericSingletonToList.java GenericSingletonToSet.java test/MiscTests.java

Author: adrianc
Date: Sat Nov  1 09:55:57 2014
New Revision: 1635910

URL: http://svn.apache.org/r1635910
Log:
Finish removing Javolution from the base component.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToList.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToSet.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java?rev=1635910&r1=1635909&r2=1635910&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java Sat Nov  1 09:55:57 2014
@@ -20,13 +20,12 @@ package org.ofbiz.base.conversion;
 
 import java.lang.reflect.Array;
 import java.util.Arrays;
+import java.util.HashSet;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import javolution.util.FastList;
-import javolution.util.FastSet;
-
 import org.ofbiz.base.util.StringUtil;
 import org.ofbiz.base.util.UtilGenerics;
 
@@ -62,7 +61,7 @@ public class CollectionConverters implem
         }
 
         public T convert(S obj) throws ConversionException {
-            List<Object> list = FastList.newInstance();
+            List<Object> list = new LinkedList<Object>();
             int len = Array.getLength(obj);
             for (int i = 0; i < len; i++) {
                 list.add(Array.get(obj, i));
@@ -111,7 +110,7 @@ public class CollectionConverters implem
         }
 
         public List<Map<K, V>> convert(Map<K, V> obj) throws ConversionException {
-            List<Map<K, V>> tempList = FastList.newInstance();
+            List<Map<K, V>> tempList = new LinkedList<Map<K, V>>();
             tempList.add(obj);
             return tempList;
         }
@@ -123,7 +122,7 @@ public class CollectionConverters implem
         }
 
         public Set<Map<K, V>> convert(Map<K, V> obj) throws ConversionException {
-            Set<Map<K, V>> tempSet = FastSet.newInstance();
+            Set<Map<K, V>> tempSet = new HashSet<Map<K, V>>();
             tempSet.add(obj);
             return tempSet;
         }

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java?rev=1635910&r1=1635909&r2=1635910&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java Sat Nov  1 09:55:57 2014
@@ -19,11 +19,11 @@
 package org.ofbiz.base.conversion;
 
 import java.lang.reflect.Modifier;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.ServiceLoader;
-
-import javolution.util.FastMap;
-import javolution.util.FastSet;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.ofbiz.base.lang.SourceMonitored;
 import org.ofbiz.base.util.Debug;
@@ -35,12 +35,11 @@ import org.ofbiz.base.util.UtilGenerics;
 public class Converters {
     protected static final String module = Converters.class.getName();
     protected static final String DELIMITER = "->";
-    protected static final FastMap<String, Converter<?, ?>> converterMap = FastMap.newInstance();
-    protected static final FastSet<ConverterCreator> creators = FastSet.newInstance();
-    protected static final FastSet<String> noConversions = FastSet.newInstance();
+    protected static final ConcurrentHashMap<String, Converter<?, ?>> converterMap = new ConcurrentHashMap<String, Converter<?, ?>>();
+    protected static final Set<ConverterCreator> creators = new HashSet<ConverterCreator>();
+    protected static final Set<String> noConversions = new HashSet<String>();
 
     static {
-        converterMap.setShared(true);
         registerCreator(new PassThruConverterCreator());
         ClassLoader loader = Thread.currentThread().getContextClassLoader();
         Iterator<ConverterLoader> converterLoaders = ServiceLoader.load(ConverterLoader.class, loader).iterator();
@@ -110,7 +109,11 @@ OUTER:
                     continue OUTER;
                 }
             }
-            if (noConversions.add(key)) {
+            boolean addedToSet = false;
+            synchronized (noConversions) {
+                addedToSet = noConversions.add(key);
+            }
+            if (addedToSet) {
                 Debug.logWarning("*** No converter found, converting from " +
                         sourceClass.getName() + " to " + targetClass.getName() +
                         ". Please report this message to the developer community so " +
@@ -163,7 +166,9 @@ OUTER:
      * @param creator The <code>ConverterCreater</code> instance to register
      */
     public static <S, T> void registerCreator(ConverterCreator creator) {
-        creators.add(creator);
+        synchronized (creators) {
+            creators.add(creator);
+        }
     }
 
     /** Registers a <code>Converter</code> instance to be used by the

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToList.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToList.java?rev=1635910&r1=1635909&r2=1635910&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToList.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToList.java Sat Nov  1 09:55:57 2014
@@ -18,17 +18,16 @@
  *******************************************************************************/
 package org.ofbiz.base.conversion;
 
+import java.util.LinkedList;
 import java.util.List;
 
-import javolution.util.FastList;
-
 public class GenericSingletonToList<T> extends AbstractConverter<T, List<T>> {
     public GenericSingletonToList(Class<T> sourceClass) {
         super(sourceClass, List.class);
     }
 
     public List<T> convert(T obj) throws ConversionException {
-        List<T> tempList = FastList.newInstance();
+        List<T> tempList = new LinkedList<T>();
         tempList.add(obj);
         return tempList;
     }

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToSet.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToSet.java?rev=1635910&r1=1635909&r2=1635910&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToSet.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToSet.java Sat Nov  1 09:55:57 2014
@@ -18,17 +18,16 @@
  *******************************************************************************/
 package org.ofbiz.base.conversion;
 
+import java.util.HashSet;
 import java.util.Set;
 
-import javolution.util.FastSet;
-
 public class GenericSingletonToSet<T> extends AbstractConverter<T, Set<T>> {
     public GenericSingletonToSet(Class<T> sourceClass) {
         super(sourceClass, Set.class);
     }
 
     public Set<T> convert(T obj) throws ConversionException {
-        Set<T> tempSet = FastSet.newInstance();
+        Set<T> tempSet = new HashSet<T>();
         tempSet.add(obj);
         return tempSet;
     }

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java?rev=1635910&r1=1635909&r2=1635910&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java Sat Nov  1 09:55:57 2014
@@ -22,12 +22,10 @@ import java.math.BigDecimal;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
-import javolution.util.FastList;
-import javolution.util.FastMap;
-
 import org.ofbiz.base.conversion.Converter;
 import org.ofbiz.base.conversion.ConverterLoader;
 import org.ofbiz.base.conversion.Converters;
@@ -79,12 +77,12 @@ public class MiscTests extends GenericTe
         List<String> baseList = UtilMisc.toList("a", "1", "b", "2", "c", "3");
         ArrayList<String> arrayList = new ArrayList<String>();
         arrayList.addAll(baseList);
-        List<String> fastList = FastList.newInstance();
+        List<String> fastList = new LinkedList<String>();
         fastList.addAll(baseList);
         Map<String, String> baseMap = UtilMisc.toMap("a", "1", "b", "2", "c", "3");
         HashMap<String, String> hashMap = new HashMap<String, String>();
         hashMap.putAll(baseMap);
-        Map<String, String> fastMap = FastMap.newInstance();
+        Map<String, String> fastMap = new HashMap<String, String>();
         fastMap.putAll(baseMap);
         Object[] testObjects = new Object[] {
             string,