Package ch.astorm.smtp4j.core
Class SmtpMessageStorage
java.lang.Object
ch.astorm.smtp4j.core.SmtpMessageStorage
- All Implemented Interfaces:
SmtpMessageHandler,SmtpServerListener
Simple
SmtpMessageHandler that stores the received messages in a list.
This class is Thread-safe.-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.astorm.smtp4j.core.SmtpMessageHandler
SmtpMessageHandler.SmtpMessageIterator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Deprecated.Deprecated.UsereadMessages()instead.iterator()Returns a newSmtpMessageIteratorthat loops over the received messages.voidnotifyClose(SmtpServer server) Invoked when theserverhas been closed.voidnotifyStart(SmtpServer server) Invoked when theserverhas been started and is ready to receive messages.Retrieves the received messages and clears the list.voidreceive(SmtpMessage smtpMessage) Receives the givensmtpMessage.
-
Constructor Details
-
SmtpMessageStorage
public SmtpMessageStorage()
-
-
Method Details
-
notifyStart
Description copied from interface:SmtpServerListenerInvoked when theserverhas been started and is ready to receive messages.- Specified by:
notifyStartin interfaceSmtpServerListener- Parameters:
server- The startedSmtpServer.
-
notifyClose
Description copied from interface:SmtpServerListenerInvoked when theserverhas been closed.- Specified by:
notifyClosein interfaceSmtpServerListener- Parameters:
server- The stoppedSmtpServer.
-
receive
Description copied from interface:SmtpMessageHandlerReceives the givensmtpMessage.- Specified by:
receivein interfaceSmtpMessageHandler- Parameters:
smtpMessage- The message received within the transaction.
-
iterator
Description copied from interface:SmtpMessageHandlerReturns a newSmtpMessageIteratorthat loops over the received messages.- Specified by:
iteratorin interfaceSmtpMessageHandler- Returns:
- A new
SmtpMessageIteratorinstance.
-
readMessages
Description copied from interface:SmtpMessageHandlerRetrieves the received messages and clears the list. If no new message has been received since the last notification, an empty list will be returned.- Specified by:
readMessagesin interfaceSmtpMessageHandler- Returns:
- All the (newly) received messages or an empty list if none.
-
getMessages
Deprecated.UsereadMessages()instead.Returns aListwith all the received messages.- Returns:
- All the received messages.
-
clear
Deprecated.UsereadMessages()instead.Clears all the messages.
-
readMessages()instead.