public class MailSenderConnection extends AbstractSenderConnection
WebServiceConnection
that is used for client-side Mail access. Exposes a Message
request and response message.Modifier | Constructor and Description |
---|---|
protected |
MailSenderConnection(Session session,
URLName transportUri,
URLName storeUri,
InternetAddress to,
long receiveTimeout)
Constructs a new Mail connection with the given parameters.
|
Modifier and Type | Method and Description |
---|---|
void |
addRequestHeader(String name,
String value)
Adds a request header with the given name and value.
|
String |
getErrorMessage()
Returns the error message.
|
Message |
getRequestMessage()
Returns the request message for this connection.
|
protected OutputStream |
getRequestOutputStream()
Returns the output stream to write the request to.
|
Iterator<String> |
getResponseHeaderNames()
Returns an iteration over all the header names this request contains.
|
Iterator<String> |
getResponseHeaders(String name)
Returns an iteration over all the string values of the specified header.
|
protected InputStream |
getResponseInputStream()
Returns the input stream to read the response from.
|
Message |
getResponseMessage()
Returns the response message, if any, for this connection.
|
URI |
getUri()
Returns the URI for this connection.
|
boolean |
hasError()
Indicates whether this connection has an error.
|
protected boolean |
hasResponse()
Indicates whether this connection has a response.
|
void |
onClose()
Template method invoked from
AbstractWebServiceConnection.close() . |
protected void |
onReceiveBeforeRead()
Called before a message has been read from the
TransportInputStream . |
protected void |
onSendAfterWrite(WebServiceMessage message)
Called after the given message has been written to the
TransportOutputStream . |
protected void |
onSendBeforeWrite(WebServiceMessage message)
Called before the given message has been written to the
TransportOutputStream . |
createTransportInputStream, createTransportOutputStream
close, onReceiveAfterRead, receive, send
protected MailSenderConnection(Session session, URLName transportUri, URLName storeUri, InternetAddress to, long receiveTimeout)
public Message getRequestMessage()
public Message getResponseMessage()
public URI getUri() throws URISyntaxException
WebServiceConnection
URISyntaxException
protected void onSendBeforeWrite(WebServiceMessage message) throws IOException
AbstractWebServiceConnection
TransportOutputStream
. Called from AbstractWebServiceConnection.send(WebServiceMessage)
.
Default implementation does nothing.
onSendBeforeWrite
in class AbstractWebServiceConnection
message
- the messageIOException
- when an I/O exception occurspublic void addRequestHeader(String name, String value) throws IOException
HeadersAwareSenderWebServiceConnection
name
- the name of the headervalue
- the value of the headerIOException
protected OutputStream getRequestOutputStream() throws IOException
AbstractSenderConnection
getRequestOutputStream
in class AbstractSenderConnection
IOException
protected void onSendAfterWrite(WebServiceMessage message) throws IOException
AbstractWebServiceConnection
TransportOutputStream
. Called from AbstractWebServiceConnection.send(WebServiceMessage)
.
Default implementation does nothing.
onSendAfterWrite
in class AbstractWebServiceConnection
message
- the messageIOException
- when an I/O exception occursprotected void onReceiveBeforeRead() throws IOException
AbstractWebServiceConnection
TransportInputStream
. Called from AbstractWebServiceConnection.receive(WebServiceMessageFactory)
.
Default implementation does nothing.
onReceiveBeforeRead
in class AbstractWebServiceConnection
IOException
- when an I/O exception occursprotected boolean hasResponse() throws IOException
AbstractSenderConnection
hasResponse
in class AbstractSenderConnection
IOException
public Iterator<String> getResponseHeaderNames() throws IOException
HeadersAwareSenderWebServiceConnection
Iterator
if
there are no headers.IOException
public Iterator<String> getResponseHeaders(String name) throws IOException
HeadersAwareSenderWebServiceConnection
Iterator
if there are no headers of the specified name.IOException
protected InputStream getResponseInputStream() throws IOException
AbstractSenderConnection
getResponseInputStream
in class AbstractSenderConnection
IOException
public boolean hasError() throws IOException
WebServiceConnection
true
if this connection has an error; false
otherwise.IOException
public String getErrorMessage() throws IOException
WebServiceConnection
null
when no error is presentIOException
WebServiceConnection.hasError()
public void onClose() throws IOException
AbstractSenderConnection
AbstractWebServiceConnection.close()
. Default implementation is empty.onClose
in class AbstractSenderConnection
IOException
- if an I/O error occurs when closing this connection