xmlBlaster 2.2.0 API

org.xmlBlaster.util.protocol.email
Class EmailExecutor

java.lang.Object
  extended by org.xmlBlaster.util.protocol.RequestReplyExecutor
      extended by org.xmlBlaster.util.protocol.email.EmailExecutor
All Implemented Interfaces:
I_AdminPlugin, I_AdminUsage, I_ResponseListener, EmailExecutorMBean, RequestReplyExecutorMBean
Direct Known Subclasses:
CallbackEmailDriver, EmailCallbackImpl, EmailConnection, EmailDriver

public abstract class EmailExecutor
extends RequestReplyExecutor
implements I_ResponseListener, EmailExecutorMBean

Base class to handle request/reply for emails.

Author:
Marcel Ruff

Nested Class Summary
protected  class EmailExecutor.LoopProtection
          Use to protect against looping messages
 
Field Summary
private  AddressBase addressBase
           
protected  java.lang.String bcc
           
static java.lang.String BOUNCE_MAILFROM_KEY
           
static java.lang.String BOUNCE_MAILTO_KEY
           
protected  java.lang.String BOUNCE_MESSAGEID_KEY
           
protected  java.lang.String cc
           
private  java.util.zip.Deflater compressor
           
private  java.util.zip.Inflater decompressor
           
private  java.lang.String emailSessionId
           
protected  javax.mail.internet.InternetAddress fromAddress
           
private  boolean isShutdown
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
protected  java.lang.String messageIdFileName
          'messageId.mid'
protected  java.lang.String msgInfoParserClassName
          Which message format parser to use
protected  java.lang.String payloadFileNamePrefix
          The extension is added later to for example "xmlBlasterMessage.xfb"
private  I_PluginConfig pluginConfig
           
protected  Pop3Driver pop3Driver
           
private  java.lang.String secretSessionId
           
protected  java.util.Map senderLoopProtectionMap
           
protected  SmtpClient smtpClient
           
protected  java.lang.String SUBJECT_MESSAGEID_TOKEN
           
protected  java.lang.String subjectTemplate
           
protected  javax.mail.internet.InternetAddress toAddress
           
 
Fields inherited from class org.xmlBlaster.util.protocol.RequestReplyExecutor
addressConfig, addressServer, cbClient, compressZlib, compressZlibStream, contextNode, glob, mbeanHandle, minSizeForCompression, ONEWAY, pingResponseTimeout, prefix, progressListener, responseListenerMap, responseTimeout, updateResponseTimeout, useEmailExpiryTimestamp, WAIT_ON_RESPONSE
 
Constructor Summary
EmailExecutor()
           
 
Method Summary
protected  java.lang.String createMessageId(MsgInfo msgInfo, java.lang.String requestId, MethodName methodName, java.sql.Timestamp expiryTimestamp)
           
 java.lang.String getBcc()
           
 java.lang.String getCc()
           
 long getDefaultResponseTimeout()
          Defaults to one day.
 long getDefaultUpdateResponseTimeout()
          Defaults to one day.
 java.lang.String getEmailSessionId()
          The sessionId used to register at Pop3Driver and send in subject: of email
 java.lang.String getEmailSessionId(MsgInfo msgInfo)
          Is overwritten for example by EmailDriver.java singleton.
 java.lang.String getFrom()
           
 java.lang.String getLoopProtectionList()
          Returns a comma seperated list of all 'from email addresses'.
protected  EmailExecutor.LoopProtection[] getLoopProtections()
           
 java.lang.String getMsgInfoParserClassName()
          Which parser to use.
 Pop3Driver getPop3Driver()
          Access the Pop3Driver.
 java.lang.String getSecretSessionId()
           
 SmtpClient getSmtpClient()
          TODO: Put into engine.Global and util.Global (see EventPlugin.java)
 java.lang.String getTo()
           
 java.lang.String getUsageUrl()
           
 void incomingMessage(java.lang.String requestId, java.lang.Object response)
          Notification by Pop3Driver when a (response) email message arrives.
 void init(Global glob, AddressBase addressBase, PluginInfo pluginConfig)
          This init() is called after the init(Global, PluginInfo)
 boolean isAlive()
           
protected  boolean isLoopingMail(MsgInfo msgInfo, EmailData emailData)
          Some weak looping protection.
 boolean isShutdown()
          I_AdminPlugin#isShutodwn
 java.lang.String ping(java.lang.String qos)
          Ping to check if callback server is alive.
