com.tomgibara.pronto.config.source
Class SynchronizedConfigSource

java.lang.Object
  extended by com.tomgibara.pronto.config.source.SynchronizedConfigSource
All Implemented Interfaces:
ConfigSource

public class SynchronizedConfigSource
extends java.lang.Object
implements ConfigSource

Instances of this class wrap other ConfigSource instances and ensure that its ConfigSource methods are safe for concurrent access.

Author:
Tom Gibara

Constructor Summary
SynchronizedConfigSource(ConfigSource source)
          Constructs a new ConfigSource which synchronizes access to the methods of another ConfigSource.
 
Method Summary
 java.util.Map<java.lang.String,java.lang.String> getProperties()
          A map of the configuration properties supplied by this source.
 ConfigSource getSource()
          The ConfigSource object which is being synchronized by this object.
 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
 

Constructor Detail

SynchronizedConfigSource

public SynchronizedConfigSource(ConfigSource source)
Constructs a new ConfigSource which synchronizes access to the methods of another ConfigSource.

Parameters:
source - the source to be synchronized, not null
Method Detail

getSource

public ConfigSource getSource()
The ConfigSource object which is being synchronized by this object.

Returns:
the ConfigSource being synchronized

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:
the last modified time from the underlying source
Throws:
java.lang.RuntimeException - if the underlying source throws one

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:
the properties from the underlying source
Throws:
java.lang.RuntimeException - if the underlying source throws one


Copyright © 2006-2007 Tom Gibara. All Rights Reserved.