public abstract class AbstractServer extends Thread implements Service
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
protected InetAddress |
bindTo |
protected static int |
CLIENT_SOCKET_SO_TIMEOUT |
protected org.slf4j.Logger |
log |
protected Managers |
managers |
protected ServerSocket |
serverSocket |
protected ServerSetup |
setup |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Modifier | Constructor and Description |
---|---|
protected |
AbstractServer(ServerSetup setup,
Managers managers) |
Modifier and Type | Method and Description |
---|---|
protected void |
closeServerSocket()
Closes the server socket.
|
protected abstract ProtocolHandler |
createProtocolHandler(Socket clientSocket)
Create a new, specific protocol handler such as for IMAP.
|
Session |
createSession()
Creates a session configured for given server (IMAP, SMTP, ...).
|
Session |
createSession(Properties properties)
Creates a session configured for given server (IMAP, SMTP, ...).
|
Session |
createSession(Properties properties,
boolean debug)
Creates a session configured for given server (IMAP, SMTP, ...).
|
Store |
createStore()
Creates a new JavaMail store.
|
String |
getBindTo() |
int |
getPort() |
String |
getProtocol() |
ServerSetup |
getServerSetup() |
protected void |
handleClientSocket(Socket clientSocket) |
protected void |
initServerSocket() |
boolean |
isRunning()
Checks if service is up and running.
|
protected boolean |
keepOn() |
protected ServerSocket |
openServerSocket() |
protected void |
quit()
Quits server by closing server socket and closing client socket handlers.
|
void |
run() |
void |
setClientSocketTimeout(int clientSocketTimeout) |
protected void |
setRunning(boolean r) |
void |
startService()
Starts the service in the background as a new thread.
|
void |
stopService()
Stops the service (without timeout).
|
void |
stopService(long millis)
Stops the service.
|
String |
toString() |
boolean |
waitTillRunning(long timeoutInMs)
Waits till service is up or timeout was reached.
|
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, yield
protected final org.slf4j.Logger log
protected final InetAddress bindTo
protected ServerSocket serverSocket
protected static final int CLIENT_SOCKET_SO_TIMEOUT
protected final Managers managers
protected ServerSetup setup
protected AbstractServer(ServerSetup setup, Managers managers)
protected abstract ProtocolHandler createProtocolHandler(Socket clientSocket)
clientSocket
- the client socket to use.protected ServerSocket openServerSocket() throws IOException
IOException
protected void initServerSocket()
protected void closeServerSocket()
public void setClientSocketTimeout(int clientSocketTimeout)
protected void handleClientSocket(Socket clientSocket) throws SocketException
SocketException
protected void quit()
public String getBindTo()
public int getPort()
public String getProtocol()
public ServerSetup getServerSetup()
public boolean waitTillRunning(long timeoutInMs) throws InterruptedException
Service
waitTillRunning
in interface Service
timeoutInMs
- the timeout in millisecondsInterruptedException
- if interrupted while waiting.public boolean isRunning()
Service
protected void setRunning(boolean r)
protected final boolean keepOn()
public void startService()
Service
Service.isRunning()
and Service.waitTillRunning(long)
to check if service is up.startService
in interface Service
public final void stopService(long millis)
stopService
in interface Service
millis
- value in mspublic final void stopService()
stopService
in interface Service
public Session createSession(Properties properties)
properties
- optional session properties, can be null.public Session createSession(Properties properties, boolean debug)
properties
- optional session properties, can be null.debug
- if true enables JavaMail debug settingspublic Session createSession()
public Store createStore() throws NoSuchProviderException
NoSuchProviderException
Copyright © 2006–2022 Icegreen Technologies. All rights reserved.