Class H2KVStorePlugin

java.lang.Object
io.vertigo.datastore.plugins.kvstore.h2.H2KVStorePlugin
All Implemented Interfaces:
io.vertigo.core.node.component.Activeable, io.vertigo.core.node.component.CoreComponent, io.vertigo.core.node.component.Plugin, io.vertigo.core.node.definition.DefinitionProvider, io.vertigo.core.node.definition.SimpleDefinitionProvider, KVStorePlugin

public final class H2KVStorePlugin extends Object implements KVStorePlugin, io.vertigo.core.node.definition.SimpleDefinitionProvider, io.vertigo.core.node.component.Activeable
Memory implementation of H2KVStorePlugin. Purge is garantee by Timer every minute.
Author:
mlaroche, pchretien, npiedeloup
  • Constructor Summary

    Constructors
    Constructor
    Description
    H2KVStorePlugin(String collections, String dbFilePath, io.vertigo.commons.transaction.VTransactionManager transactionManager, io.vertigo.commons.codec.CodecManager codecManager, io.vertigo.core.analytics.AnalyticsManager analyticsManager)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clear(KVCollection collection)
    Removes all elements from a collection.
    int
    count(KVCollection collection)
    <C> Optional<C>
    find(KVCollection collection, String key, Class<C> clazz)
    Finds the optional element to which the id is mapped inside the specified collection.
    <C> List<C>
    findAll(KVCollection collection, int skip, Integer limit, Class<C> clazz)
    Finds all elements contained inside the specified collection.
    Returns the list of collections managed by this plugin.
    List<? extends io.vertigo.core.node.definition.Definition>
    provideDefinitions(io.vertigo.core.node.definition.DefinitionSpace definitionSpace)
     
    void
    put(KVCollection collection, String key, Object element)
    Adds an element defined by an id in a collection.
    boolean
    remove(KVCollection collection, String key)
    Removes an element defined by an id from a collection.
    void
    void

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.vertigo.core.node.definition.DefinitionProvider

    addDefinitionResourceConfig

    Methods inherited from interface io.vertigo.core.node.definition.SimpleDefinitionProvider

    get
  • Constructor Details

    • H2KVStorePlugin

      @Inject public H2KVStorePlugin(String collections, String dbFilePath, io.vertigo.commons.transaction.VTransactionManager transactionManager, io.vertigo.commons.codec.CodecManager codecManager, io.vertigo.core.analytics.AnalyticsManager analyticsManager)
      Constructor.
      Parameters:
      collections - List of collections managed by this plugin (comma separated)
      timeToLiveSeconds - life time of elements (seconde)
  • Method Details

    • start

      public void start()
      Specified by:
      start in interface io.vertigo.core.node.component.Activeable
    • stop

      public void stop()
      Specified by:
      stop in interface io.vertigo.core.node.component.Activeable
    • provideDefinitions

      public List<? extends io.vertigo.core.node.definition.Definition> provideDefinitions(io.vertigo.core.node.definition.DefinitionSpace definitionSpace)
      Specified by:
      provideDefinitions in interface io.vertigo.core.node.definition.SimpleDefinitionProvider
    • getCollections

      public List<KVCollection> getCollections()
      Returns the list of collections managed by this plugin.
      Specified by:
      getCollections in interface KVStorePlugin
      Returns:
      list of collections;
    • count

      public int count(KVCollection collection)
      Specified by:
      count in interface KVStorePlugin
      Parameters:
      collection - the collection
      Returns:
      count of elements into collection
    • put

      public void put(KVCollection collection, String key, Object element)
      Adds an element defined by an id in a collection.
      Specified by:
      put in interface KVStorePlugin
      Parameters:
      collection - the collection
      key - the id
      element - the element
    • remove

      public boolean remove(KVCollection collection, String key)
      Removes an element defined by an id from a collection.
      Specified by:
      remove in interface KVStorePlugin
      Parameters:
      collection - the collection
      key - the id
      Returns:
      if element exists before removed
    • clear

      public void clear(KVCollection collection)
      Removes all elements from a collection.
      Specified by:
      clear in interface KVStorePlugin
      Parameters:
      collection - the collection
    • find

      public <C> Optional<C> find(KVCollection collection, String key, Class<C> clazz)
      Finds the optional element to which the id is mapped inside the specified collection. If the element is not found then an empty option is returned.
      Specified by:
      find in interface KVStorePlugin
      Type Parameters:
      C - Element type
      Parameters:
      collection - the collection
      key - the id
      clazz - the type of the searched element
      Returns:
      the option
    • findAll

      public <C> List<C> findAll(KVCollection collection, int skip, Integer limit, Class<C> clazz)
      Finds all elements contained inside the specified collection.
      Specified by:
      findAll in interface KVStorePlugin
      Type Parameters:
      C - Element type
      Parameters:
      collection - the collection
      skip - the position from which the elements are returned
      limit - the limit size of elements
      clazz - the type of the searched element
      Returns:
      the list of elements.