public abstract class AbstractServer extends Thread implements Service
Thread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
protected InetAddress |
bindTo |
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.
|
javax.mail.Session |
createSession()
Creates a session configured for given server (IMAP, SMTP, ...).
|
javax.mail.Session |
createSession(Properties properties)
Creates a session configured for given server (IMAP, SMTP, ...).
|
javax.mail.Session |
createSession(Properties properties,
boolean debug)
Creates a session configured for given server (IMAP, SMTP, ...).
|
javax.mail.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() |
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, yieldprotected final org.slf4j.Logger log
protected final InetAddress bindTo
protected ServerSocket serverSocket
protected 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
IOExceptionprotected void initServerSocket()
protected void closeServerSocket()
protected void handleClientSocket(Socket clientSocket)
protected void quit()
public String getBindTo()
public int getPort()
public String getProtocol()
public ServerSetup getServerSetup()
public boolean waitTillRunning(long timeoutInMs)
throws InterruptedException
ServicewaitTillRunning in interface ServicetimeoutInMs - the timeout in millisecondsInterruptedException - if interrupted while waiting.public boolean isRunning()
Serviceprotected void setRunning(boolean r)
protected final boolean keepOn()
public void startService()
ServiceService.isRunning() and Service.waitTillRunning(long) to check if service is up.startService in interface Servicepublic final void stopService(long millis)
stopService in interface Servicemillis - value in mspublic final void stopService()
stopService in interface Servicepublic javax.mail.Session createSession(Properties properties)
properties - optional session properties, can be null.public javax.mail.Session createSession(Properties properties, boolean debug)
properties - optional session properties, can be null.debug - if true enables JavaMail debug settingspublic javax.mail.Session createSession()
public javax.mail.Store createStore()
throws javax.mail.NoSuchProviderException
javax.mail.NoSuchProviderExceptionCopyright © 2006–2017 Icegreen Technologies. All rights reserved.