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 Details

    • PersistentStorageBean

      public PersistentStorageBean()
  • Method Details

    • startup

      @PostConstruct public void startup() throws DAOException
      Throws:
      DAOException
    • shutdown

      @PreDestroy public void shutdown()
    • get

      public Object get(String key)
      Specified by:
      get in interface DataStorage
    • olderThan

      public boolean olderThan(String key, Instant time)
    • put

      public void put(String key, Object object)
      Specified by:
      put in interface DataStorage
    • getIfRecentOrPut

      public <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
      Type Parameters:
      T -
      Parameters:
      key - the identifier under which to store the object
      object - the object to store under the given key if the key doesn't exist yet or is older than timeToLiveMinutes
      timeToLive - 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 object
      unit - The TemporalUnit in which the timeToLive parameter is given
      Returns:
      the object stored under the given key if viable, otherwise the given object
    • getIfRecentOrPut

      public <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
      Parameters:
      key - the identifier under which to store the object
      object - the object to store under the given key if the key doesn't exist yet or is older than timeToLiveMinutes
      timeToLiveMinutes - 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

      public <T> Optional<T> getIfRecentOrRemove(String key, long timeToLiveMinutes)
    • getIfRecentOrRemove

      public <T> Optional<T> getIfRecentOrRemove(String key, long timeToLive, TemporalUnit unit)
    • contains

      public boolean contains(String key)
    • getTemplateManager

      public CMSTemplateManager getTemplateManager()
    • setTemplateManager

      public void setTemplateManager(CMSTemplateManager templateManager)
    • getMessageBroker

      public MessageQueueManager getMessageBroker()
    • setMessageBroker

      public void setMessageBroker(MessageQueueManager messageBroker)
    • remove

      public void remove(String key)