jive中這段程式碼什麼意思?

yadan發表於2002-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;
    }
<p class="indent">

這段程式碼檢測配置檔案中的<setup></setup>標籤中的值是true,為什麼用Class,Method這樣的機制?有和好處?

相關文章