Package org.jtrim2.concurrent.query
Class CachedLinkRequest<QueryArgType>
java.lang.Object
org.jtrim2.concurrent.query.CachedLinkRequest<QueryArgType>
- Type Parameters:
QueryArgType- the type of the actual input of the query for the data retrieval process. Note that this type is recommended to be immutable or effectively immutable.
Defines a request for a data when the
AsyncDataLink providing should
be cached. The request is intended to passed to an AsyncDataQuery as
an input.
Apart from the input of the query, the request contains an timeout value
after the cached AsyncDataLink becomes invalid and should be
recreated when needed again.
Thread safety
The methods of this class are safe to be accessed by multiple threads concurrently. Instances of this class are immutable except that the actualinput of the query can possibly be mutable. Note
however that it is recommended that this input be immutable as well making
instances of this class completely immutable.
Synchronization transparency
The methods of this class are synchronization transparent.-
Constructor Summary
ConstructorsConstructorDescriptionCachedLinkRequest(QueryArgType queryArg) Creates and initializes theCachedLinkRequestwith the given input for the query and one hour as thecache expire timeoutvalue.CachedLinkRequest(QueryArgType queryArg, long cacheExpire, TimeUnit timeunit) Creates and initializes theCachedLinkRequestwith the given input for the query and the cache expire timeout value. -
Method Summary
Modifier and TypeMethodDescriptionlonggetCacheExpire(TimeUnit timeunit) Returns the timeout value in the given time unit after anAsyncDataLinkrequested by this request becomes invalid and must be recreated.Returns the object used as the input of the query of the data.toString()Returns the string representation of thisCachedLinkRequestin no particular format.
-
Constructor Details
-
CachedLinkRequest
Creates and initializes theCachedLinkRequestwith the given input for the query and one hour as thecache expire timeoutvalue.- Parameters:
queryArg- the object used as the input of theAsyncDataQueryto retrieve the requested data. This argument can benullif the query acceptsnullvalues as its input.
-
CachedLinkRequest
Creates and initializes theCachedLinkRequestwith the given input for the query and the cache expire timeout value.- Parameters:
queryArg- the object used as the input of theAsyncDataQueryto retrieve the requested data. This argument can benullif the query acceptsnullvalues as its input.cacheExpire- the time in the given unit after theAsyncDataLinkinstance created using this request becomes invalid and should be recreated. This argument must be greater than or equal to zero.timeunit- the time unit of thecacheExpireargument. This argument cannot benull.- Throws:
IllegalArgumentException- thrown ifcacheExpire < 0NullPointerException- thrown iftimeunitisnull
-
-
Method Details
-
getCacheExpire
Returns the timeout value in the given time unit after anAsyncDataLinkrequested by this request becomes invalid and must be recreated.- Parameters:
timeunit- the time unit in which the timeout value is to be returned. This argument cannot benull.- Returns:
- the timeout value in the given time unit after an
AsyncDataLinkrequested by this request becomes invalid and must be recreated. This method always returns a value greater than or equal to zero.
-
getQueryArg
Returns the object used as the input of the query of the data. That is, this is the only property which determines what data is to be retrieved.- Returns:
- the object used as the input of the query of the data. This
method may return
nullifnullwas passed in the constructor.
-
toString
Returns the string representation of thisCachedLinkRequestin no particular format.This method is intended to be used for debugging only.
-