PersistentItem (Resource Management Library 2.8.1-SNAPSHOT API)
Date: 2018-11-04

org.gcube.resourcemanagement.support.server.utils.persistence

## Class PersistentItem<T extends Serializable>

- java.lang.Object
- - org.gcube.resourcemanagement.support.server.utils.persistence.PersistentItem<T>

- All Implemented Interfaces:
    PersistenceHandler<T>

      public abstract class PersistentItem<T extends Serializable>
      extends Object
      implements PersistenceHandler<T>

  Wrapping for data that can be persisted on the filesystem.

       new PersistentItem<DataTypeToPersist>(fileToStore, refreshDelay) {
        public void onLoad() {
               //...
        }

        // The other methods to overload
        // ...

       }

  Author:
    Daniele Strollo (ISTI-CNR)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static String` | `LOG_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PersistentItem()` Deprecated. for internal use only.
    `PersistentItem(String persistenceFileName)`
    `PersistentItem(String persistenceFileName, long refreshDelay)`
    `PersistentItem(T data, String persistenceFileName, long refreshDelay)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `destroy()` Requires the destroy of the persistent resource.
    `T` | `getData()` Returns the corresponding persistent data.
    `void` | `setData(T data)` Sets the new data to persist.
    `protected void` | `setPersistenceFileName(String persistenceFileName)`
    `protected void` | `setRefreshDelay(long refreshDelay)`

    - ### Methods inherited from class java.lang.Object

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

    - ### Methods inherited from interface org.gcube.resourcemanagement.support.server.utils.persistence.PersistenceHandler

      `onDestroy, onLoad, onRefresh`

- - ### Field Detail

    - #### LOG_PREFIX

          protected static final String LOG_PREFIX

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PersistentItem

          public PersistentItem()

      Deprecated. for internal use only.

    - #### PersistentItem

          public PersistentItem(String persistenceFileName)

    - #### PersistentItem

          public PersistentItem(String persistenceFileName,
                                long refreshDelay)

    - #### PersistentItem

          public PersistentItem(T data,
                                String persistenceFileName,
                                long refreshDelay)

  - ### Method Detail

    - #### setPersistenceFileName

          protected final void setPersistenceFileName(String persistenceFileName)

    - #### setRefreshDelay

          protected final void setRefreshDelay(long refreshDelay)

    - #### destroy

          public final void destroy()

      Description copied from interface: `PersistenceHandler`
      Requires the destroy of the persistent resource. The persistent file will be deleted and the onDestroy event will be raised.
      Specified by:
        `destroy` in interface `PersistenceHandler<T extends Serializable>`

    - #### getData

          public final T getData()

      Returns the corresponding persistent data.
      Specified by:
        `getData` in interface `PersistenceHandler<T extends Serializable>`
      Returns:

    - #### setData

          public final void setData(T data)

      Description copied from interface: `PersistenceHandler`
      Sets the new data to persist.
      Specified by:
        `setData` in interface `PersistenceHandler<T extends Serializable>`

Copyright © 2018. All Rights Reserved.