Class SimpleServer
- java.lang.Object
-
- org.opennms.netmgt.provision.server.exchange.SimpleConversationEndPoint
-
- org.opennms.netmgt.provision.server.SimpleServer
-
- Direct Known Subclasses:
Pop3Server
,SSLServer
public class SimpleServer extends SimpleConversationEndPoint
SimpleServer class.
- Version:
- $Id: $
- Author:
- ranger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SimpleServer.ServerErrorExchange
-
Nested classes/interfaces inherited from class org.opennms.netmgt.provision.server.exchange.SimpleConversationEndPoint
SimpleConversationEndPoint.SimpleExchange
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_stopped
-
Fields inherited from class org.opennms.netmgt.provision.server.exchange.SimpleConversationEndPoint
m_conversation
-
-
Constructor Summary
Constructors Constructor Description SimpleServer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addErrorHandler(RequestHandler requestHandler)
addErrorHandlerprotected boolean
attemptConversation(java.io.BufferedReader in, java.io.OutputStream out)
attemptConversationvoid
dispose()
disposeprotected RequestHandler
errorString(java.lang.String error)
errorStringjava.lang.String
getBanner()
getBannerjava.net.InetAddress
getInetAddress()
getInetAddressint
getLocalPort()
getLocalPortprotected SimpleServerRunnable
getRunnable()
getRunnablejava.net.ServerSocket
getServerSocket()
getServerSocketprotected java.lang.Thread
getServerThread()
getServerThreadjava.net.Socket
getSocket()
getSocketint
getThreadSleepLength()
getThreadSleepLengthvoid
init()
initprotected void
onInit()
onInitprotected void
sendBanner(java.io.OutputStream out)
sendBannervoid
setBanner(java.lang.String banner)
setBannervoid
setBannerDelay(int delay)
Slow down transmission of the banner by a specified number of milliseconds.void
setServerSocket(java.net.ServerSocket serverSocket)
setServerSocketprotected void
setServerThread(java.lang.Thread serverThread)
setServerThreadvoid
setSocket(java.net.Socket socket)
setSocketvoid
setThreadSleepLength(int timeout)
setThreadSleepLengthprotected RequestHandler
shutdownServer(java.lang.String response)
shutdownServervoid
startServer()
startServervoid
stopServer()
stopServer-
Methods inherited from class org.opennms.netmgt.provision.server.exchange.SimpleConversationEndPoint
addResponseHandler, contains, getTimeout, matches, multilineLineRequest, setTimeout, singleLineRequest, startsWith
-
-
-
-
Method Detail
-
setBanner
public void setBanner(java.lang.String banner)
setBanner
- Parameters:
banner
- aString
object.
-
getBanner
public java.lang.String getBanner()
getBanner
- Returns:
- a
String
object.
-
setBannerDelay
public void setBannerDelay(int delay)
Slow down transmission of the banner by a specified number of milliseconds.
-
getInetAddress
public java.net.InetAddress getInetAddress()
getInetAddress
- Returns:
- InetAddress returns the inetaddress from the serversocket.
-
getLocalPort
public int getLocalPort()
getLocalPort
- Returns:
- a int.
-
setThreadSleepLength
public void setThreadSleepLength(int timeout)
setThreadSleepLength
- Parameters:
timeout
- a int.
-
getThreadSleepLength
public int getThreadSleepLength()
getThreadSleepLength
- Returns:
- a int.
-
init
public void init() throws java.lang.Exception
init
- Overrides:
init
in classSimpleConversationEndPoint
- Throws:
java.lang.Exception
- if any.
-
onInit
protected void onInit()
onInit
-
startServer
public void startServer() throws java.io.IOException
startServer
- Throws:
java.lang.Exception
- if any.java.io.IOException
-
stopServer
public void stopServer() throws java.io.IOException
stopServer
- Throws:
java.io.IOException
- if any.
-
dispose
public void dispose()
dispose
-
getRunnable
protected SimpleServerRunnable getRunnable() throws java.io.IOException
getRunnable
- Returns:
- a
Runnable
object. - Throws:
java.lang.Exception
- if any.java.io.IOException
-
sendBanner
protected void sendBanner(java.io.OutputStream out) throws java.io.IOException
sendBanner
- Parameters:
out
- aOutputStream
object.- Throws:
java.io.IOException
- if any.
-
attemptConversation
protected boolean attemptConversation(java.io.BufferedReader in, java.io.OutputStream out) throws java.lang.Exception
attemptConversation
- Parameters:
in
- aBufferedReader
object.out
- aOutputStream
object.- Returns:
- a boolean.
- Throws:
java.lang.Exception
- if any.
-
addErrorHandler
protected void addErrorHandler(RequestHandler requestHandler)
addErrorHandler
- Parameters:
requestHandler
- aRequestHandler
object.
-
errorString
protected RequestHandler errorString(java.lang.String error)
errorString
- Parameters:
error
- aString
object.- Returns:
- a
RequestHandler
object.
-
shutdownServer
protected RequestHandler shutdownServer(java.lang.String response)
shutdownServer
- Parameters:
response
- aString
object.- Returns:
- a
RequestHandler
object.
-
setServerSocket
public void setServerSocket(java.net.ServerSocket serverSocket)
setServerSocket
- Parameters:
serverSocket
- aServerSocket
object.
-
getServerSocket
public java.net.ServerSocket getServerSocket()
getServerSocket
- Returns:
- a
ServerSocket
object.
-
setSocket
public void setSocket(java.net.Socket socket)
setSocket
- Parameters:
socket
- aSocket
object.
-
getSocket
public java.net.Socket getSocket()
getSocket
- Returns:
- a
Socket
object.
-
setServerThread
protected void setServerThread(java.lang.Thread serverThread)
setServerThread
- Parameters:
serverThread
- aThread
object.
-
getServerThread
protected java.lang.Thread getServerThread()
getServerThread
- Returns:
- a
Thread
object.
-
-