Package davmail
Class AbstractConnection
java.lang.Object
java.lang.Thread
davmail.AbstractConnection
- All Implemented Interfaces:
Closeable,AutoCloseable,Runnable
- Direct Known Subclasses:
CaldavConnection,ImapConnection,LdapConnection,PopConnection,SmtpConnection
Generic connection common to pop3 and smtp implementations
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static enumNested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Socketprotected AbstractConnection.LineReaderInputStreamprotected OutputStreamprotected Stringprotected ExchangeSessionprotected AbstractConnection.Stateprotected StringFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAbstractConnection(String name, Socket clientSocket) Only set the thread name and socketAbstractConnection(String name, Socket clientSocket, String encoding) Initialize the streams and set a thread name. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close client connection, streams, and Exchange session.voidlogConnection(String action, String userName) Read a line from the client connection.voidsendClient(byte[] messageBytes) Send all bytes to the client.voidsendClient(byte[] messageBytes, int offset, int length) Send only bytes to the client.voidsendClient(String message) Send the provided message to the client followed by CRLF.voidsendClient(String prefix, String message) Send prefix and message to the client followed by CRLF.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
client
-
in
-
os
-
userName
-
password
-
state
-
session
-
-
Constructor Details
-
AbstractConnection
Only set the thread name and socket- Parameters:
name- thread type nameclientSocket- client socket
-
AbstractConnection
Initialize the streams and set a thread name.- Parameters:
name- thread type nameclientSocket- client socketencoding- socket stream encoding
-
-
Method Details
-
logConnection
-
sendClient
Send the provided message to the client followed by CRLF.- Parameters:
message- message- Throws:
IOException- on error
-
sendClient
Send prefix and message to the client followed by CRLF.- Parameters:
prefix- prefixmessage- message- Throws:
IOException- on error
-
sendClient
Send all bytes to the client.- Parameters:
messageBytes- content- Throws:
IOException- on error
-
sendClient
Send only bytes to the client.- Parameters:
messageBytes- contentoffset- the start offset in the data.length- the number of bytes to write.- Throws:
IOException- on error
-
readClient
Read a line from the client connection. Log message to logger- Returns:
- command line or null
- Throws:
IOException- when unable to read the next line
-
close
public void close()Close client connection, streams, and Exchange session.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-