Nitido Inc.

com.nitido.nimx.services.notification.channels
Class EmailDeliveryChannel

java.lang.Object
  extended by com.nitido.nimx.services.notification.channels.DeliveryChannel
      extended by com.nitido.nimx.services.notification.channels.EmailDeliveryChannel
All Implemented Interfaces:
NotificationConstants
Direct Known Subclasses:
StubEmailDeliveryChannel

public class EmailDeliveryChannel
extends DeliveryChannel

An implementation of the delivery channel that handles the sending of email messages.


Field Summary
protected  int _maxSMTPconnections
          Property which determines the number of simultaneous SMTP connections to allow for the email delivery channel.
protected  java.util.Properties _smtpProperties
           
 
Fields inherited from class com.nitido.nimx.services.notification.channels.DeliveryChannel
_confService, _ticketCache
 
Fields inherited from interface com.nitido.nimx.services.notification.NotificationConstants
CONF_KEY_CACHE_EXPIRE_TIME, CONF_KEY_CACHE_MAX_TIME, CONF_KEY_CACHE_PREFIX, CONF_KEY_CACHE_REMOVE_FINAL, CONF_KEY_CACHE_SLEEP_TIME, CONF_KEY_DELIVERY_CHANNEL_LIST_PREFIX, CONF_KEY_DELIVERY_CHANNELS_PREFIX, KEY_TRANSACTION_PREFIX, LEN_PREFIX_TOKEN, LEN_PREFIX_USER_SPACE, PREFIX_TOKEN, PREFIX_USER_SPACE, PROTOCOL_ADDRESS_SEPARATOR, TICKET_SEPARATOR
 
Constructor Summary
EmailDeliveryChannel(NiMKernelServiceVisa visa)
           
 
Method Summary
 boolean canDeliverTo(Member target)
          Determines whether the member has the requied information for this delivery channel to be able to send a message to the user.
protected  javax.mail.Transport connectSMTP(Entity entity)
          Connect to to the SMTP server with the specified settings.
 javax.mail.internet.MimeMessage createMessage()
          Returns a new MimeMessage object from the current mail session.
 java.lang.String deliver(NotificationMessage msg)
          Starts the delivery process for this message (or places it into some sort of internal queue).
protected  void disconnectSMTP(javax.mail.Transport smtp)
           
protected  java.lang.String getActualConfigProperty(Entity entity, java.lang.String configKey)
          This method return the actual value of a setting.
 java.lang.String getKey()
          Returns the key to use when referring to this delivery method.
 java.lang.String getProtocolPrefix()
          "mailto://" -> EmailDeliveryChannel "mobile://" -> SMSDeliveryChannel etc.
 IndividualStatus getStatus(java.lang.String ticket)
          Notification service uses this method to get an updated status object before returning to the client.
 void init(StatusTicketCache cache, ConfigurationService conf)
          Initializes the delivery channel by providing access to the status ticket cache and the configuration service.
 boolean isStandardTicket(java.lang.String ticket)
          The implementation of the delivery channel determines whether the given status ticket belongs to its set of standard tickets that do not require storage in the status cache.
protected  void loadProperties()
          Loads configuratioin properties.
protected  void sendMessage(Entity entity, javax.mail.Message msg, javax.mail.Address[] addr)
          Sends the message by opening a new new SMTP connection and using its sendMessage() method.
 boolean validateRecipient(java.lang.String recipient)
          Determines whether the recipient string is a valid address/phone etc that this delivery channel can use.
 
Methods inherited from class com.nitido.nimx.services.notification.channels.DeliveryChannel
getConfigPropertiesByPrefix, getConfigProperty, getTicketCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_maxSMTPconnections

protected int _maxSMTPconnections
Property which determines the number of simultaneous SMTP connections to allow for the email delivery channel. -1 for no limit.


_smtpProperties

protected transient java.util.Properties _smtpProperties
Constructor Detail

EmailDeliveryChannel

public EmailDeliveryChannel(NiMKernelServiceVisa visa)
Method Detail

init

public void init(StatusTicketCache cache,
                 ConfigurationService conf)
          throws InitializationFailedException
Description copied from class: DeliveryChannel
Initializes the delivery channel by providing access to the status ticket cache and the configuration service.

Overrides:
init in class DeliveryChannel
Parameters:
cache - status ticket cache
conf - configuration service
Throws:
InitializationFailedException

loadProperties

protected void loadProperties()
                       throws InitializationFailedException
Loads configuratioin properties.

Throws:
InitializationFailedException

canDeliverTo

