Class DefaultMOPersistenceProvider

java.lang.Object
org.snmp4j.agent.io.DefaultMOPersistenceProvider
All Implemented Interfaces:
MOPersistenceProvider

public class DefaultMOPersistenceProvider extends Object implements MOPersistenceProvider
The DefaultMOPersistenceProvider provides agent state persistence using a file with DefaultMOInput and DefaultMOOutput input/output.
Version:
1.2
Author:
Frank Fock
  • Constructor Details

    • DefaultMOPersistenceProvider

      public DefaultMOPersistenceProvider(MOServer[] server, String defaultURI)
      Creates a persistence provider for the supplied MOServer instances. The content and state of the managed objects of those servers are subject to store(java.lang.String) and restore(java.lang.String, int) operations.
      Parameters:
      server - an array of MOServer instances (possibly empty).
      defaultURI - the (optional) default URI (i.e., file path) to be used for this persistence provider.
  • Method Details

    • getPersistenceProviderID

      public String getPersistenceProviderID()
      Returns an unique ID of the persistence provider which should identify the format and type of the persistence provider.
      Specified by:
      getPersistenceProviderID in interface MOPersistenceProvider
      Returns:
      "default".
    • isValidPersistenceURI

      public boolean isValidPersistenceURI(String uri)
      Checks whether the supplied URI string is valid for this persistence provider.
      Specified by:
      isValidPersistenceURI in interface MOPersistenceProvider
      Parameters:
      uri - a string identifying a persistent storage location for this storage provider.
      Returns:
      true if the uri is valid, false otherwise.
    • restore

      public void restore(String uri, int importMode) throws IOException
      Restore (load) agent state from the specified file URI or file name.
      Specified by:
      restore in interface MOPersistenceProvider
      Parameters:
      uri - a string pointing to the persistent storage file from which the agent state should be restored from. The format of he string is either a simple file name or an URI starting with "file:".
      importMode - specifies how the agent's current state should be update while restoring a previous state.
      Throws:
      IOException - if the restore operation fails.
    • store

      public void store(String uri) throws IOException
      Stores the current agent state to persistent storage specified by the supplied URI.
      Specified by:
      store in interface MOPersistenceProvider
      Parameters:
      uri - a string pointing to the persistent storage file to use. The format of the string is either a simple file name or an URI starting with "file:".
      Throws:
      IOException - if the store operation fails.
    • store

      public void store(String uri, MOPriorityProvider priorityProvider) throws IOException
      Description copied from interface: MOPersistenceProvider
      Stores the current agent state to persistent storage specified by the supplied URI in the order defined by the given MOPriorityProvider.getPriorityMap(OctetString).
      Specified by:
      store in interface MOPersistenceProvider
      Parameters:
      uri - a string pointing to the persistent storage from which the agent state should be restored from. The format of the string is specified by the persistence provider. A null value can be specified to let the persistence provider use its default URI. If that default URI is null too, a NullPointerException will be thrown.
      priorityProvider - provides the boot managed object and its priority map that defines the order of storing all other managed objects.
      Throws:
      IOException - if the store operation fails.
    • getDefaultURI

      public String getDefaultURI()
      Description copied from interface: MOPersistenceProvider
      Gets the URI of the default persistent storage for this provider.
      Specified by:
      getDefaultURI in interface MOPersistenceProvider
      Returns:
      the URI (e.g. file path) for the default persistent storage location of this provider. A provider may use a different one. A null value indicates that there is no default location.