protected  EmailExecutor.LoopProtection removeFromLoopProtection(java.lang.String key)
          Cleanup
 java.lang.Object sendEmail(MsgUnitRaw[] msgArr, MethodName methodName, boolean expectingResponse)
          This sends the update to the client.
 java.lang.Object sendEmail(MsgUnitRaw msgUnit, MethodName methodName, boolean expectingResponse)
           
 java.lang.Object sendEmail(java.lang.String qos, MethodName methodName, boolean expectingResponse)
           
 java.lang.Object sendEmail(java.lang.String key, java.lang.String qos, MethodName methodName, boolean expectingResponse)
           
protected  void sendMessage(MsgInfo msgInfo, java.lang.String requestId, MethodName methodName, boolean udp)
          Extends RequestReplyExecutor.sendMessage
 void sendUpdateOneway(MsgUnitRaw[] msgArr)
          The oneway variant, without return value.
 void setBcc(java.lang.String bcc)
          Send all emails additionally to the given bcc.
 void setCc(java.lang.String cc)
          Send all emails additionally to the given CC addresses.
protected  void setEmailSessionId(SessionName sessionName)
          Email protocol contract with server side CallbackEmailDriver.java and client side EmailCallbackImpl.java We use joe/2...
 void setEmailSessionId(java.lang.String emailSessionId)
           
 void setFrom(java.lang.String from)
          JMX
 void setSecretSessionId(java.lang.String secretSessionId)
           
 void setTo(java.lang.String to)
          JMX
 void setUsageUrl(java.lang.String url)
           
 void shutdown()
          This method shuts down the driver.
 java.lang.String usage()
           
 
Methods inherited from class org.xmlBlaster.util.protocol.RequestReplyExecutor
addResponseListener, clearResponseListenerMap, executeException, executeResponse, freePendingThreads, getAddressServer, getCbClient, getDefaultPingResponseTimeout, getExpiryTimestamp, getMinSizeForCompression, getPendingRequestList, getPingResponseTimeout, getProgressListener, getResponseListener, getResponseTimeout, getResponseTimeout, getResponseTimeout, getResponseTimeoutPropertyName, getType, getUpdateResponseTimeout, getXmlBlasterCore, hasConnection, initialize, initializeCb, interruptInvocation, isCompressZlib, isCompressZlibStream, isShutdownCompletly, isUseEmailExpiryTimestamp, receiveReply, registerProgressListener, removeResponseListener, requestAndBlockForReply, setCbClient, setCompressZlib, setCompressZlibStream, setLoginName, setMinSizeForCompression, setPingResponseTimeout, setResponseTimeout, setUpdateResponseTimeout, setUseEmailExpiryTimestamp, setXmlBlasterCore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xmlBlaster.util.protocol.RequestReplyExecutorMBean
getMinSizeForCompression, getPingResponseTimeout, getResponseTimeout, getResponseTimeout, getUpdateResponseTimeout, interruptInvocation, isCompressZlib, isCompressZlibStream, isUseEmailExpiryTimestamp, setCompressZlib, setCompressZlibStream, setMinSizeForCompression, setPingResponseTimeout, setResponseTimeout, setUpdateResponseTimeout, setUseEmailExpiryTimestamp
 
Methods inherited from interface org.xmlBlaster.util.admin.I_AdminPlugin
getType, getVersion
 

Field Detail

ME

private java.lang.String ME

log

private static java.util.logging.Logger log

isShutdown

private boolean isShutdown

addressBase

private AddressBase addressBase

pluginConfig

private I_PluginConfig pluginConfig

fromAddress

protected javax.mail.internet.InternetAddress fromAddress

toAddress

protected javax.mail.internet.InternetAddress toAddress

cc

protected java.lang.String cc

bcc

protected java.lang.String bcc

smtpClient

protected SmtpClient smtpClient

secretSessionId

private java.lang.String secretSessionId

emailSessionId

private java.lang.String emailSessionId

pop3Driver

protected Pop3Driver pop3Driver

compressor

private java.util.zip.Deflater compressor

decompressor

private java.util.zip.Inflater decompressor

msgInfoParserClassName

protected java.lang.String msgInfoParserClassName
Which message format parser to use


senderLoopProtectionMap

protected java.util.Map senderLoopProtectionMap

BOUNCE_MESSAGEID_KEY

protected final java.lang.String BOUNCE_MESSAGEID_KEY
See Also:
Constant Field Values

BOUNCE_MAILTO_KEY

public static final java.lang.String BOUNCE_MAILTO_KEY
See Also:
Constant Field Values

BOUNCE_MAILFROM_KEY

