C
- Your connection typepublic abstract class WebServer<C extends WebConnection> extends Thread implements Runnable
WebRequestListener
and
registerListener(Class,
WebRequestListener)
for further information.)
This does take a generic for your web connection extender (if you are using one) however the generic is not used in some returns. This is to avoid a nasty bit of casting in some of the creator classes in the backend. As you're likely to be the only one creating connections, it is perfectly safe to assume that all WebConnections present in this class or returned by it are of your generic type "C" and castable.
Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
WebServer(int port,
String webContentRoot)
This creates a simple webserver capable of serving static
pages.
|
WebServer(int port,
String webContentRoot,
boolean sendDebugMessages)
See above - with the option to send debug messages to console
during errors.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addConnection(WebConnection connection)
|
protected <X extends WebActionEvent>
|
callEvent(X event)
|
abstract C |
createConnection(Socket socket)
|
@NotNull String |
get404()
|
@NotNull List<WebConnection> |
getConnectionPool()
|
@NotNull String |
getDefaultFileName()
|
@NotNull String |
getMethodNotSupportedFileName()
|
int |
getPort()
|
File |
getWebRootFolder()
|
boolean |
hasConnections()
|
boolean |
isDebug()
|
void |
registerListener(Class<? extends WebActionEvent> event,
WebRequestListener<?> listener)
|
protected void |
removeConnection(WebConnection connection)
|
void |
run()
|
void |
shutDown()
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler,
getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler,
setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public WebServer(int port, String webContentRoot)
WebConnection
abstract class.
port
- The web port; 80 is the default onewebContentRoot
- The folder path where your website files will be
public WebServer(int port, String webContentRoot, boolean sendDebugMessages)
port
- The web port; 80 is the default onewebContentRoot
- The folder path where your website files will be
sendDebugMessages
- Whether to send debug messagesprotected <X extends WebActionEvent> X callEvent(X event)
public void registerListener(Class<? extends WebActionEvent> event, WebRequestListener<?> listener)
public boolean isDebug()
public File getWebRootFolder()
@NotNull public @NotNull String getDefaultFileName()
@NotNull public @NotNull String get404()
@NotNull public @NotNull String getMethodNotSupportedFileName()
public abstract C createConnection(Socket socket)
socket
- The socketpublic int getPort()
public boolean hasConnections()
protected void addConnection(WebConnection connection)
protected void removeConnection(WebConnection connection)
@NotNull public @NotNull List<WebConnection> getConnectionPool()
public void shutDown()
Copyright © 2020. All rights reserved.