public class EmailDispatcher extends Object implements NotificationDispatcher
EmailDispatcher
class is used to dispatch Notification
via JavaMail. This class currently does not attempt to reuse an existing
Session
or Transport
since each Notification
could
have a different target server with different properties.
In the future, this class could keep various Transport
instances open
on a Timer
, but those instances would need to be hashed so that the
proper instance is retrieved from the properties of the incoming
Notification
.Modifier and Type | Field and Description |
---|---|
static String |
JAVAMAIL_FROM_PROPERTY
The JavaMail property for the
From: header. |
Constructor and Description |
---|
EmailDispatcher() |
Modifier and Type | Method and Description |
---|---|
void |
dispatch(Notification notification)
Dispatches the specified notification.
|
protected javax.mail.Transport |
getMailTransport(Map<String,Object> properties) |
String |
getType()
Gets the type of dispatcher.
|
boolean |
isDigestSupported()
Gets whether the dispatcher supports sending a digest or summary in a
single
Notification . |
boolean |
isNotificationContentGenerationRequired()
Gets whether Ambari should attempt to generate the content of the
Notification before giving it to the dispatcher. |
TargetConfigurationResult |
validateTargetConfig(Map<String,Object> properties)
Validates alert target configuration.
|
public static final String JAVAMAIL_FROM_PROPERTY
From:
header.public String getType()
getType
in interface NotificationDispatcher
null
).public boolean isNotificationContentGenerationRequired()
Notification
before giving it to the dispatcher. Some dispatchers
may choose to format data in a way which is not easily represented in the
{alert-templates.xml}.
If false
then the Notification
will only contain the
recipients and a map of properties for the dispatcher to use.isNotificationContentGenerationRequired
in interface NotificationDispatcher
true
if Ambari should generate the Notification
content, false
otherwise.public void dispatch(Notification notification)
dispatch
in interface NotificationDispatcher
notification
- the notificationt to dispatch (not null
).public boolean isDigestSupported()
Notification
. Some providers may not allow the
Notification
to contain information on more than a single event.isDigestSupported
in interface NotificationDispatcher
true
if digest is supported, false
otherwise.public TargetConfigurationResult validateTargetConfig(Map<String,Object> properties)
validateTargetConfig
in interface NotificationDispatcher
properties
- alert target propertiesCopyright © 2022 Apache Software Foundation. All rights reserved.