aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/icedteanp/java/sun/applet/PluginObjectStore.java
diff options
context:
space:
mode:
authorDenis Lila <[email protected]>2011-03-31 15:15:29 -0400
committerDenis Lila <[email protected]>2011-03-31 15:15:29 -0400
commit5f5e4e60cbd14b87dfdba9206faa3843da33097d (patch)
tree941d1e2e300c627aad2b396165790681d5a8f0ef /plugin/icedteanp/java/sun/applet/PluginObjectStore.java
parent948a84aa91411545d03c091ab7280905f34097f0 (diff)
Made PluginObjectStore a singleton.
Diffstat (limited to 'plugin/icedteanp/java/sun/applet/PluginObjectStore.java')
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginObjectStore.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/plugin/icedteanp/java/sun/applet/PluginObjectStore.java b/plugin/icedteanp/java/sun/applet/PluginObjectStore.java
index a80e327..07a94e5 100644
--- a/plugin/icedteanp/java/sun/applet/PluginObjectStore.java
+++ b/plugin/icedteanp/java/sun/applet/PluginObjectStore.java
@@ -40,14 +40,21 @@ package sun.applet;
import java.util.HashMap;
import java.util.Map;
-public class PluginObjectStore {
- private static HashMap<Integer, Object> objects = new HashMap<Integer, Object>();
- private static HashMap<Integer, Integer> counts = new HashMap<Integer, Integer>();
- private static HashMap<Object, Integer> identifiers = new HashMap<Object, Integer>();
- private static final Object lock = new Object();
+// Enums are the best way to implement singletons.
+enum PluginObjectStore {
+ INSTANCE;
- private static boolean wrapped = false;
- private static int nextUniqueIdentifier = 1;
+ private HashMap<Integer, Object> objects = new HashMap<Integer, Object>();
+ private HashMap<Integer, Integer> counts = new HashMap<Integer, Integer>();
+ private HashMap<Object, Integer> identifiers = new HashMap<Object, Integer>();
+ private final Object lock = new Object();
+
+ private boolean wrapped = false;
+ private int nextUniqueIdentifier = 1;
+
+ public static PluginObjectStore getInstance() {
+ return INSTANCE;
+ }
public Object getObject(Integer identifier) {
synchronized(lock) {
@@ -78,7 +85,7 @@ public class PluginObjectStore {
}
}
- private static boolean checkNeg() {
+ private boolean checkNeg() {
if (nextUniqueIdentifier < 1) {
wrapped = true;
nextUniqueIdentifier = 1;