uk.co.bigbeeconsultants.bconfig

SourceChangeDetector

class SourceChangeDetector extends AnyRef

Provides a tool for detecting changes in a ConfigSourceJ, typically intended for observing changed files via their last modified timestamps. Polling is done economically: (a) it is only done by the calling thread (no background threads are needed), and (b) a max-age parameter sets a band of time during which updates are ignored.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. SourceChangeDetector
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new SourceChangeDetector(source: ConfigSourceJ, maxAgeMillis: Long, refresh: (Boolean) ⇒ Unit)

    source

    the file (or other) source

    maxAgeMillis

    Setting the max age to, say, 10000 will mean that the file timestamp is only checked at most once every ten seconds, minimising the overhead of logic and thread synchronisation.

    refresh

    a function that will be invoked when a change in the file has been detected. It receives a boolean indicating whether the source should be reloaded. For file-based sources, this is true if the file exists and is newer than the last time it was opened; if the file has recently been deleted, refresh will be invoked with the false value. For readable-once sources and classpath sources, the value will only ever be true the first time.

    Many threads may concurrently call pollForUpdate or updateNow, but if they result in a refresh, this will occur within a monitor lock on the source change detector. This ensures that calls to refresh will only ever happen one at a time. Be careful not to attempt to obtain other locks inside refresh in a way that night cause deadlock.

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  15. def pollForUpdate(): Boolean

    Checks whether the source is newer and needs reloading.

    Checks whether the source is newer and needs reloading. For the large part of the max-age period, this method does almost nothing. At infrequent periods, it will inspect the file's last-modified timestamp and potentially signal for the file to be reloaded. Therefore it is safe to call this method frequently, every time a value is needed from the cache of file contents.

    returns

    true if the refresh callback was invoked with its argument set to true

  16. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  17. def toString(): String

    Definition Classes
    AnyRef → Any
  18. def updateNow(): Boolean

    Triggers an immediate change detection.

    Triggers an immediate change detection. Use this if it is known by some other means that the cache has become stale.

    returns

    true if the refresh callback was invoked with its argument set to true

  19. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped