|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vhosting.netconf.transport.NetconfCatcher
public abstract class NetconfCatcher
This abstract class implements all the aspects that characterize a Netconf connection and through its protected methods you can create a subclass that implements directly a certain type of transport protocol.
Examples include: 1. Netconf over SSH2 (RFC 4742) 2. Netconf over SOAP (RFC 4743) 3. Netconf over BEEP (RFC 4744) ...
Nested Class Summary | |
---|---|
static class |
NetconfCatcher.LogLevel
This enumeration lists the possible levels of writing logs. |
Constructor Summary | |
---|---|
protected |
NetconfCatcher(java.lang.String labelConnection)
It enables a subclass to be instantiated. |
Method Summary | |
---|---|
void |
disconnect()
Invoke this method if you want to end the connection at any point in your application, such as when the user wants to do it manually. |
protected abstract boolean |
doDisconnect()
This method must necessarily be implemented with the code necessary to perform a disconnect with the server. |
protected abstract byte[] |
doReadDataFromServer()
This method must necessarily be implemented when required to read the next message from the server. |
protected abstract void |
doSendDataToServer(byte[] bytes)
This method must necessarily be implemented so that any type of message can be sent to the Netconf server. |
static void |
enableLog(NetconfCatcher.LogLevel level)
Enables the writing of the logs. |
protected void |
fireConnectionClosed()
This method must necessarily be invoked at the end of the process when the server connection is lost to natural causes. |
static NetconfCatcher.LogLevel |
getLogLevel()
Get the log level set. |
static java.io.PrintStream |
getLogStream()
Get the log stream. |
abstract boolean |
isConnected()
Check if the connection is alive or not. |
protected void |
sendHelloMsg()
Packages the message hello with the abilities of this implementation of netconf and send the message to the server. |
static void |
setLogStream(java.io.PrintStream stream)
Set the stream on which the log will be reversed. |
void |
setNetconfCatcherListener(NetconfCatcherListener ncl)
Set the NetconfCatcherListener in order to intercept transport events. |
void |
setSyncRequestsTimeout(int timeout)
Allows you to specify a request timeout for synchronous RPC calls. |
protected void |
throwTransportException(java.lang.Exception e,
NetconfTransportError.FailCause cause,
boolean withClosedConnection)
This method must be used into connection process when an exception occurs or a condition in which the connection can not be established. |
protected void |
whileRpcReplyCatching()
This method must be called immediately following methods: sendHelloMsg(); checkServerHelloMsg(); The invocation of the method will generate an infinite loop on reading a message from the server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected NetconfCatcher(java.lang.String labelConnection)
labelConnection
- A label used to identify the connection.Method Detail |
---|
public final void setNetconfCatcherListener(NetconfCatcherListener ncl)
ncl
- A NetconfCatcherListener instance.NetconfCatcherListener
protected final void sendHelloMsg() throws java.io.IOException
java.io.IOException
- throw if there are not a connection and
the message sent can not exercise.protected final void throwTransportException(java.lang.Exception e, NetconfTransportError.FailCause cause, boolean withClosedConnection)
e
- The exception that occurred during the connection
process or the exception is created when there is a
condition in which the connection can not be established.cause
- The fail cause.withClosedConnection
- true if the connection is closed
after it was opened in prior periods during the connection
process;
false if the connection was never opened before.public abstract boolean isConnected()
protected void fireConnectionClosed()
sendHelloMsg(); checkServerHelloMsg(); whileRpcReplyCatching();fails for an exception, which means that the connection has been terminated by the server.
protected abstract void doSendDataToServer(byte[] bytes) throws java.io.IOException
bytes
- The byte array containing the Netconf message.
java.io.IOException
- Throw this exception when the server connection was lost.protected abstract byte[] doReadDataFromServer() throws java.io.IOException
java.io.IOException
- Throw this exception when the server connection was lost.public final void disconnect()
protected abstract boolean doDisconnect()
protected final void whileRpcReplyCatching() throws java.io.IOException
sendHelloMsg(); checkServerHelloMsg();The invocation of the method will generate an infinite loop on reading a message from the server. This infinite loop will end only by throwing an exception that indicates the end of the connection to the server.
java.io.IOException
- Throw this exception if the connection is closed for any
reason.public final void setSyncRequestsTimeout(int timeout)
timeout
- The timeout.public static final void setLogStream(java.io.PrintStream stream)
stream
- The stream on which the log will be
reversed.public static final void enableLog(NetconfCatcher.LogLevel level)
level
- The log level flag.setLogStream(PrintStream stream)
,
getLogLevel()
,
NetconfCatcher.LogLevel
public static final java.io.PrintStream getLogStream()
public static final NetconfCatcher.LogLevel getLogLevel()
enableLog(LogLevel level)
,
NetconfCatcher.LogLevel
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |