使用jive中工厂模式方式:
public static ForumFactory getInstance(Authorization authorization) {
if (factory == null) {
synchronized(initLock) {
if (factory == null) {
String classNameProp =
JiveGlobals.getJiveProperty("ForumFactory.className");
if (classNameProp != null) {
className = classNameProp;
}
try {
//Load the class and create an instance.
Class c = Class.forName(className);
factory = (ForumFactory)c.newInstance();
}
catch (Exception e) {
System.err.println("Failed to load ForumFactory class "
+ className + ". Jive cannot function normally.");
e.printStackTrace();
return null;
}
}
}
}
//Now, create a forum factory proxy.
return factory ;
}