public static final java.lang.String BOUNCE_MAILFROM_KEY
See Also:
Constant Field Values

messageIdFileName

protected java.lang.String messageIdFileName
'messageId.mid'


payloadFileNamePrefix

protected java.lang.String payloadFileNamePrefix
The extension is added later to for example "xmlBlasterMessage.xfb"


subjectTemplate

protected java.lang.String subjectTemplate

SUBJECT_MESSAGEID_TOKEN

protected final java.lang.String SUBJECT_MESSAGEID_TOKEN
See Also:
Constant Field Values
Constructor Detail

EmailExecutor

public EmailExecutor()
Method Detail

init

public void init(Global glob,
                 AddressBase addressBase,
                 PluginInfo pluginConfig)
          throws XmlBlasterException
This init() is called after the init(Global, PluginInfo)

Parameters:
addressBase - Contains the email TO: address
Throws:
XmlBlasterException

getPop3Driver

public Pop3Driver getPop3Driver()
                         throws XmlBlasterException
Access the Pop3Driver.

Returns:
never null
Throws:
XmlBlasterException

getSmtpClient

public SmtpClient getSmtpClient()
                         throws XmlBlasterException
TODO: Put into engine.Global and util.Global (see EventPlugin.java)

Returns:
Throws:
XmlBlasterException

getDefaultResponseTimeout

public long getDefaultResponseTimeout()
Defaults to one day.

Overrides:
getDefaultResponseTimeout in class RequestReplyExecutor

getDefaultUpdateResponseTimeout

public long getDefaultUpdateResponseTimeout()
Defaults to one day.

Overrides:
getDefaultUpdateResponseTimeout in class RequestReplyExecutor

getMsgInfoParserClassName

public java.lang.String getMsgInfoParserClassName()
Which parser to use. The 'email' protocol uses as a default setting the XbfParser but usig the XmlScriptParser may be convenient as well.

The environment setting 'parserClass=' is checked.

Returns:
The class name of the parser, "org.xmlBlaster.util.xbformat.XbfParser"

sendEmail

public java.lang.Object sendEmail(java.lang.String qos,
                                  MethodName methodName,
                                  boolean expectingResponse)
                           throws XmlBlasterException
Throws:
XmlBlasterException

sendEmail

public java.lang.Object sendEmail(java.lang.String key,
                                  java.lang.String qos,
                                  MethodName methodName,
                                  boolean expectingResponse)
                           throws XmlBlasterException
Throws:
XmlBlasterException

sendEmail

public java.lang.Object sendEmail(MsgUnitRaw msgUnit,
                                  MethodName methodName,
                                  boolean expectingResponse)
                           throws XmlBlasterException
Throws:
XmlBlasterException

sendEmail

public java.lang.Object sendEmail(MsgUnitRaw[] msgArr,
                                  MethodName methodName,
                                  boolean expectingResponse)
                           throws XmlBlasterException
This sends the update to the client.

Parameters:
methodName - MethodName.UPDATE and others
withResponse - one of SocketExecutor.WAIT_ON_RESPONSE or SocketExecutor.ONEWAY
Throws:
XmlBlasterException

incomingMessage

public void incomingMessage(java.lang.String requestId,
                            java.lang.Object response)
Notification by Pop3Driver when a (response) email message arrives. Enforced by I_ResponseListener

Specified by:
incomingMessage in interface I_ResponseListener

isLoopingMail

protected boolean isLoopingMail(MsgInfo msgInfo,
                                EmailData emailData)
Some weak looping protection. Assume requestId to be strictly increasing to detect email duplicates (which can be produced by MTAs)


removeFromLoopProtection

protected EmailExecutor.LoopProtection removeFromLoopProtection(java.lang.String key)
Cleanup

Parameters:
key - this is the sender email address, for example "xmlBlaster@localhost" for a client or "demo@localhost" on server side (emailData.getFrom())
Returns:
The removed entry or null if not found

getLoopProtectionList

public java.lang.String getLoopProtectionList()
Returns a comma seperated list of all 'from email addresses'. Used for JMX.

Specified by:
getLoopProtectionList in interface EmailExecutorMBean
Returns:
For example "joe@localhost,blue@localhost", never null

getLoopProtections

protected EmailExecutor.LoopProtection[] getLoopProtections()

createMessageId

protected java.lang.String createMessageId(MsgInfo msgInfo,
                                           java.lang.String requestId,
                                           MethodName methodName,
                                           java.sql.Timestamp expiryTimestamp)