public boolean canDeliverTo(Member target)
Description copied from class: DeliveryChannel
Determines whether the member has the requied information for this delivery channel to be able to send a message to the user.

Specified by:
canDeliverTo in class DeliveryChannel
Parameters:
target - the Member object to which the message will be delivered
Returns:
true if the Member object contains the information this delivery channel requires to attempt a message delivery, false otherwise

deliver

public java.lang.String deliver(NotificationMessage msg)
                         throws NotificationServiceException
Description copied from class: DeliveryChannel
Starts the delivery process for this message (or places it into some sort of internal queue).

Specified by:
deliver in class DeliveryChannel
Parameters:
msg - the message to be sent out
Returns:
the status ticket for this message
Throws:
NotificationServiceException - if the delivery channel is unable to initiate the delivery of the message

getKey

public java.lang.String getKey()
Description copied from class: DeliveryChannel
Returns the key to use when referring to this delivery method.

Specified by:
getKey in class DeliveryChannel
Returns:
key for this delivery channel

getProtocolPrefix

public java.lang.String getProtocolPrefix()
Description copied from class: DeliveryChannel
"mailto://" -> EmailDeliveryChannel "mobile://" -> SMSDeliveryChannel etc. an address with a prefix that is not listed will generate an error,

Specified by:
getProtocolPrefix in class DeliveryChannel

isStandardTicket

public boolean isStandardTicket(java.lang.String ticket)
Description copied from class: DeliveryChannel
The implementation of the delivery channel determines whether the given status ticket belongs to its set of standard tickets that do not require storage in the status cache.

Specified by:
isStandardTicket in class DeliveryChannel
Parameters:
ticket - status ticket
Returns:
true if the ticket is this delivery's channel standard ticket, false otherwise

getStatus

public IndividualStatus getStatus(java.lang.String ticket)
                           throws StatusNotFoundException
Description copied from class: DeliveryChannel
Notification service uses this method to get an updated status object before returning to the client. The delivery channel implementations will individually determine whether the ticket represents a standard status, in which case the status object is constructed right there, or the delivery channel retrieves the status object from the status cache.

Specified by:
getStatus in class DeliveryChannel
Parameters:
ticket - the status ticket that is being requested from the channel
Returns:
the individual status which corresponds to the ticket provided as an argument
Throws:
StatusNotFoundException - thrown if the delivery channel could not find a status object for the given ticket

createMessage

public javax.mail.internet.MimeMessage createMessage()
Returns a new MimeMessage object from the current mail session.

Returns:
new mimemessage object

sendMessage

protected void sendMessage(Entity entity,
                           javax.mail.Message msg,
                           javax.mail.Address[] addr)
                    throws javax.mail.MessagingException,
                           NotificationServiceException,
                           javax.mail.SendFailedException
Sends the message by opening a new new SMTP connection and using its sendMessage() method.

Parameters:
entity - the entity on whose behalf the message is being sent out
msg - the message to send
addr - the array of emails that this message is being sent to
Throws:
javax.mail.MessagingException - if there is an exception in sending out the message
javax.mail.SendFailedException - if there is an exception in sending out the message
NotificationServiceException - if there is an exception in obtaining an SMTP connection (either the max number of allowed connections has been reached or there is an error connecting to the server)

connectSMTP

protected javax.mail.Transport connectSMTP(Entity entity)
                                    throws NotificationServiceException
Connect to to the SMTP server with the specified settings. This method will open one connection to the SMTP. The connection will remain open until disconnectSMTP() is invoked.

Throws:
NotificationServiceException

disconnectSMTP

protected void disconnectSMTP(javax.mail.Transport smtp)

validateRecipient

public boolean validateRecipient(java.lang.String recipient)
Description copied from class: DeliveryChannel
Determines whether the recipient string is a valid address/phone etc that this delivery channel can use.

Specified by:
validateRecipient in class DeliveryChannel

getActualConfigProperty

protected java.lang.String getActualConfigProperty(Entity entity,
                                                   java.lang.String configKey)
                                            throws NotificationServiceException
This method return the actual value of a setting. A setting value can be the literal string or referencing another value in the Entity's user space. This method will interpret the initial value of the setting and fetch the actual value from the user space if necessary.

Returns:
The actual value, which can be literal string or the dereferenced value from the user space. It will return null if the specified setting does not exists or the dereferenced value is null.
Throws:
NotificationServiceException

Nitido NiM 2.5 Java API

These JavaDoc pages are generated for release/nim_2_5-2.5.44

Copyright © 1999-2009 Nitido Inc.    Proprietary and Confidential.    All Rights Reserved.