- java.lang.Object
-
- org.snmp4j.agent.io.DefaultMOPersistenceProvider
-
- All Implemented Interfaces:
MOPersistenceProvider
public class DefaultMOPersistenceProvider extends Object implements MOPersistenceProvider
TheDefaultMOPersistenceProvider
provides agent state persistence using a file withDefaultMOInput
andDefaultMOOutput
input/output.- Version:
- 1.2
- Author:
- Frank Fock
-
-
Constructor Summary
Constructors Constructor Description DefaultMOPersistenceProvider(MOServer[] server, String defaultURI)
Creates a persistence provider for the suppliedMOServer
instances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getDefaultURI()
Gets the URI of the default persistent storage for this provider.String
getPersistenceProviderID()
Returns an unique ID of the persistence provider which should identify the format and type of the persistence provider.boolean
isValidPersistenceURI(String uri)
Checks whether the supplied URI string is valid for this persistence provider.void
restore(String uri, int importMode)
Restore (load) agent state from the specified file URI or file name.void
store(String uri)
Stores the current agent state to persistent storage specified by the supplied URI.void
store(String uri, MOPriorityProvider priorityProvider)
Stores the current agent state to persistent storage specified by the supplied URI in the order defined by the givenMOPriorityProvider.getPriorityMap(OctetString)
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.snmp4j.agent.io.MOPersistenceProvider
restore
-
-
-
-
Constructor Detail
-
DefaultMOPersistenceProvider
public DefaultMOPersistenceProvider(MOServer[] server, String defaultURI)
Creates a persistence provider for the suppliedMOServer
instances. The content and state of the managed objects of those servers are subject tostore(java.lang.String)
andrestore(java.lang.String, int)
operations.- Parameters:
server
- an array ofMOServer
instances (possibly empty).defaultURI
- the (optional) default URI (i.e., file path) to be used for this persistence provider.
-
-
Method Detail
-
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 interfaceMOPersistenceProvider
- Returns:
- "default".
-
isValidPersistenceURI
public boolean isValidPersistenceURI(String uri)
Checks whether the supplied URI string is valid for this persistence provider.- Specified by:
isValidPersistenceURI
in interfaceMOPersistenceProvider
- Parameters:
uri
- a string identifying a persistent storage location for this storage provider.- Returns:
true
if theuri
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 interfaceMOPersistenceProvider
- 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 interfaceMOPersistenceProvider
- Parameters:
uri
- a string pointing to the persistent storage file to use. The format of he 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 givenMOPriorityProvider.getPriorityMap(OctetString)
.- Specified by:
store
in interfaceMOPersistenceProvider
- 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. Anull
value can be specified to let the persistence provider use its default URI. If that default URI isnull
too, aNullPointerException
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 interfaceMOPersistenceProvider
- 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.
-
-