Package io.goobi.viewer.managedbeans
Class PersistentStorageBean
java.lang.Object
io.goobi.viewer.managedbeans.PersistentStorageBean
- All Implemented Interfaces:
DataStorage
,Serializable
@Named("applicationBean")
@Eager
@ApplicationScoped
public class PersistentStorageBean
extends Object
implements DataStorage, Serializable
Used for application wide storage of objects accessible to other managed objects
- Author:
- florian
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
<T> T
getIfRecentOrPut
(String key, T object, long timeToLiveMinutes) If the given key exists and the entry is no older than the given timeToLiveMinutes, return the object stored under the key, otherwise store the given object under the given key and return it<T> T
getIfRecentOrPut
(String key, T object, long timeToLive, TemporalUnit unit) If the given key exists and the entry is no older than the given timeToLiveMinutes, return the object stored under the key, otherwise store the given object under the given key and return it<T> Optional<T>
getIfRecentOrRemove
(String key, long timeToLiveMinutes) <T> Optional<T>
getIfRecentOrRemove
(String key, long timeToLive, TemporalUnit unit) Get an object stored under the given key.boolean
void
void
void
setMessageBroker
(MessageQueueManager messageBroker) void
setTemplateManager
(CMSTemplateManager templateManager) void
shutdown()
void
startup()
-
Constructor Details
-
PersistentStorageBean
public PersistentStorageBean()
-
-
Method Details
-
startup
- Throws:
DAOException
-
shutdown
@PreDestroy public void shutdown() -
get
- Specified by:
get
in interfaceDataStorage
-
olderThan
-
put
- Specified by:
put
in interfaceDataStorage
-
getIfRecentOrPut
If the given key exists and the entry is no older than the given timeToLiveMinutes, return the object stored under the key, otherwise store the given object under the given key and return it- Type Parameters:
T
-- Parameters:
key
- the identifier under which to store the objectobject
- the object to store under the given key if the key doesn't exist yet or is older than timeToLiveMinutestimeToLive
- the maximum age in the given time unit the stored object may have to be returned. If it's older, it will be replaced with the passed objectunit
- TheTemporalUnit
in which the timeToLive parameter is given- Returns:
- the object stored under the given key if viable, otherwise the given object
-
getIfRecentOrPut
If the given key exists and the entry is no older than the given timeToLiveMinutes, return the object stored under the key, otherwise store the given object under the given key and return it- Type Parameters:
T
- Type of the object to put- Parameters:
key
- the identifier under which to store the objectobject
- the object to store under the given key if the key doesn't exist yet or is older than timeToLiveMinutestimeToLiveMinutes
- the maximum age in minutes the stored object may have to be returned. If it's older, it will be replaced with the passed object- Returns:
- the object stored under the given key if viable, otherwise the given object
-
getIfRecentOrRemove
-
getIfRecentOrRemove
Get an object stored under the given key. If the object is older than the given time to live, it is removed and an empty Optional returned- Type Parameters:
T
- Type of the object to get/remove- Parameters:
key
- key of the object to get/removetimeToLive
- objects put within this timespan are returned, older objets are removedunit
- time unit of 'timeToLive'- Returns:
- An optional containing the requested object, or an empty optional if the key doesn't exist or the object is older than 'timeToLive'
-
contains
-
getTemplateManager
-
setTemplateManager
-
getMessageBroker
-
setMessageBroker
-
remove
-