jive中这段代码什么意思?

yadan 02-12-17


// check for <setup>true</setup> in the jive config file. If setup does
// equal true, inactivate this setup tool

boolean doSetup = false;
// Try loading a Jive class:

try {
Class jiveGlobals = Class.forName(
"com.jivesoftware.forum.JiveGlobals");
// authorization class used below
Class authorization = Class.forName(
"com.jivesoftware.forum.Authorization");
Class[] params = new Class[1];
params[0] =
"".getClass();
Method getJiveProperty = jiveGlobals.getMethod(
"getJiveProperty", params);
if (getJiveProperty == null) {
doSetup = true;
}
else {
// Call JiveGlobals.getJiveProperty("setup")
String[] args = {
"setup"};
Object setupVal = getJiveProperty.invoke(null, args);
if (setupVal == null) {
doSetup = true;
}
else {
String setup = (String)setupVal;
if (!
"true".equals(setup)) {
doSetup = true;
}
}
}
}
catch (Exception e) {
doSetup = true;
}

这段代码检测配置文件中的<setup></setup>标签中的值是true,为什么用Class,Method这样的机制?有和好处?