Responsible for holding the Cache configuration properties. If the default
constructor is used, this class will load the properties from the
.
| Method from com.opensymphony.oscache.base.Config Detail: |
public Object get(Object key) {
return properties.get(key);
}
|
public Properties getProperties() {
return properties;
}
Retrieves all of the configuration properties. This property set
should be treated as immutable. |
public String getProperty(String key) {
if (key == null) {
throw new IllegalArgumentException("key is null");
}
if (properties == null) {
return null;
}
return properties.getProperty(key);
}
Retrieve the value of the named configuration property. If the property
cannot be found this method will return null. |
public static Properties loadProperties(URL url,
String info) {
log.info("OSCache: Getting properties from URL " + url + " for " + info);
Properties properties = new Properties();
InputStream in = null;
try {
in = url.openStream();
properties.load(in);
log.info("OSCache: Properties read " + properties);
} catch (Exception e) {
log.error("OSCache: Error reading from " + url, e);
log.error("OSCache: Ensure the properties information in " + url+ " is readable and in your classpath.");
} finally {
try {
in.close();
} catch (IOException e) {
log.warn("OSCache: IOException while closing InputStream: " + e.getMessage());
}
}
return properties;
}
Load the properties from the specified URL. |
public static Properties loadProperties(String filename,
String info) {
URL url = null;
ClassLoader threadContextClassLoader = Thread.currentThread().getContextClassLoader();
if (threadContextClassLoader != null) {
url = threadContextClassLoader.getResource(filename);
}
if (url == null) {
url = Config.class.getResource(filename);
if (url == null) {
log.warn("OSCache: No properties file found in the classpath by filename " + filename);
return new Properties();
}
}
return loadProperties(url, info);
}
Load the specified properties file from the classpath. If the file
cannot be found or loaded, an error will be logged and no
properties will be set. |
public void set(Object key,
Object value) {
if (key == null) {
throw new IllegalArgumentException("key is null");
}
if (value == null) {
return;
}
if (properties == null) {
properties = new Properties();
}
properties.put(key, value);
}
Sets a configuration property. |