Returns:
messageId="sessionId:4423c4433subscribe"

sendMessage

protected void sendMessage(MsgInfo msgInfo,
                           java.lang.String requestId,
                           MethodName methodName,
                           boolean udp)
                    throws XmlBlasterException,
                           java.io.IOException
Extends RequestReplyExecutor.sendMessage

Specified by:
sendMessage in class RequestReplyExecutor
Throws:
XmlBlasterException
java.io.IOException

sendUpdateOneway

public void sendUpdateOneway(MsgUnitRaw[] msgArr)
                      throws XmlBlasterException
The oneway variant, without return value.

Throws:
XmlBlasterException - Is never from the client (oneway).

ping

public java.lang.String ping(java.lang.String qos)
                      throws XmlBlasterException
Ping to check if callback server is alive. This ping checks the availability on the application level.

Parameters:
qos - Currently an empty string ""
Returns:
Currently an empty string ""
Throws:
XmlBlasterException - If client not reachable

shutdown

public void shutdown()
This method shuts down the driver.

Specified by:
shutdown in interface I_AdminPlugin
Overrides:
shutdown in class RequestReplyExecutor

isShutdown

public boolean isShutdown()
I_AdminPlugin#isShutodwn

Specified by:
isShutdown in interface I_AdminPlugin
Overrides:
isShutdown in class RequestReplyExecutor
Returns:
true if down

isAlive

public boolean isAlive()
Returns:
true if the plugin is still alive, false otherwise

getSecretSessionId

public java.lang.String getSecretSessionId()
Returns:
Returns the secretSessionId.

setSecretSessionId

public void setSecretSessionId(java.lang.String secretSessionId)
Parameters:
secretSessionId - The secretSessionId to set.

getEmailSessionId

public java.lang.String getEmailSessionId()
The sessionId used to register at Pop3Driver and send in subject: of email

Returns:
Usually the clients relative login sessionName "client/joe/3", never null

getEmailSessionId

public java.lang.String getEmailSessionId(MsgInfo msgInfo)
Is overwritten for example by EmailDriver.java singleton.

Parameters:
msgInfo -
Returns:

setEmailSessionId

public void setEmailSessionId(java.lang.String emailSessionId)

setEmailSessionId

protected void setEmailSessionId(SessionName sessionName)
Email protocol contract with server side CallbackEmailDriver.java and client side EmailCallbackImpl.java We use joe/2... to find our response again. If no positive sessionId is given, the server generates e.g. -7 for us which we don't know In this case we use joe... only


getCc

public java.lang.String getCc()
Specified by:
getCc in interface EmailExecutorMBean
Returns:
Returns the cc.

setCc

public void setCc(java.lang.String cc)
Send all emails additionally to the given CC addresses. You can pass a comma separated list of addresses.

Specified by:
setCc in interface EmailExecutorMBean
Parameters:
cc - The copy addresses, for example "joe@localhost,jack@localhost"

setTo

public void setTo(java.lang.String to)
           throws java.lang.IllegalArgumentException
JMX

Specified by:
setTo in interface EmailExecutorMBean
Throws:
java.lang.IllegalArgumentException

getTo

public java.lang.String getTo()
Specified by:
getTo in interface EmailExecutorMBean
Returns:
Returns the 'to' email address.

setFrom

public void setFrom(java.lang.String from)
             throws java.lang.IllegalArgumentException
JMX

Specified by:
setFrom in interface EmailExecutorMBean
Throws:
java.lang.IllegalArgumentException

getFrom

public java.lang.String getFrom()
Specified by:
getFrom in interface EmailExecutorMBean
Returns:
Returns the 'from' email address.

getBcc

public java.lang.String getBcc()
Specified by:
getBcc in interface EmailExecutorMBean
Returns:
Returns the blind copy email addresses or null

setBcc

public void setBcc(java.lang.String bcc)
Send all emails additionally to the given bcc. You can pass a comma separated list of addresses.

Specified by:
setBcc in interface EmailExecutorMBean
Parameters:
bcc - The blind copy addresses, for example "joe@localhost,jack@localhost"

usage

public java.lang.String usage()
Specified by:
usage in interface I_AdminUsage
Overrides:
usage in class RequestReplyExecutor
Returns:
a human readable usage help string

getUsageUrl

public java.lang.String getUsageUrl()
Specified by:
getUsageUrl in interface I_AdminUsage
Returns:
A link for JMX usage

setUsageUrl

public void setUsageUrl(java.lang.String url)
Specified by:
setUsageUrl in interface I_AdminUsage

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.