package singleton;
public class RegSingleton {
private static RegSingleton _instance;
protected RegSingleton() { }
public static void Register
(String name, RegSingleton obj
) { _registry.put(name, obj);
}
public static RegSingleton Instance() {
if (_instance == null) {
// User define this name in system property file
// before program starts
String name =
System.
getProperty("patterns.book.singletonName");
_instance = RegSingleton.Lookup(name);
}
return _instance;
}
protected static RegSingleton Lookup
(String name
) { return (RegSingleton) _registry.get(name);
}
}