]> source.dussan.org Git - vaadin-framework.git/commitdiff
Use non-blocking Map implementation for caches (#16582)
authorLeif Åstrand <leif@vaadin.com>
Wed, 4 Feb 2015 18:45:10 +0000 (20:45 +0200)
committerLeif Åstrand <leif@vaadin.com>
Wed, 4 Feb 2015 18:45:10 +0000 (20:45 +0200)
Change-Id: Id2d3bc317f6763480b2ef5ce71244f048c5cfc26

server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java
server/src/com/vaadin/ui/declarative/DesignContext.java
server/src/com/vaadin/ui/declarative/DesignFormatter.java
server/src/com/vaadin/ui/declarative/converters/ShortcutKeyMapper.java

index 3e2c01c8816c16a04085060b9492cd05f882a9bb..57a54cb9d8209dfb6637542a775079c6ff02bdf9 100644 (file)
@@ -23,10 +23,9 @@ import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.regex.Matcher;
@@ -55,8 +54,7 @@ public class DesignAttributeHandler implements Serializable {
         return Logger.getLogger(DesignAttributeHandler.class.getName());
     }
 
-    private static Map<Class<?>, AttributeCacheEntry> cache = Collections
-            .synchronizedMap(new HashMap<Class<?>, AttributeCacheEntry>());
+    private static Map<Class<?>, AttributeCacheEntry> cache = new ConcurrentHashMap<Class<?>, AttributeCacheEntry>();
 
     // translates string <-> object
     private static DesignFormatter FORMATTER = new DesignFormatter();
@@ -403,8 +401,7 @@ public class DesignAttributeHandler implements Serializable {
      * @author Vaadin Ltd
      */
     private static class AttributeCacheEntry implements Serializable {
-        private Map<String, Method[]> accessMethods = Collections
-                .synchronizedMap(new HashMap<String, Method[]>());
+        private Map<String, Method[]> accessMethods = new ConcurrentHashMap<String, Method[]>();
 
         private void addAttribute(String attribute, Method getter, Method setter) {
             Method[] methods = new Method[2];
index b298c95320f7a256375f03276533b3717a700892..5f160d6f26680c48656d75abee44d3ff65de857b 100644 (file)
@@ -17,10 +17,10 @@ package com.vaadin.ui.declarative;
 
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.jsoup.nodes.Attributes;
 import org.jsoup.nodes.Document;
@@ -44,8 +44,7 @@ import com.vaadin.ui.HasComponents;
 public class DesignContext implements Serializable {
 
     // cache for object instances
-    private static Map<Class<?>, Component> instanceCache = Collections
-            .synchronizedMap(new HashMap<Class<?>, Component>());
+    private static Map<Class<?>, Component> instanceCache = new ConcurrentHashMap<Class<?>, Component>();
 
     // The root component of the component hierarchy
     private Component rootComponent = null;
index fdce563104fa8aa6550fd6969533d542ec74e387..103142a11b975784240fb0ab48ad4cb30b21ff2a 100644 (file)
@@ -21,11 +21,11 @@ import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.util.Collections;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.TimeZone;
+import java.util.concurrent.ConcurrentHashMap;
 
 import com.vaadin.data.util.converter.Converter;
 import com.vaadin.event.ShortcutAction;
@@ -34,8 +34,8 @@ import com.vaadin.ui.declarative.converters.DesignDateConverter;
 import com.vaadin.ui.declarative.converters.DesignFormatConverter;
 import com.vaadin.ui.declarative.converters.DesignResourceConverter;
 import com.vaadin.ui.declarative.converters.DesignShortcutActionConverter;
-import com.vaadin.ui.declarative.converters.ShortcutKeyMapper;
 import com.vaadin.ui.declarative.converters.DesignToStringConverter;
+import com.vaadin.ui.declarative.converters.ShortcutKeyMapper;
 
 /**
  * Class focused on flexible and consistent formatting and parsing of different
@@ -47,8 +47,7 @@ import com.vaadin.ui.declarative.converters.DesignToStringConverter;
  */
 public class DesignFormatter implements Serializable {
 
-    private final Map<Class<?>, Converter<String, ?>> converterMap = Collections
-            .synchronizedMap(new HashMap<Class<?>, Converter<String, ?>>());
+    private final Map<Class<?>, Converter<String, ?>> converterMap = new ConcurrentHashMap<Class<?>, Converter<String, ?>>();
 
     /**
      * Creates the formatter with default types already mapped.
index 46c38ce0e052915be59c1f0478656b56041900f0..2940c82c0664c4b4239d4f1ba41d4114e4f9b8a7 100644 (file)
@@ -16,9 +16,8 @@
 package com.vaadin.ui.declarative.converters;
 
 import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import com.vaadin.event.ShortcutAction.KeyCode;
 import com.vaadin.event.ShortcutAction.ModifierKey;
@@ -55,10 +54,8 @@ public interface ShortcutKeyMapper extends Serializable {
      */
     public static final ShortcutKeyMapper DEFAULT = new ShortcutKeyMapper() {
 
-        private final Map<Integer, String> keyCodeMap = Collections
-                .synchronizedMap(new HashMap<Integer, String>());
-        private final Map<String, Integer> presentationMap = Collections
-                .synchronizedMap(new HashMap<String, Integer>());
+        private final Map<Integer, String> keyCodeMap = new ConcurrentHashMap<Integer, String>();
+        private final Map<String, Integer> presentationMap = new ConcurrentHashMap<String, Integer>();
 
         {
             // map modifiers