|
JASMI API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.agentpp.smi.SMIRepositoryManager
public final class SMIRepositoryManager
The SMIRepositoryManager class can be used to access MIB information from a MIB repository. In order to be able to construct an instance of this class a valid license/licenseKey pair is needed. There are two types of license, one allows read access only and the other type provides read-write access to the MIB repository.
Please visit http://www.agentpp.com for information on how to obtain a license. A MIB repository is a directory on a file system, where compiled MIBs can be stored. That directory is exclusively used. Thus, only compiled MIBs may be stored in that directory. As of version 1.8 of JASMI, a MIB repository can be any type of persistent storage that supportsInputStream and OutputStream.
| Field Summary |
|---|
| Fields inherited from interface com.agentpp.smi.IRepositoryManager |
|---|
NOCHECK_INCONSISTENT_ACCESS, NOCHECK_INCONSISTENT_STATUS, NOCHECK_INCONSISTENT_SYNTAX, NOCHECK_NOT_IN_GROUP |
| Constructor Summary | |
|---|---|
SMIRepositoryManager(java.lang.String license,
java.lang.String licenseKey)
|
|
| Method Summary | |
|---|---|
void |
addModule(IModule module)
Adds a MIB module to the repository. |
IModuleInfo[] |
addModules(java.io.File file)
Adds a MIB file to the repository. |
void |
addRepositoryListener(RepositoryListener l)
Adds a RepositoryListener to this repository that provides
Input- and OutputStreams to read and write MIB modules from persistent
storage (i.e. the MIB repository). |
void |
checkModules(java.io.InputStream file)
Check whether an InputStream contains valid MIB modules. |
IModuleInfo[] |
checkModules(java.io.InputStream file,
boolean lenientSyntaxCheck)
Check whether an InputStream contains valid MIB modules. |
java.lang.Integer |
createModuleID()
Creates a new unique module ID for the current MIB repository. |
void |
deleteModule(RepositoryEvent e)
Requests deletion of the MIB module identified by the module name supplied with the RepositoryEvent object. |
java.lang.String |
getErrorText(int errorCode,
java.lang.String message)
Get an error text from the error code and error message of the SMIParseException. |
java.lang.String |
getErrorText(com.agentpp.smiparser.SMIParseException parseException)
Get an error text for a SMIParseException. |
IObject[] |
getImportedObjects(java.lang.String moduleName)
Get those MIBObjects for a MIB module with the specified name, that are imported from other MIBs. |
IObject[] |
getImportedObjects(java.lang.String moduleName,
java.util.Hashtable moduleIDs)
Get those MIBObjects for a MIB module with the specified name, that are imported from other MIBs. |
int |
getMaxErrors()
Returns the maximum number of errors the repository manager will collect until bailing out when parsing/compiling a MIB file. |
IModule |
getModule(java.lang.String moduleName)
Return a given MIB module including its objects. |
IModuleInfo[] |
getModuleInfo(java.io.File file)
Get MIB module information (module name and imports) from a MIB file. |
IModuleInfo[] |
getModuleInfo(java.io.InputStream file,
java.lang.String name)
Get MIB module information (module name and imports) from an input stream. |
IModuleInfo[] |
getModuleInfos()
Get module information about all MIB modules in the MIB repository. |
java.lang.String[] |
getModuleNames()
Return an array of all module names available from the repository managed by the receiver. |
IModule[] |
getModules()
Return an array of all MIB modules. |
IModule[] |
getModules(java.io.InputStream file,
ImportModuleListener listener)
Get the modules contained in a MIB file. |
IObject[] |
getObjects(java.lang.String moduleName)
Get the MIBObjects of the MIB module with the given name. |
int |
getParserOptions()
Get actual parser options. |
java.io.File |
getRepositoryDirectory()
Gets the repository directory used to store compiled MIB modules by default. |
void |
initialize()
Initialize the repository, thus remove all modules from the repository. |
boolean |
isReadOnly()
Check whether the repository manager can be used to modify a MIB repository or not. |
java.lang.String[] |
listModuleNames()
Enumerates the available MIB module names in the repository. |
void |
open(java.io.File directory)
Open the MIB Repository located at the given path. |
void |
readModule(RepositoryEvent e)
Requests to read a MIB module with the name specified in the supplied event object. |
boolean |
removeModule(java.lang.String moduleName)
Remove a module from the repository. |
void |
removeRepositoryListener(RepositoryListener l)
Removes a RepositoryListener from this repository. |
void |
setMaxErrors(int maxErrors)
Sets the maximum number of errors the repository manager will collect until bailing out when parsing/compiling a MIB file. |
void |
setParserOptions(int options)
Set parser options. |
void |
writeModule(RepositoryEvent e)
Requests to write a MIB module with the name specified in the supplied event object. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SMIRepositoryManager(java.lang.String license,
java.lang.String licenseKey)
| Method Detail |
|---|
public void open(java.io.File directory)
throws java.io.IOException
IRepositoryManager
open in interface IRepositoryManagerdirectory - a possibly empty directory to store MIB repository data.
java.io.IOException - if given MIB repository path is invalid.
public IModuleInfo[] addModules(java.io.File file)
throws com.agentpp.smiparser.SMIParseException
IRepositoryManager
addModules in interface IRepositoryManagerfile - a file containing one or more MIB modules.
com.agentpp.smiparser.SMIParseException - if file contains any errors.
public void addModule(IModule module)
throws java.io.IOException
IRepositoryManager
addModule in interface IRepositoryManagermodule - an IModule instance that will be written to the MIB repository.
RepositoryEvent listeners will be called to provide
an alternative output stream.
java.io.IOException
public IModule[] getModules(java.io.InputStream file,
ImportModuleListener listener)
throws com.agentpp.smiparser.SMIParseException
IRepositoryManager
getModules in interface IRepositoryManagerfile - an InputStream containing one or more MIB modules.listener - an ImportModuleListener instance used as callback to parse or load
objects of imported MIB modules and for creating a module ID for
any MIB modules parsed from stream.
com.agentpp.smiparser.SMIParseException - if any syntax or semantic
error has been detected in file.
public void checkModules(java.io.InputStream file)
throws com.agentpp.smiparser.SMIParseException
IRepositoryManager
checkModules in interface IRepositoryManagerfile - an InputStream containing SMIv1/v2 MIB module(s).
com.agentpp.smiparser.SMIParseException - if file has an error.
public IModuleInfo[] checkModules(java.io.InputStream file,
boolean lenientSyntaxCheck)
throws com.agentpp.smiparser.SMIParseException
IRepositoryManager
checkModules in interface IRepositoryManagerfile - an InputStream containing SMIv1/v2 MIB module(s).lenientSyntaxCheck - if true the syntax checking is minimal, otherwise
it is the default (SMI standard).
com.agentpp.smiparser.SMIParseException - if the syntax check fails.
public IModuleInfo[] getModuleInfo(java.io.File file)
throws com.agentpp.smiparser.SMIParseException
IRepositoryManager
getModuleInfo in interface IRepositoryManagerfile - a SMIv1/v2 MIB File instance.
com.agentpp.smiparser.SMIParseException - if file contains any errors.
public IModuleInfo[] getModuleInfo(java.io.InputStream file,
java.lang.String name)
throws com.agentpp.smiparser.SMIParseException
IRepositoryManager
getModuleInfo in interface IRepositoryManagerfile - an InputStream instance containing SMIv1/v2 MIB modules.name - a String representing name of the source, for example the path of a
FileInputStream.
com.agentpp.smiparser.SMIParseException - if inputStream contains any errors.
public IModuleInfo[] getModuleInfos()
throws java.io.IOException
IRepositoryManager
getModuleInfos in interface IRepositoryManagerjava.io.IOException - if the MIB repository is invalid or on any other IO error.
public boolean removeModule(java.lang.String moduleName)
throws java.io.IOException
IRepositoryManager
removeModule in interface IRepositoryManagermoduleName - the name of the victim.
java.io.IOException
public void initialize()
throws java.io.IOException
IRepositoryManager
initialize in interface IRepositoryManagerjava.io.IOException - thrown if an exception occured while accessing the MIB repository.
public IModule[] getModules()
throws java.io.IOException
IRepositoryManager
getModules in interface IRepositoryManagerjava.io.IOException
public IModule getModule(java.lang.String moduleName)
throws java.io.IOException
IRepositoryManager
getModule in interface IRepositoryManagermoduleName - a module name.
java.io.IOException
public java.lang.String[] getModuleNames()
throws java.io.IOException
IRepositoryManager
getModuleNames in interface IRepositoryManagerjava.io.IOException
public IObject[] getObjects(java.lang.String moduleName)
throws java.io.IOException
IRepositoryManager
getObjects in interface IRepositoryManagermoduleName - the name of a MIB module.
java.io.IOException
public IObject[] getImportedObjects(java.lang.String moduleName)
throws java.io.IOException
IRepositoryManager
getImportedObjects in interface IRepositoryManagermoduleName - the name of a MIB module.
java.io.IOException
public IObject[] getImportedObjects(java.lang.String moduleName,
java.util.Hashtable moduleIDs)
throws java.io.IOException
IRepositoryManager
getImportedObjects in interface IRepositoryManagermoduleName - the name of a MIB module.moduleIDs - an empty Hashtable. On return, it contains a mapping from
all module names of the visited MIB modules to their respective module
IDs.
java.io.IOExceptionpublic boolean isReadOnly()
public java.lang.String getErrorText(com.agentpp.smiparser.SMIParseException parseException)
IRepositoryManager
getErrorText in interface IRepositoryManagerparseException - a com.agentpp.smiparser.SMIParseException.
public java.lang.String getErrorText(int errorCode,
java.lang.String message)
IRepositoryManager
getErrorText in interface IRepositoryManagererrorCode - the errorCode from a com.agentpp.smiparser.SMIParseException.message - the message of a com.agentpp.smiparser.SMIParseException.
public void setParserOptions(int options)
IRepositoryManager
setParserOptions in interface IRepositoryManageroptions - a bitwise OR of option values.public int getParserOptions()
IRepositoryManager
getParserOptions in interface IRepositoryManagerpublic java.io.File getRepositoryDirectory()
IRepositoryManagerIRepositoryManager.addRepositoryListener(com.agentpp.smi.event.RepositoryListener) method.
getRepositoryDirectory in interface IRepositoryManagerFile instance representing a directory.public void removeRepositoryListener(RepositoryListener l)
IRepositoryManagerRepositoryListener from this repository. If no
listeners are left, MIB modules will be read and written from the default
MIB repository directory.
removeRepositoryListener in interface IRepositoryManagerl - a RepositoryListener.public void addRepositoryListener(RepositoryListener l)
IRepositoryManagerRepositoryListener to this repository that provides
Input- and OutputStreams to read and write MIB modules from persistent
storage (i.e. the MIB repository). This can be used, for example, to
store and read compiled MIB modules from JAR or ZIP files instead from a
directory, which is the default.
addRepositoryListener in interface IRepositoryManagerl - a RepositoryListener that provides InputStreams
and OutputStreams on demand to read or write a precompiled
MIB module identified by its name from persistent storage.public void writeModule(RepositoryEvent e)
RepositoryListenerOutputStream
member of the supplied event object.
writeModule in interface RepositoryListenere - a RepositoryEvent with the module name of the MIB module
that should be written to persistent storage. The implementor of this
interface should set the OutputStream of event.public void readModule(RepositoryEvent e)
RepositoryListenerInputStream
member of the supplied event object.
readModule in interface RepositoryListenere - a RepositoryEvent with the module name of the MIB module
that should be read from persistent storage. The implementor of this
interface should set the InputStream of event.public void deleteModule(RepositoryEvent e)
RepositoryListenerRepositoryEvent object.
deleteModule in interface RepositoryListenere - a RepositoryEvent with the module name of the MIB module
that should be removed from persistent MIB repository storage. If
a listener has successfully removed the module, it must set the
corresponding flag in the supplied event object.public void setMaxErrors(int maxErrors)
maxErrors - the maximum number of errors detected for each MIB file.public int getMaxErrors()
public java.lang.Integer createModuleID()
throws java.io.IOException
IRepositoryManagerIModule instance when this instance has been created
programmatically by using means provided by the JASMI Ext API for example.
When parsing MIB modules from a text source file, a module ID is automatically allocated.
When a MIB module is removed from a IB repository, its module ID is freed and can be reused again for any other new module.
createModuleID in interface IRepositoryManagerjava.io.IOExceptionpublic java.lang.String[] listModuleNames()
RepositoryListener
listModuleNames in interface RepositoryListenernull if that method is not
supported by the listener.
|
JASMI API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||