Package org.snmp4j.agent.io
Class DefaultMOPersistenceProvider
java.lang.Object
org.snmp4j.agent.io.DefaultMOPersistenceProvider
- All Implemented Interfaces:
MOPersistenceProvider
The
DefaultMOPersistenceProvider
provides agent state
persistence using a file with DefaultMOInput
and
DefaultMOOutput
input/output.- Version:
- 1.2
- Author:
- Frank Fock
-
Constructor Summary
ConstructorDescriptionDefaultMOPersistenceProvider
(MOServer[] server, String defaultURI) Creates a persistence provider for the suppliedMOServer
instances. -
Method Summary
Modifier and TypeMethodDescriptionGets the URI of the default persistent storage for this provider.Returns an unique ID of the persistence provider which should identify the format and type of the persistence provider.boolean
Checks whether the supplied URI string is valid for this persistence provider.void
Restore (load) agent state from the specified file URI or file name.void
Stores the current agent state to persistent storage specified by the supplied URI.
-
Constructor Details
-
DefaultMOPersistenceProvider
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 Details
-
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
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
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
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.
-
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.
-