Class MailStoreMonitor
- All Implemented Interfaces:
Iterable<ComponentType>
,Channel
,ComponentType
,Eligible
,Manager
After establishing a connection to a store and selected
folders (see onOpenMailMonitor(OpenMailMonitor, Channel)
),
the existing and all subsequently arriving mails will be sent
downstream using FoldersUpdated
events.
This implementation uses the IdleManager
. The
IdleManager
works only if its IdleManager.watch(jakarta.mail.Folder)
method is invoked (for a folder) after any operation on that folder.
Note that operations such as e.g. setting the deleted flag of
a message is also an operation on a folder.
Folders are updated in response to an UpdateFolders
event
or when the store signals the arrival of new messages. Information
about the folders is delivered by a FoldersUpdated
event.
Folders may be freely used while handling the event, because the
folders will be re-registered with the IdleManager
when the FoldersUpdated
event completes.
Any usage of folders independent of handling the events mentioned
will result in a loss of the monitor function.
If required, the monitor function may be reestablished any time
by firing a UpdateFolders
event for the folders used.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.jgrapes.mail.MailConnectionManager
MailConnectionManager.AbstractMailChannel
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default
-
Field Summary
Fields inherited from class org.jgrapes.mail.MailConnectionManager
channels
Fields inherited from class org.jgrapes.mail.MailComponent
mailProps
-
Constructor Summary
ConstructorsConstructorDescriptionMailStoreMonitor
(Channel componentChannel) Creates a new server using the given channel. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureComponent
(Map<String, String> values) Configure the component.Returns the max idle time.void
Closes the channel.void
onOpenMailMonitor
(OpenMailMonitor event, Channel channel) Open a store as specified by the event and monitor the folders (also specified by the event).void
Stops the thread that is associated with this dispatcher.void
onUpdateFolders
(UpdateFolders event, MailChannel channel) Retrieves the folders specified in the event.setMaxIdleTime
(Duration maxIdleTime) Sets the maximum idle time.toString()
If a name has been set for this component (seeManager.setName(String)
), return the name, else return the object name provided byComponents.objectName(Object)
, usingComponentVertex.component()
as argument.Methods inherited from class org.jgrapes.mail.MailConnectionManager
executorService, setExecutorService
Methods inherited from class org.jgrapes.mail.MailComponent
onConfigUpdate, setMailProperties
Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setName
Methods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, unregisterAsGenerator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
MailStoreMonitor
Creates a new server using the given channel.- Parameters:
componentChannel
- the component’s channel
-
-
Method Details
-
setMaxIdleTime
Sets the maximum idle time.A running
IMAPFolder.idle()
is terminated and renewed after this time. Defaults to 25 minutes.- Parameters:
maxIdleTime
- the new max idle time
-
maxIdleTime
Returns the max idle time.- Returns:
- the duration
-
configureComponent
Configure the component.Currently, only max idle time is supported.
- Specified by:
configureComponent
in classMailComponent
- Parameters:
values
- the values
-
onOpenMailMonitor
Open a store as specified by the event and monitor the folders (also specified by the event).Information about all existing and all subsequently arriving mails will be signaled downstream using
FoldersUpdated
events.- Parameters:
event
- the eventchannel
- the channel
-
onClose
Closes the channel.- Parameters:
event
- the event
-
onUpdateFolders
Retrieves the folders specified in the event.- Parameters:
event
- the eventchannel
- the channel
-
onStop
Stops the thread that is associated with this dispatcher.- Parameters:
event
- the event- Throws:
InterruptedException
- if the execution is interrupted
-
toString
Description copied from class:ComponentVertex
If a name has been set for this component (seeManager.setName(String)
), return the name, else return the object name provided byComponents.objectName(Object)
, usingComponentVertex.component()
as argument.- Overrides:
toString
in classMailComponent
-