Author: adrianc
Date: Fri Nov 13 00:31:39 2009
New Revision: 835667
URL:
http://svn.apache.org/viewvc?rev=835667&view=revLog:
Small improvement to the Converters class. A converter is registered only once.
Now client code can create local instances of specific converters without interfering with the operation of the factory method.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java
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=835667&r1=835666&r2=835667&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 Fri Nov 13 00:31:39 2009
@@ -127,11 +127,13 @@
*/
public static <S, T> void registerConverter(Converter<S, T> converter) {
String key = converter.getSourceClass().getName().concat(DELIMITER).concat(converter.getTargetClass().getName());
- synchronized (converterMap) {
- converterMap.put(key, converter);
- }
- if (Debug.verboseOn()) {
- Debug.logVerbose("Registered converter " + converter.getClass().getName(), module);
+ if (converterMap.get(key) == null) {
+ synchronized (converterMap) {
+ converterMap.put(key, converter);
+ }
+ if (Debug.verboseOn()) {
+ Debug.logVerbose("Registered converter " + converter.getClass().getName(), module);
+ }
}
}