/**
* Deutsche Knowledge Services
* ADSS - BPMS Team
* Copyright 2009
*/
package com.db.dks.bpms.presence.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Singleton class used to provide configuration settings from the
* application.properties file
*
* @author quitedw
*
*/
public class ApplicationManager {
private static final Log log = LogFactory.getLog(ApplicationManager.class);
private Properties properties;
private static volatile ApplicationManager instance;
private ApplicationManager() {
try {
loadParameters("/application.properties");
} catch (Exception e) {
log.error("Error loading application properties file!");
}
}
public static ApplicationManager getInstance() {
if (instance == null) {
synchronized (ApplicationManager.class) {
if (instance == null) {
instance = new ApplicationManager();
}
}
}
return instance;
}
public Properties getProperties() {
return properties;
}
private void loadParameters(String fileName) throws Exception {
log.info("Loading application properties...");
InputStream is = null;
try {
is = this.getClass().getResourceAsStream(fileName);
if (null != is) {
properties = new Properties();
properties.load(is);
log.info("successfully loaded: " + fileName);
} else {
throw new Exception("Cannot load application properties file!");
}
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
log.error("error closing InputStream: ", e);
}
}
}
}
}
you need a brain that works like a sponge to absorb all the kewl stuffs about java
Wednesday, March 30, 2011
test java
Subscribe to:
Posts (Atom)