com.tomgibara.pronto.config.source
Class SystemConfigSource
java.lang.Object
com.tomgibara.pronto.config.source.SystemConfigSource
- All Implemented Interfaces:
- ConfigSource
public class SystemConfigSource
- extends java.lang.Object
- implements ConfigSource
Enacapsulates the system properties as a ConfigSource. Note that calling
either method on this class is a moderately expensive operation. For this
reason, it is recommended that instances of this class are wrapped in a
CachingConfigSource if used in conjunction with ConfigPolicy objects
featuring very small minimum read periods. This class is not safe for
concurrent use. Wrap instances in a SynchronousConfigSource if thread safety
is required.
- Author:
- Tom Gibara
|
Method Summary |
java.util.Map<java.lang.String,java.lang.String> |
getProperties()
A map of the configuration properties supplied by this source. |
long |
lastModified()
Returns the time at which the properties were last known to have changed. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SystemConfigSource
public SystemConfigSource()
lastModified
public long lastModified()
throws java.lang.RuntimeException
- Description copied from interface:
ConfigSource
- Returns the time at which the properties were last known to have changed.
This method must be implemented and MAY NOT return rogue values if the
time is unknown. The correct behaviour in such circumstances is to return
the current system time. If calculation of the time fails, the
implementation is free to throw a runtime exception of its choosing.
- Specified by:
lastModified in interface ConfigSource
- Returns:
- time at which the system properties were known to have last
changed.
- Throws:
java.lang.RuntimeException - if the system properties cannot be accessed
getProperties
public java.util.Map<java.lang.String,java.lang.String> getProperties()
throws java.lang.RuntimeException
- Description copied from interface:
ConfigSource
- A map of the configuration properties supplied by this source. The map
returned by this method will not be modified by the config. The
implementation is free to throw an unchecked exception of its choice if
the properties cannot be supplied.
- Specified by:
getProperties in interface ConfigSource
- Returns:
- a snapshot of the present system properties
- Throws:
java.lang.RuntimeException - if the system properties cannot be accessed
Copyright © 2006-2007 Tom Gibara. All Rights Reserved.