You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2012/05/29 12:19:21 UTC
svn commit: r1343646 -
/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PosDialog.java
Author: jacopoc
Date: Tue May 29 10:19:21 2012
New Revision: 1343646
URL: http://svn.apache.org/viewvc?rev=1343646&view=rev
Log:
Improved code that manages the cache:
* removed unnecessary synchronization
* protected the UtilCache object (static field) by making it private and final
Modified:
ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PosDialog.java
Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PosDialog.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PosDialog.java?rev=1343646&r1=1343645&r2=1343646&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PosDialog.java (original)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PosDialog.java Tue May 29 10:19:21 2012
@@ -48,7 +48,7 @@ import org.ofbiz.base.util.cache.UtilCac
public class PosDialog {
public static final String module = PosDialog.class.getName();
- protected static UtilCache<Object, Object> instances = UtilCache.createUtilCache("pos.Dialogs", 0, 0);
+ private static final UtilCache<XPage, PosDialog> instances = UtilCache.createUtilCache("pos.Dialogs", 0, 0);
protected final Frame clientFrame = XProjectManager.getCurrentProject().getAppFrame();
protected final Window appWindow = XProjectManager.getCurrentProject().getAppWindow();
@@ -71,14 +71,7 @@ public class PosDialog {
public static PosDialog getInstance(XPage page, boolean modal, int padding) {
PosDialog dialog = (PosDialog) instances.get(page);
if (dialog == null) {
- synchronized(PosDialog.class) {
- dialog = (PosDialog) instances.get(page);
-
- if (dialog == null) {
- dialog = new PosDialog(page, modal, padding);
- instances.put(page, dialog);
- }
- }
+ dialog = instances.putIfAbsentAndGet(page, new PosDialog(page, modal, padding));
}
dialog.modal = modal;