Monday, January 21, 2013

Working with apache commons configuration


This week, i have explored the apache commons-configuration third part jar. It sounds more interesting to read the configuration details from multiple properties files in our project at once.

Sample Configuration file:

configuration.xml – File to configure the list of properties file to be loaded from your application.
<?xml version="1.0" encoding="ISO-8859-1"?>
<configuration>
  <system />
  <properties fileName="logging.properties" />
  <properties fileName="appConfig.properties" />
  <properties fileName="webserviceEndPoints.properties" />
  <properties fileName="message.properties" />
  <properties fileName="com/x/y/z/a.properties"/>
  <properties fileName="com/x/y/z/b.properties"/>
</configuration>

/**
* This class is to read values from the properties files listed in central configuration file. Need to define the *all configuration/properties file in the configuation.xml
*/
public final class ConfigurationManager {
    private static final String CONFIG_FILE = "configuration.xml";
    private static Configuration configuration;
    private ConfigurationManager() {
     final URL configFileURL = Thread.currentThread().getContextClassLoader().getResource(CONFIG_FILE);
     final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(configFileURL);
     configuration = builder.getConfiguration(true);
    }


Now, how do we get the value from property file using key?

Each method returns an object by looking up in the property file associated with the key if the corresponding key is missing it will return defaultValue which is the argument.

    configuration.getInteger(Key)
    configuration.getInteger(Key, defaultValue) - If not present in prop file
                        .getString
                        .getBoolean
                        .getDouble
                        .getStringArray
                        .getList etc.

   You can have to explore for additional methods.

Reference:
commons-configuration-1.5.jar. Please refer the features here for configuration (http://commons.apache.org/configuration)

Wednesday, January 16, 2013

online image editor


I have come across a new new online tool this week. Thought, it is worth to share this tool with my readers and followers.

To create/edit graphic images we may need licensed software like photoshop etc. Do you think, is it really worth to spend much cost to create/edit  simple images to the designers like me? Definitely, me answer is NO.

How about create/edit an image through online without installing any specialized software(s)? Sounds interesting? Have a look at the website http://pixlr.com/editor

Rgds
_NjN

Pega Decisioning Consultant - Mission Test Quiz & Answers

The Pega Certified Decisioning Consultant (PCDC) certification is for professionals participating in the design and development of a Pega ...