package singleton;
public class SomeFactory {
static private SomeFactory _instance;
protected SomeFactory() {
// ....
}
public static SomeFactory instance() {
if (_instance == null) {
String factoryStyle =
System.
getProperty("patterns.book.factoryStyle");
if (factoryStyle.equals("wise")) {
_instance = new WiseFactory();
} else if (factoryStyle.equals("quick")) {
_instance = new QuickFactory();
} else {
_instance = new SomeFactory();
}
}
return _instance;
}
// Factory methods, producing products...
// .....
}
// .....
}
// .....
}