- java.lang.Object
-
- org.snmp4j.agent.io.DefaultMOPersistenceProvider
-
- All Implemented Interfaces:
MOPersistenceProvider
public class DefaultMOPersistenceProvider extends Object implements MOPersistenceProvider
TheDefaultMOPersistenceProviderprovides agent state persistence using a file withDefaultMOInputandDefaultMOOutputinput/output.- Version:
- 1.2
- Author:
- Frank Fock
-
-
Constructor Summary
Constructors Constructor Description DefaultMOPersistenceProvider(MOServer[] server, String defaultURI)Creates a persistence provider for the suppliedMOServerinstances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetDefaultURI()Gets the URI of the default persistent storage for this provider.StringgetPersistenceProviderID()Returns an unique ID of the persistence provider which should identify the format and type of the persistence provider.booleanisValidPersistenceURI(String uri)Checks whether the supplied URI string is valid for this persistence provider.voidrestore(String uri, int importMode)Restore (load) agent state from the specified file URI or file name.voidstore(String uri)Stores the current agent state to persistent storage specified by the supplied URI.
-
-
-
Constructor Detail
-
DefaultMOPersistenceProvider
public DefaultMOPersistenceProvider(MOServer[] server, String defaultURI)
Creates a persistence provider for the suppliedMOServerinstances. 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 ofMOServerinstances (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:
getPersistenceProviderIDin interfaceMOPersistenceProvider- Returns:
- "default".
-
isValidPersistenceURI
public boolean isValidPersistenceURI(String uri)
Checks whether the supplied URI string is valid for this persistence provider.- Specified by:
isValidPersistenceURIin interfaceMOPersistenceProvider- Parameters:
uri- a string identifying a persistent storage location for this storage provider.- Returns:
trueif theuriis valid,falseotherwise.
-
restore
public void restore(String uri, int importMode) throws IOException
Restore (load) agent state from the specified file URI or file name.- Specified by:
restorein 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:
storein 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
public String getDefaultURI()
Description copied from interface:MOPersistenceProviderGets the URI of the default persistent storage for this provider.- Specified by:
getDefaultURIin 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
nullvalue indicates that there is no default location.
-
-