Package org.jgrapes.mail
Class SimpleMailMonitor
java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jgrapes.mail.MailComponent
org.jgrapes.mail.SimpleMailMonitor
- All Implemented Interfaces:
Iterable<ComponentType>
,Channel
,ComponentType
,Eligible
,Manager
A component that monitors the INBOX of a mail account.
The component uses Jakarta Mail to connect to a mail server.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default
-
Field Summary
Fields inherited from class org.jgrapes.mail.MailComponent
mailProps
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new component with its channel set to itself.SimpleMailMonitor
(Channel componentChannel) Creates a new component base with its channel set to the given channel.SimpleMailMonitor
(Channel componentChannel, HandlerDefinition.ChannelReplacements channelReplacements) Creates a new component base likeSimpleMailMonitor(Channel)
but with channel mappings forHandler
annotations. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureComponent
(Map<String, String> values) Configure the component specific values.Returns the max idle time.void
Run the monitor.void
Stop the monitor.Returns the poll interval.setMailProperties
(Map<String, String> props) Sets the mail properties.setMaxIdleTime
(Duration maxIdleTime) Sets the maximum idle time.setPassword
(String password) Sets the password.void
setPollInterval
(Duration pollInterval) Sets the poll interval.Methods inherited from class org.jgrapes.mail.MailComponent
onConfigUpdate
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, toString, 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
-
SimpleMailMonitor
public SimpleMailMonitor()Creates a new component with its channel set to itself. -
SimpleMailMonitor
Creates a new component base with its channel set to the given channel.As a special case
Channel.SELF
can be passed to the constructor to make the component use itself as channel. The special value is necessary as you obviously cannot pass an object to be constructed to its constructor.- Parameters:
componentChannel
- the channel that the component’s handlers listen on by default and thatManager.fire(Event, Channel...)
sends the event to
-
SimpleMailMonitor
public SimpleMailMonitor(Channel componentChannel, HandlerDefinition.ChannelReplacements channelReplacements) Creates a new component base likeSimpleMailMonitor(Channel)
but with channel mappings forHandler
annotations.- Parameters:
componentChannel
- the channel that the component’s handlers listen on by default and thatManager.fire(Event, Channel...)
sends the event tochannelReplacements
- the channel replacements to apply to thechannels
elements of theHandler
annotations
-
-
Method Details
-
setPassword
Sets the password.- Parameters:
password
- the new password
-
setMailProperties
Sets the mail properties.See the Jakarta Mail documentation for available settings.
- Overrides:
setMailProperties
in classMailComponent
- Parameters:
props
- the props- Returns:
- the mail monitor
-
setMaxIdleTime
Sets the maximum idle time.A running
IMAPFolder.idle()
is terminated and renewed after this time.- Parameters:
maxIdleTime
- the new max idle time
-
maxIdleTime
Returns the max idle time.- Returns:
- the duration
-
setPollInterval
Sets the poll interval.Polling is used when the idle command is not available.
- Parameters:
pollInterval
- the pollInterval to set
-
pollInterval
Returns the poll interval.- Returns:
- the pollInterval
-
configureComponent
Description copied from class:MailComponent
Configure the component specific values.- Specified by:
configureComponent
in classMailComponent
- Parameters:
values
- the values
-
onStart
Run the monitor.- Parameters:
event
- the event- Throws:
NoSuchProviderException
- the no such provider exception
-
onStop
Stop the monitor.- Parameters:
event
- the event
-