|
AdventNet CLI 2.0 API Specification | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This is the RMI interface implemented by the CLISessionImpl class. The interface provides methods which are normally available in the non RMI CLISession class.
| Method Summary | |
void |
addCLIClient(CLIClient client)
Registers the CLIClient for receiving the asynchronous Response for a asyn request. |
void |
addConnectionListener(com.adventnet.cli.rmi.ConnectionListener conListener)
Registers the connectionListener, if not already registered as a listener. |
void |
close()
Closes the CLISession and stops the asynch receiver thread. |
int |
getCLIClientsSize()
Gets the count of clients that have registered for callback. |
java.lang.String |
getCLIPrompt()
Gets the CLI Prompt for this session. |
java.util.Properties |
getCLIPromptAction()
Gets the prompt list. |
CLIProtocolOptions |
getCLIProtocolOptions()
Gets the CLIProtocolOptions for this session. |
int |
getDebugLevel()
Gets the debug level. |
java.lang.String |
getInitialMessage()
Gets the initial Message sent by the device after a successful connection establishment. |
java.lang.String |
getInterruptCmd()
Gets the interrupt command. |
int |
getKeepAliveTimeout()
Gets the keepAlive time-out in seconds. |
int |
getMaxConnections()
Gets the maximum no of CLI Connections that can exist for this session. |
int |
getRequestTimeout()
Gets the time-out in milliseconds for this request message. |
CLIResourceManager |
getResourceManager()
Gets the CLIResourceManager which manages the System Resources. |
java.lang.String |
getTransportProviderClassName()
Gets the Transport Provider Class name. |
boolean |
isSetDebug()
Gets the debug flag. |
boolean |
isSetIgnoreSpecialCharacters()
Returns whether the ignoring of special characters is enabled or not. |
boolean |
isSetPooling()
Gets the pooling Flag of this Session. |
void |
open()
Opens the CLI connection with the remote device based on the CLIProtocolOptions set. |
void |
removeCLIClient(CLIClient client)
Unregisters or removes the CLIClient from the list of clients that have already registered for callback to receive asynchronous responses. |
void |
removeConnectionListener(com.adventnet.cli.rmi.ConnectionListener conListener)
Unregisters the listener, if it is registered as a ConnectionListener. |
int |
send(CLIMessage cliMsg)
Sends the CLIMessage asynchronously. |
void |
setCLIPrompt(java.lang.String cliPrompt)
Sets the CLI Prompt for this session. |
void |
setCLIPromptAction(java.util.Properties prop)
Sets the prompt list. |
void |
setCLIProtocolOptions(CLIProtocolOptions cliProtocolOptions)
Sets the CLIProtocolOptions for this session. |
void |
setDebug(boolean debug)
Sets the debug flag. |
void |
setDebugLevel(int level)
Sets the debug level. |
void |
setIgnoreSpecialCharacters(boolean ignore)
Enables stripping of special characters in the response message. |
void |
setInterruptCmd(java.lang.String cmd)
Sets the interrupt command. |
void |
setKeepAliveTimeout(int timeout)
Sets the keepAlive time-out in seconds. |
void |
setMaxConnections(int connections)
Sets the maximum no of CLI Connections that can exist for this session. |
void |
setPooling(boolean poolFlag)
Enables/Disables the pooling of CLITransport Sessions. |
void |
setRequestTimeout(int timeout)
Sets the time-out for this request message. |
void |
setTransportProviderClassName(java.lang.String className)
Sets the Transport Provider Class name. |
CLIMessage |
syncSend(CLIMessage cliMsg)
Sends the CLIMessage synchronously. |
| Method Detail |
public void open()
throws java.rmi.RemoteException
public void setTransportProviderClassName(java.lang.String className)
throws java.rmi.RemoteException
className - The provider classname.
public java.lang.String getTransportProviderClassName()
throws java.rmi.RemoteException
public void setCLIProtocolOptions(CLIProtocolOptions cliProtocolOptions)
throws java.rmi.RemoteException
cliProtocolOptions - the CLI protocol options.
public CLIProtocolOptions getCLIProtocolOptions()
throws java.rmi.RemoteException
public void setCLIPrompt(java.lang.String cliPrompt)
throws java.rmi.RemoteException
cliPrompt - the CLI prompt.
public java.lang.String getCLIPrompt()
throws java.rmi.RemoteException
public void setPooling(boolean poolFlag)
throws java.rmi.RemoteException
poolFlag - the flag to enable pooling. If true, the sharing of
the Transport Connections is enabled.
public boolean isSetPooling()
throws java.rmi.RemoteException
public void setMaxConnections(int connections)
throws java.rmi.RemoteException
connection - count.
public int getMaxConnections()
throws java.rmi.RemoteException
public CLIMessage syncSend(CLIMessage cliMsg)
throws java.rmi.RemoteException
cliMsg - the CLIMessage to be sent.
public void addCLIClient(CLIClient client)
throws java.rmi.RemoteException
client - the CLIClient.
public int send(CLIMessage cliMsg)
throws java.rmi.RemoteException
cliMsg - the CLIMessage to be sent.
public void close()
throws java.rmi.RemoteException
public void setRequestTimeout(int timeout)
throws java.rmi.RemoteException
timeout - The time-out value(in milliseconds).
public int getRequestTimeout()
throws java.rmi.RemoteException
public void setKeepAliveTimeout(int timeout)
throws java.rmi.RemoteException
timeout - the time-out value (in seconds).
public int getKeepAliveTimeout()
throws java.rmi.RemoteException
public void setDebug(boolean debug)
throws java.rmi.RemoteException
debug - if true, enables debug messages. If false, disables it.
public boolean isSetDebug()
throws java.rmi.RemoteException
public void setDebugLevel(int level)
throws java.rmi.RemoteException
1 - Normal. 2 - Critical.
level - the debug level.
public int getDebugLevel()
throws java.rmi.RemoteException
public void setIgnoreSpecialCharacters(boolean ignore)
throws java.rmi.RemoteException
a) ASCII characters from 32 to 126 inclusive. b) 10 (New Line) and 9 (Horizontal Tab).
ignore - boolean to enable or disable ignoring of special
characters.
public boolean isSetIgnoreSpecialCharacters()
throws java.rmi.RemoteException
public java.lang.String getInitialMessage()
throws java.rmi.RemoteException
public void removeCLIClient(CLIClient client)
throws java.rmi.RemoteException
client - the CLIClient.
public int getCLIClientsSize()
throws java.rmi.RemoteException
public void addConnectionListener(com.adventnet.cli.rmi.ConnectionListener conListener)
throws java.rmi.RemoteException
conListener - the connectionListener to be registered. Registers
only if it is a non null.removeConnectionListener(ConnectionListener)
public void removeConnectionListener(com.adventnet.cli.rmi.ConnectionListener conListener)
throws java.rmi.RemoteException
conListener - the ConnectionListener to be unregistered.addConnectionListener(ConnectionListener)
public java.util.Properties getCLIPromptAction()
throws java.rmi.RemoteException
(i.e.) prop.setProperty(prompt,"");and this will be assumed as the command prompt.
This will be used when the CLIPromptAction in the message is not set.
setCLIPromptAction(Properties),
getInterruptCmd(),
CLIMessage#getCLIPromptAction()
public void setCLIPromptAction(java.util.Properties prop)
throws java.rmi.RemoteException
prop.setProperty(prompt, cmd);
When no action or command is defined for a prompt, it will be
assumed as the command prompt. Note that the suffix, if any, should
also be given in the command set for the prompt, as no
suffix would be appended to the command, when it is sent.
An example for the use of CLIPromptAction can be, in the case of commands that returns a response, which runs for more than the screen size. For such commands (in case of the Cisco router), a "--More--" prompt appears, which requires further commands or key input. A sample code snippet would look like:
Properties prop = new Properties();
prop.setProperty(">",""); // the command prompt
prop.setProperty("--More--"," ");
cliSession.setCLIPromptAction(prop);
CLIMessage climsg = new CLIMessage("show interfaces");
CLIMessage response = cliSession.syncSend(climsg);
System.out.println("response obtained "+response);
Here 'cliSession' is the CLISession instance. Whenever the "--More--"
prompt appears, a " "(space) will be sent. Hence the 'response' obtained
is the complete response for the command sent.prompts - prompts and its command as a Properties object.getCLIPromptAction(),
setInterruptCmd(String),
CLIMessage#setCLIPromptAction(Properties)
public java.lang.String getInterruptCmd()
throws java.rmi.RemoteException
Normally the session waits for a time of requestTimeout for the response and throws an exception when the response is not obtained within the specified time interval. But when the interrupt command is set and response is not obtained, the message/command previously sent to the device is aborted by sending this command and the partial result for the message is returned to the user. The interrupt command can be any string (like the ascii value of 'Control C').
String valuesetInterruptCmd(String)
public void setInterruptCmd(java.lang.String cmd)
throws java.rmi.RemoteException
This is the command which will be sent by the session, when the complete response for the message sent, is not obtained. This happens when none of the prompts in the message or in the session, matches the prompt returned by the device or the response is not obtained. In this case, the session sends the interrupt command (thus aborting the message/command previously sent to the device) and returns the partial response for the message sent.
For instance, when a 'ls |more' command is sent to a unix machine, it prompts with a '--More--' for further key input. When a ' ' is typed it scrolls the next screen or when ^c is sent it exits. But when '--More--' is not specified as one of the prompts, the command is incomplete. So if the ascii value of '^c' is set using,
cliSession.setInterruptCmd("\003")
this will be sent when the request message timesout and
the command will be aborted. cmd - the interrupt command as a String value.getInterruptCmd()
public CLIResourceManager getResourceManager()
throws java.rmi.RemoteException
For instance, when you have finished using the CLI APIs, closed the session and would like to close all connections(non-dedicated) managed by the session,
clisession.getResourceManager().closeAllConnections();method can be invoked.
|
AdventNet CLI 2.0 API Specification | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||