org.jboss.net.axis.transport.mailto.client
Class BaseMailSender

java.lang.Object
  extended byBasicHandler
      extended byorg.jboss.net.axis.transport.mailto.client.BaseMailSender
All Implemented Interfaces:
MailConstants (src)
Direct Known Subclasses:
AsyncMailSender (src) , SyncMailSender (src)

public class BaseMailSender
extends BasicHandler
implements MailConstants (src)

Title:
Mail Sender

Description:
This is the Email Transport's Client Side Pivot. This handler manages sending email and attempting to get a response email from the server.
To properly setup this transport you will need a client-deploy.wsdd that contains something like:
  <handler name="MailSender" type="java:org.jboss.net.axis.transport.mail.client.MailSender" >
    <parameter name="username" value="user"/>
    <parameter name="password" value="pass"/>
    <parameter name="timeout" value="120"/>
    <!-- any relavent javamail properties may be set here, these are just an example of some posibilities -->
    <parameter name="mail.store.protocol" value="pop3"/>
    <parameter name="mail.transport.protocol" value="smtp"/>
    <parameter name="mail.host" value="mail.someserver.com"/>
    <parameter name="mail.user" value="user"/>
    <parameter name="mail.from" value="user@someserver.com"/>
    <parameter name="mail.debug" value="false"/>
  </handler>
  <transport name="mail" pivot="MailSender"/>
 
The parameters "username" and "password" are optional. If your mail server doesn't require authentication they can be omitted. The parameter "timeout" is to specify the number of minutes the transport will attempt to retrieve a response from the server. The default is 30 minutes. Any valid Javamail properties may be specified as parameters, and they will be read and used by the transport.

See Also:
Serialized Form

Field Summary
protected  Logger log
           
static java.lang.String MAIL_PROPS
           
protected static java.util.Properties mailProps
          If a JavaMail session is not stored in jndi, this field will hold the JavaMail properties used to create a session.
protected static java.lang.String mailSessionName
          The name of a javamail session from jndi that we should use rather than creating a new one.
static java.lang.String SESSION_NAME
           
static java.lang.String TRANS_PROPS
           
 
Fields inherited from interface org.jboss.net.axis.transport.mailto.MailConstants (src)
HEADER_CONTENT_TRANSFER_ENCODING, HEADER_CONTENT_TYPE, HEADER_FROM, HEADER_IN_REPLY_TO, HEADER_MESSAGE_ID, HEADER_TO
 
Constructor Summary
BaseMailSender()
           
 
Method Summary
protected  void archiveMessage(java.lang.String msgID, MessageContext msgCtx)
          Override this method if you need to store outgoing messages.
Note: If web service security handlers are in the handler chain, the message will be signed/encrypted here.
protected  void checkResponse(MessageContext ctx)
          Override this method if you want the client to block until it recieves a response.
In reality, this is probably only usefull for testing since email is not really a synchronous operation.
protected  java.util.Properties getJavaMailProperties()
          This handler expects the JavaMail properties to be specified in the wsdd (if no SessionName is set).
protected  Session getMailSession()
          Fetch a mail session.
 void invoke(MessageContext ctx)
           
protected  java.lang.String sendMail(MessageContext ctx)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAIL_PROPS

public static final java.lang.String MAIL_PROPS
See Also:
Constant Field Values (src)

TRANS_PROPS

public static final java.lang.String TRANS_PROPS
See Also:
Constant Field Values (src)

SESSION_NAME

public static final java.lang.String SESSION_NAME
See Also:
Constant Field Values (src)

log

protected Logger log

mailProps

protected static java.util.Properties mailProps
If a JavaMail session is not stored in jndi, this field will hold the JavaMail properties used to create a session.


mailSessionName

protected static java.lang.String mailSessionName
The name of a javamail session from jndi that we should use rather than creating a new one.

Constructor Detail

BaseMailSender

public BaseMailSender()
Method Detail

invoke

public void invoke(MessageContext ctx)
            throws AxisFault
Throws:
AxisFault

sendMail

protected java.lang.String sendMail(MessageContext ctx)
                             throws AxisFault
Throws:
AxisFault

archiveMessage

protected void archiveMessage(java.lang.String msgID,
                              MessageContext msgCtx)
Override this method if you need to store outgoing messages.
Note: If web service security handlers are in the handler chain, the message will be signed/encrypted here.

Parameters:
msgID -
msgCtx -

checkResponse

protected void checkResponse(MessageContext ctx)
                      throws AxisFault
Override this method if you want the client to block until it recieves a response.
In reality, this is probably only usefull for testing since email is not really a synchronous operation.

Parameters:
ctx -
Throws:
AxisFault

getJavaMailProperties

protected java.util.Properties getJavaMailProperties()
                                              throws AxisFault
This handler expects the JavaMail properties to be specified in the wsdd (if no SessionName is set). If the properties aren't there it will look for a parameter by the name of transport.properties that holds the name of a properties file (to be loaded by the classloader) with the required properties (only javamail properties will be loaded from this file, timeout and authentication information, if included, will be ignored). As a last resort the handler will search the classpath for MailTransportClient.properties. The precidence is transport.properties, properties in the options, then default file.

Returns:
Throws:
AxisFault

getMailSession

protected Session getMailSession()
                          throws AxisFault
Fetch a mail session.

Returns:
Session
Throws:
AxisFault