Package cloud.piranha.http.singlethread
Class SingleThreadHttpServer
- java.lang.Object
-
- cloud.piranha.http.singlethread.SingleThreadHttpServer
-
- All Implemented Interfaces:
HttpServer
,Runnable
public class SingleThreadHttpServer extends Object implements HttpServer, Runnable
The single threaded implementation of HTTP Server.- Author:
- Manfred Riem ([email protected])
- See Also:
HttpServer
-
-
Field Summary
Fields Modifier and Type Field Description protected HttpServerProcessor
processor
Stores the processor.protected boolean
running
Stores the running flag.protected int
serverPort
Stores the port we are listening on.protected Thread
serverProcessingThread
Stores the server acceptor thread.protected ServerSocket
serverSocket
Stores the server socket.protected boolean
serverStopRequest
Stores the server stop request.protected int
soTimeout
Stores the SO_TIMEOUT.
-
Constructor Summary
Constructors Constructor Description SingleThreadHttpServer()
Constructor.SingleThreadHttpServer(int serverPort)
Constructor.SingleThreadHttpServer(int serverPort, HttpServerProcessor processor)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpServerProcessor
getHttpServerProcessor()
Get the http server processorint
getServerPort()
Get the server portboolean
getSSL()
Get the SSL flagboolean
isRunning()
Check if the server is running.void
run()
void
setHttpServerProcessor(HttpServerProcessor httpServerProcessor)
Set the http server processorvoid
setServerPort(int serverPort)
Set the server portvoid
setSSL(boolean ssl)
Set the SSL flagvoid
start()
Start the server.void
stop()
Stop the server.
-
-
-
Field Detail
-
processor
protected HttpServerProcessor processor
Stores the processor.
-
running
protected boolean running
Stores the running flag.
-
serverProcessingThread
protected Thread serverProcessingThread
Stores the server acceptor thread.
-
serverPort
protected int serverPort
Stores the port we are listening on.
-
serverSocket
protected ServerSocket serverSocket
Stores the server socket.
-
serverStopRequest
protected boolean serverStopRequest
Stores the server stop request.
-
soTimeout
protected int soTimeout
Stores the SO_TIMEOUT.
-
-
Constructor Detail
-
SingleThreadHttpServer
public SingleThreadHttpServer()
Constructor.
-
SingleThreadHttpServer
public SingleThreadHttpServer(int serverPort)
Constructor.- Parameters:
serverPort
- the server port.
-
SingleThreadHttpServer
public SingleThreadHttpServer(int serverPort, HttpServerProcessor processor)
Constructor- Parameters:
serverPort
- the server port.processor
- the HTTP server processor.
-
-
Method Detail
-
isRunning
public boolean isRunning()
Description copied from interface:HttpServer
Check if the server is running.- Specified by:
isRunning
in interfaceHttpServer
- Returns:
- true if it is, false otherwise.
- See Also:
HttpServer.isRunning()
-
run
public void run()
- Specified by:
run
in interfaceRunnable
- See Also:
Runnable.run()
-
start
public void start()
Description copied from interface:HttpServer
Start the server.- Specified by:
start
in interfaceHttpServer
- See Also:
HttpServer.start()
-
stop
public void stop()
Description copied from interface:HttpServer
Stop the server.- Specified by:
stop
in interfaceHttpServer
- See Also:
HttpServer.stop()
-
getServerPort
public int getServerPort()
Description copied from interface:HttpServer
Get the server port- Specified by:
getServerPort
in interfaceHttpServer
- Returns:
- the server port
-
setServerPort
public void setServerPort(int serverPort)
Description copied from interface:HttpServer
Set the server port- Specified by:
setServerPort
in interfaceHttpServer
- Parameters:
serverPort
- the port
-
setSSL
public void setSSL(boolean ssl)
Description copied from interface:HttpServer
Set the SSL flag- Specified by:
setSSL
in interfaceHttpServer
- Parameters:
ssl
- the SSL flag
-
getSSL
public boolean getSSL()
Description copied from interface:HttpServer
Get the SSL flag- Specified by:
getSSL
in interfaceHttpServer
- Returns:
- the server port
-
setHttpServerProcessor
public void setHttpServerProcessor(HttpServerProcessor httpServerProcessor)
Description copied from interface:HttpServer
Set the http server processor- Specified by:
setHttpServerProcessor
in interfaceHttpServer
- Parameters:
httpServerProcessor
- the http server processor
-
getHttpServerProcessor
public HttpServerProcessor getHttpServerProcessor()
Description copied from interface:HttpServer
Get the http server processor- Specified by:
getHttpServerProcessor
in interfaceHttpServer
- Returns:
- the http server processor
-
-