Search in sources :

Example 1 with ConfigDataProcessor

use of gate.config.ConfigDataProcessor in project gate-core by GateNLP.

the class Gate method initConfigData.

// initDataStoreRegister()
/**
 * Reads config data (<TT>gate.xml</TT> files). There are three sorts of
 * these files:
 * <UL>
 * <LI> The builtin file from GATE's resources - this is read first.
 * <LI> A site-wide init file given as a command-line argument or as a
 * <TT>gate.config</TT> property - this is read second.
 * <LI> The user's file from their home directory - this is read last.
 * </UL>
 * Settings from files read after some settings have already been made will
 * simply overwrite the previous settings.
 */
public static void initConfigData() throws GateException {
    ConfigDataProcessor configProcessor = new ConfigDataProcessor();
    URL configURL;
    // parse the site configuration file
    if (siteConfigFile != null && siteConfigFile.exists()) {
        try {
            configURL = siteConfigFile.toURI().toURL();
        } catch (MalformedURLException mue) {
            // this should never happen
            throw new GateRuntimeException(mue);
        }
        try {
            InputStream configStream = new FileInputStream(siteConfigFile);
            configProcessor.parseConfigFile(configStream, configURL);
        } catch (IOException e) {
            throw new GateException("Couldn't open site configuration file: " + configURL + " " + e);
        }
    }
    // parse the user configuration data if present
    if (userConfigFile != null && userConfigFile.exists()) {
        try {
            configURL = userConfigFile.toURI().toURL();
        } catch (MalformedURLException mue) {
            // this should never happen
            throw new GateRuntimeException(mue);
        }
        try {
            InputStream configStream = new FileInputStream(userConfigFile);
            configProcessor.parseConfigFile(configStream, configURL);
        } catch (IOException e) {
            throw new GateException("Couldn't open user configuration file: " + configURL + " " + e);
        }
    }
    // remember the init-time config options
    originalUserConfig.putAll(userConfig);
}
Also used : MalformedURLException(java.net.MalformedURLException) ConfigDataProcessor(gate.config.ConfigDataProcessor) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) GateRuntimeException(gate.util.GateRuntimeException) GateException(gate.util.GateException) IOException(java.io.IOException) URL(java.net.URL) FileInputStream(java.io.FileInputStream)

Aggregations

ConfigDataProcessor (gate.config.ConfigDataProcessor)1 GateException (gate.util.GateException)1 GateRuntimeException (gate.util.GateRuntimeException)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1