com.adventnet.cli.transport
Class TelnetTransportImpl

java.lang.Object
  |
  +--com.adventnet.cli.transport.TelnetTransportImpl

public class TelnetTransportImpl
extends java.lang.Object
implements CLITransportProvider

The telnet implementation of the CLITransportProvider for sending commands through telnet.


Fields inherited from interface com.adventnet.cli.transport.CLITransportProvider
STREAM_CLOSED
 
Constructor Summary
TelnetTransportImpl()
          Creates an instance of this Telnet provider.
 
Method Summary
 void close()
          This closes the telnet connection to the remote device.
 void open(CLIProtocolOptions cliProtOpt)
          Opens a telnet connection to the remote device.
 CLIMessage read()
          Receives the CLI message from the opened telnet connection.
 void write(CLIMessage cliMsg)
          Sends the command in the CLIMessage using the opened telnet connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TelnetTransportImpl

public TelnetTransportImpl()
Creates an instance of this Telnet provider. API users need not instantiate this class since it is instantiated internally by CLIResourceManager.
Method Detail

open

public void open(CLIProtocolOptions cliProtOpt)
          throws java.lang.Exception,
                 ConnectException,
                 LoginException
Opens a telnet connection to the remote device. Parameters like the Remote Host, Port, Login name and password are taken from the CLIProtocolOptions parameter that is passed to the method. The perform ping (one of the parameters passed in the CLIProtocolOptions) will check if the device is alive, by doing a ping, before opening a connection to the device. If the ping succeeds, a connection is established with the device, else ConnectException is thrown.
Specified by:
open in interface CLITransportProvider
Parameters:
cliProtOpt - the CLIProtocolOptions with the telnet parameters.
Throws:
java.lang.Exception - thrown when an error occurs while trying to telnet to the remote device. The exception will be an instance of ConnectException if unable to connect to the specified host and port and will be an instance of LoginException if any of the login parameters like username and password is incorrect.

close

public void close()
           throws java.lang.Exception
This closes the telnet connection to the remote device.
Specified by:
close in interface CLITransportProvider
Throws:
java.lang.Exception - if any error occurs during the closing of the telnet connection.

write

public void write(CLIMessage cliMsg)
           throws java.io.IOException
Sends the command in the CLIMessage using the opened telnet connection. The CLI command to be sent will be present in a byte array in the CLIMessage argument.
Specified by:
write in interface CLITransportProvider
Parameters:
cliMsg - the CLIMessage that has to be sent. The CLI command (as a string) is obtained by calling cliMsg.getData().
Throws:
java.io.IOException - if error occurs while writing the data.

read

public CLIMessage read()
                throws java.io.IOException
Receives the CLI message from the opened telnet connection. The CLI response is read into the CLIMessage and returned.
Specified by:
read in interface CLITransportProvider
Returns:
CLIMessage that is read.
Throws:
java.io.IOException - if error occurs while reading the data through the telnet connection.


Copyright (c)AdventNet Inc., 1996-2003