Class XRecent<T,X extends Exception>

java.lang.Object
de.team33.patterns.expiry.tethys.XRecent<T,X>
Type Parameters:
T - The type of instances to handle.
All Implemented Interfaces:
XSupplier<T,X>

public class XRecent<T,X extends Exception> extends Object implements XSupplier<T,X>
Defines a container type for handling instances, which in principle can be defined globally and reused over and over again, but have to be updated after a certain time.

Problem to solve:

There are objects that, due to their technical properties, are predestined to be initialized and made available once throughout the application. In particular, they are state-free but relatively "expensive" to initialize. Due to their semantics, however, they have to be renewed from time to time. An example of such an object could be an authentication token.

This class serves to handle such objects and in particular their updating.

  • Constructor Summary

    Constructors
    Constructor
    Description
    XRecent(XSupplier<? extends T,? extends X> newSubject, long maxIdle, long maxLiving)
    Initializes a new instance of this container type given a XSupplier for the type to be handled and an intended lifetime of such instances.
  • Method Summary

    Modifier and Type
    Method
    Description
    final T
    get()
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • XRecent

      public XRecent(XSupplier<? extends T,? extends X> newSubject, long maxIdle, long maxLiving)
      Initializes a new instance of this container type given a XSupplier for the type to be handled and an intended lifetime of such instances.

      CAUTION: The given lifetime should be significantly smaller than the actually expected life span of an instance to be handled, otherwise there may not be enough time to use a provided instance successfully!

      Parameters:
      newSubject - the XSupplier for the instances to handle
      maxIdle - the maximum idle time in milliseconds
      maxLiving - the maximum lifetime in milliseconds
  • Method Details