diff options
author | Leif Åstrand <leif@vaadin.com> | 2015-02-04 20:45:10 +0200 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2015-02-04 20:45:10 +0200 |
commit | 648b493cbb5ac4eabdbf476da55afae0799b2be2 (patch) | |
tree | c50e303926cabdb01103a69465b61a3e666225ed /server/src/com/vaadin/ui/declarative | |
parent | 5d08dd6efc1d9d955ec0444204c8730438ec8923 (diff) | |
download | vaadin-framework-648b493cbb5ac4eabdbf476da55afae0799b2be2.tar.gz vaadin-framework-648b493cbb5ac4eabdbf476da55afae0799b2be2.zip |
Use non-blocking Map implementation for caches (#16582)
Change-Id: Id2d3bc317f6763480b2ef5ce71244f048c5cfc26
Diffstat (limited to 'server/src/com/vaadin/ui/declarative')
4 files changed, 11 insertions, 19 deletions
diff --git a/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java b/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java index 3e2c01c881..57a54cb9d8 100644 --- a/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java +++ b/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java @@ -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]; diff --git a/server/src/com/vaadin/ui/declarative/DesignContext.java b/server/src/com/vaadin/ui/declarative/DesignContext.java index b298c95320..5f160d6f26 100644 --- a/server/src/com/vaadin/ui/declarative/DesignContext.java +++ b/server/src/com/vaadin/ui/declarative/DesignContext.java @@ -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; diff --git a/server/src/com/vaadin/ui/declarative/DesignFormatter.java b/server/src/com/vaadin/ui/declarative/DesignFormatter.java index fdce563104..103142a11b 100644 --- a/server/src/com/vaadin/ui/declarative/DesignFormatter.java +++ b/server/src/com/vaadin/ui/declarative/DesignFormatter.java @@ -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. diff --git a/server/src/com/vaadin/ui/declarative/converters/ShortcutKeyMapper.java b/server/src/com/vaadin/ui/declarative/converters/ShortcutKeyMapper.java index 46c38ce0e0..2940c82c06 100644 --- a/server/src/com/vaadin/ui/declarative/converters/ShortcutKeyMapper.java +++ b/server/src/com/vaadin/ui/declarative/converters/ShortcutKeyMapper.java @@ -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 |