Class SessionCache
- java.lang.Object
-
- org.hl7.fhir.validation.cli.services.SessionCache
-
public class SessionCache extends Object
SessionCache for storing and retrieving ValidationEngine instances, so callers do not have to re-instantiate a new instance for each validation request.
-
-
Field Summary
Fields Modifier and Type Field Description protected static longTIME_TO_LIVEprotected static TimeUnitTIME_UNIT
-
Constructor Summary
Constructors Constructor Description SessionCache()SessionCache(long sessionLength, TimeUnit sessionLengthUnit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcacheSession(String sessionId, ValidationEngine validationEngine)Stores the initializedValidationEnginein the cache with the passed in id as the key.StringcacheSession(ValidationEngine validationEngine)Stores the initializedValidationEnginein the cache.ValidationEnginefetchSessionValidatorEngine(String sessionId)Returns the storedValidationEngineassociated with the passed in session id, if one such instance exists.Set<String>getSessionIds()Returns the set of stored session ids.booleansessionExists(String sessionId)Checks if the passed inStringid exists in the set of stored session id.
-
-
-
Field Detail
-
TIME_TO_LIVE
protected static final long TIME_TO_LIVE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SessionCache
public SessionCache()
-
SessionCache
public SessionCache(long sessionLength, TimeUnit sessionLengthUnit)
- Parameters:
sessionLength- the constant amount of time an entry is available before it expires. A negative value results in entries that NEVER expire. A zero value results in entries that ALWAYS expire.sessionLengthUnit- the unit of time for the timeToLive parameter, must not be null
-
-
Method Detail
-
cacheSession
public String cacheSession(ValidationEngine validationEngine)
Stores the initializedValidationEnginein the cache. Returns the session id that will be associated with this instance.- Parameters:
validationEngine-ValidationEngine- Returns:
- The
Stringid associated with the stored instance.
-
cacheSession
public String cacheSession(String sessionId, ValidationEngine validationEngine)
Stores the initializedValidationEnginein the cache with the passed in id as the key. If a null key is passed in, a new key is generated and returned.- Parameters:
sessionId- TheStringkey to associate with this storedValidationEnginevalidationEngine- TheValidationEngineinstance to cache.- Returns:
- The
Stringid that will be associated with the storedValidationEngine
-
sessionExists
public boolean sessionExists(String sessionId)
Checks if the passed inStringid exists in the set of stored session id.- Parameters:
sessionId- TheStringid to search for.- Returns:
Boolean.TRUEif such id exists.
-
fetchSessionValidatorEngine
public ValidationEngine fetchSessionValidatorEngine(String sessionId)
Returns the storedValidationEngineassociated with the passed in session id, if one such instance exists.- Parameters:
sessionId- TheStringsession id.- Returns:
- The
ValidationEngineassociated with the passed in id, or null if none exists.
-
getSessionIds
public Set<String> getSessionIds()
Returns the set of stored session ids.- Returns:
Setof session ids.
-
-