Ignore:
Timestamp:
2015-09-03T20:59:30+12:00 (9 years ago)
Author:
ak19
Message:

Fixes to do with networked Derby: port and host number changes propagated from build.props to global.props are now at last picked up by DerbyWrapper.java by build.xml setting a system property (-Dgsdl3.writablehome), which is then used to force load Global.Properties if it's not loaded yet. It won't be loaded when launching the ant update-userdb cmd which runs ModifyUsersDB.java. Or if running ModifyUsersDB.java, txt2usersDB.java or usersDB2txt from the cmdline.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/DerbyWrapper.java

    r30055 r30196  
    3535public class DerbyWrapper
    3636{
    37     static final String PORT = GlobalProperties.getProperty("derby.server.port", "1527");
    38     static final String DERBYSERVER = GlobalProperties.getProperty("derby.server", "localhost");
    39     static final String PROTOCOL = "jdbc:derby://"+DERBYSERVER+":"+PORT+"/"; // "jdbc:derby://localhost:1527";
    40     static final String DRIVER = "org.apache.derby.jdbc.ClientDriver"; //"org.apache.derby.jdbc.EmbeddedDriver";
     37    static final String PORT;
     38    static final String DERBYSERVER;
     39    static final String PROTOCOL;   
     40
     41    // static code block to initialise the above
     42    static {
     43    // GlobalProperties won't be loaded at this point if running ant config-admin or ant config-user
     44    // from the command line (both of which call ant update-userdb which in turn calls ModifyUsersDB.java)
     45    // In such a case, the ant command will have set the system property (-Dgsdl3_writablehome)
     46    // and passed this to ModifyUsersDB.java. Use that to load the GlobalProperties at this point
     47
     48    if(GlobalProperties.getGSDL3Home() == null) { // testing whether GlobalProperties is already loaded
     49        String gsdl3_writablehome = System.getProperty("gsdl3.writablehome"); // set by 'ant update-userdb' cmd
     50
     51        //System.err.println("@@@@@ writablehome: " + gsdl3_writablehome);
     52        GlobalProperties.loadGlobalProperties(gsdl3_writablehome);
     53    }
     54   
     55    //System.err.println("@@@@@ GlobalProperties.getGSDL3Home(): " + GlobalProperties.getGSDL3Home()); //test
     56   
     57    // No more fallback values, use exactly what's propagated into global.properties from build.properties
     58    PORT = GlobalProperties.getProperty("derby.server.port");//, "1527");
     59    DERBYSERVER = GlobalProperties.getProperty("derby.server");//, "localhost");
     60    PROTOCOL = "jdbc:derby://"+DERBYSERVER+":"+PORT+"/"; // "jdbc:derby://localhost:1527"; // by default
     61    }
     62   
     63
     64    static final String DRIVER = "org.apache.derby.jdbc.ClientDriver"; //"org.apache.derby.jdbc.EmbeddedDriver";
    4165    static final String USERSDB = "usersDB";
    4266    static final String USERS = "users";
Note: See TracChangeset for help on using the changeset viewer.