Commit fd286572 authored by Lubomir Bulej's avatar Lubomir Bulej

Use lazy-initialized singleton in GuardResolver

Get rid of synchronization in getInstance() method and instead use
a static initializer to create the GuardResolver singleton (we should
get rid of that too, but later).
parent 26a915d3
......@@ -14,11 +14,14 @@ import ch.usi.dag.disl.exception.GuardException;
public class GuardResolver {
// TODO LB: Get rid of guard resolver singleton
private static GuardResolver instance = null;
private static GuardResolver instance = new GuardResolver ();
// Guard to guard method map
private Map<Class<?>, GuardMethod> guardToMethod =
new HashMap<Class<?>, GuardMethod>();
public static GuardResolver getInstance () {
return instance;
}
public synchronized GuardMethod getGuardMethod(
Class<?> guardClass) throws GuardException {
......@@ -65,12 +68,7 @@ public class GuardResolver {
return guardMethod;
}
public static synchronized GuardResolver getInstance() {
if (instance == null) {
instance = new GuardResolver();
}
return instance;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment