Class MailSenderConnection
java.lang.Object
org.springframework.ws.transport.AbstractWebServiceConnection
org.springframework.ws.transport.AbstractSenderConnection
org.springframework.ws.transport.mail.MailSenderConnection
- All Implemented Interfaces:
AutoCloseable
,HeadersAwareSenderWebServiceConnection
,WebServiceConnection
Implementation of
WebServiceConnection
that is used for client-side Mail access. Exposes a Message
request and response message.- Since:
- 1.5.0
- Author:
- Arjen Poutsma, Greg Turnquist
-
Constructor Summary
ModifierConstructorDescriptionprotected
MailSenderConnection
(jakarta.mail.Session session, jakarta.mail.URLName transportUri, jakarta.mail.URLName storeUri, jakarta.mail.internet.InternetAddress to, long receiveTimeout) Constructs a new Mail connection with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRequestHeader
(String name, String value) Adds a request header with the given name and value.Returns the error message.jakarta.mail.Message
Returns the request message for this connection.protected OutputStream
Returns the output stream to write the request to.Returns an iteration over all the header names this request contains.getResponseHeaders
(String name) Returns an iteration over all the string values of the specified header.protected InputStream
Returns the input stream to read the response from.jakarta.mail.Message
Returns the response message, if any, for this connection.getUri()
Returns the URI for this connection.boolean
hasError()
Indicates whether this connection has an error.protected boolean
Indicates whether this connection has a response.void
onClose()
Template method invoked fromAbstractWebServiceConnection.close()
.protected void
Called before a message has been read from theTransportInputStream
.protected void
onSendAfterWrite
(WebServiceMessage message) Called after the given message has been written to theTransportOutputStream
.protected void
onSendBeforeWrite
(WebServiceMessage message) Called before the given message has been written to theTransportOutputStream
.Methods inherited from class org.springframework.ws.transport.AbstractSenderConnection
createTransportInputStream, createTransportOutputStream
Methods inherited from class org.springframework.ws.transport.AbstractWebServiceConnection
close, onReceiveAfterRead, receive, send
-
Constructor Details
-
MailSenderConnection
protected MailSenderConnection(jakarta.mail.Session session, jakarta.mail.URLName transportUri, jakarta.mail.URLName storeUri, jakarta.mail.internet.InternetAddress to, long receiveTimeout) Constructs a new Mail connection with the given parameters.
-
-
Method Details
-
getRequestMessage
public jakarta.mail.Message getRequestMessage()Returns the request message for this connection. -
getResponseMessage
public jakarta.mail.Message getResponseMessage()Returns the response message, if any, for this connection. -
getUri
Description copied from interface:WebServiceConnection
Returns the URI for this connection.- Throws:
URISyntaxException
-
onSendBeforeWrite
Description copied from class:AbstractWebServiceConnection
Called before the given message has been written to theTransportOutputStream
. Called fromAbstractWebServiceConnection.send(WebServiceMessage)
.Default implementation does nothing.
- Overrides:
onSendBeforeWrite
in classAbstractWebServiceConnection
- Parameters:
message
- the message- Throws:
IOException
- when an I/O exception occurs
-
addRequestHeader
Description copied from interface:HeadersAwareSenderWebServiceConnection
Adds a request header with the given name and value. This method can be called multiple times, to allow for headers with multiple values.- Parameters:
name
- the name of the headervalue
- the value of the header- Throws:
IOException
-
getRequestOutputStream
Description copied from class:AbstractSenderConnection
Returns the output stream to write the request to.- Specified by:
getRequestOutputStream
in classAbstractSenderConnection
- Throws:
IOException
-
onSendAfterWrite
Description copied from class:AbstractWebServiceConnection
Called after the given message has been written to theTransportOutputStream
. Called fromAbstractWebServiceConnection.send(WebServiceMessage)
.Default implementation does nothing.
- Overrides:
onSendAfterWrite
in classAbstractWebServiceConnection
- Parameters:
message
- the message- Throws:
IOException
- when an I/O exception occurs
-
onReceiveBeforeRead
Description copied from class:AbstractWebServiceConnection
Called before a message has been read from theTransportInputStream
. Called fromAbstractWebServiceConnection.receive(WebServiceMessageFactory)
.Default implementation does nothing.
- Overrides:
onReceiveBeforeRead
in classAbstractWebServiceConnection
- Throws:
IOException
- when an I/O exception occurs
-
hasResponse
Description copied from class:AbstractSenderConnection
Indicates whether this connection has a response.- Specified by:
hasResponse
in classAbstractSenderConnection
- Throws:
IOException
-
getResponseHeaderNames
Description copied from interface:HeadersAwareSenderWebServiceConnection
Returns an iteration over all the header names this request contains. Returns an emptyIterator
if there are no headers.- Throws:
IOException
-
getResponseHeaders
Description copied from interface:HeadersAwareSenderWebServiceConnection
Returns an iteration over all the string values of the specified header. Returns an emptyIterator
if there are no headers of the specified name.- Throws:
IOException
-
getResponseInputStream
Description copied from class:AbstractSenderConnection
Returns the input stream to read the response from.- Specified by:
getResponseInputStream
in classAbstractSenderConnection
- Throws:
IOException
-
hasError
Description copied from interface:WebServiceConnection
Indicates whether this connection has an error. Typically, error detection is done by inspecting connection error codes, etc.- Returns:
true
if this connection has an error;false
otherwise.- Throws:
IOException
-
getErrorMessage
Description copied from interface:WebServiceConnection
Returns the error message.- Returns:
- the connection error message, if any; returns
null
when no error is present - Throws:
IOException
- See Also:
-
onClose
Description copied from class:AbstractSenderConnection
Template method invoked fromAbstractWebServiceConnection.close()
. Default implementation is empty.- Overrides:
onClose
in classAbstractSenderConnection
- Throws:
IOException
- if an I/O error occurs when closing this connection
-