Pages

Thursday, January 5, 2017

Using an external dfc.properties file

Normally, dfc.jar based client applications load dfc.properties from the class path. That usually means that the file should be included in the application archive. For example, when D2 or DA are deployed to a server, dfc.properties in the WEB-INF/class of the exploded web application has to be adjusted.

However, dfc.jar allows specifying the path to an external dfc.properties file that should be used instead of the internal file. The path should be assigned to system property dfc.properties.file before any dfc.jar method is invoked.

    final static String DFC_PROPERTIES_FILE_NAME = "settings/dfc.properties";

    void checkIfExtenalDFCPropertiesFileIsAvailable() {
        // checking whether the external dfc.properties exist
        File dfcPropertiesFile = new File(DFC_PROPERTIES_FILE_NAME);
        if (dfcPropertiesFile.exists()) {
            // dfc.properties.file system property points to the file that is to be used by dfc.jar
            System.setProperty("dfc.properties.file", dfcPropertiesFile.getAbsolutePath());
            logger.debug("dfc.properties at {} will be loaded", dfcPropertiesFile.getAbsolutePath());
        } else {
            logger.debug("dfc.properties from the classpath will be used");
        }
    }

No comments:

Post a Comment