org.jboss.net.axis.transport.mailto.server
Class MailTransportService

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.net.axis.transport.mailto.AbstractMailTransportService (src) 
              extended byorg.jboss.net.axis.transport.mailto.server.MailTransportService
All Implemented Interfaces:
MailConstants (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src)

public class MailTransportService
extends AbstractMailTransportService (src)
implements MailConstants (src)

Title:
Mail Transport MBean

Description:

This MBean is the service that polls the mail box (pop/imap) and processes any soap messages it finds there.

To define a mail transport and the transport level handlers, the jboss-net.sar/server-config.wsdd file must be modified to include:

   <transport name="mail">
     <requestFlow>
       <handler type="java:org.jboss.net.axis.transport.mail.server.handler.TargetServiceHandler"/>
     </requestFlow>
     <responseFlow>
       <!-- response flow specific handlers can go here -->
     </responseFlow>
   </transport>
 

To enable this service edit the jboss-net.sar/META-INF/jboss-service.xml file to include :

   <mbean code="org.jboss.net.axis.transport.mailto.server.MailTransportService" 
          name="jboss.net:service=MailTransport">
     <depends>jboss.net:service=Axis</depends>
     <attribute name="SessionName">java:/Mail</attribute>
     <attribute name="FolderName">INBOX</attribute>
     <attribute name="TransportName">mail</attribute>
     <attribute name="EngineName">jboss.net:service=Axis</attribute>
     <attribute name="DeleteMail">true</attribute>
   </mbean>
 

If you don't want to hammer on the pollMail button from the mbean interface (jmx|web-console) then it would be best to set up a schedule to do it for you (again in the jboss-service.xml file:

   <mbean code="org.jboss.varia.scheduler.Scheduler" 
         name="jboss.net:service=Scheduler,name=MailTransport">
      <attribute name="StartAtStartup">true</attribute>
      <attribute name="SchedulableMBean">jboss.net:service=MailTransport</attribute>
      <attribute name="SchedulableMBeanMethod">pollMail()</attribute>
      <attribute name="InitialStartDate">NOW</attribute>
      <attribute name="SchedulePeriod">30000</attribute>
      <attribute name="InitialRepetitions">-1</attribute>
   </mbean>
 

This transport assumes the use of ws-addressing handlers and as such has no provision for sending a response. The addressing handler will create a new call with the response if there is a wsa:Reply-To header. Otherwise the response will disappear into the ether with nary a log entry.


Field Summary
 
Fields inherited from class org.jboss.net.axis.transport.mailto.AbstractMailTransportService (src)
ENGINE_NAME, FOLDER_NAME, SESSION_NAME
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
log, SERVICE_CONTROLLER_SIG, serviceName
 
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
 
Fields inherited from interface org.jboss.system.ServiceMBean (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
MailTransportService()
           
 
Method Summary
protected  void archiveMessage(java.lang.String msgID, MessageContext msgCtx)
          Override this method if you need to store incoming messages.
Note: If web service security handlers are in the handler chain, the message will not have been verified/decrypted yet.
protected  MessageContext createMessageContext(AxisEngine engine, Message msg)
          Creates a message context that will be used while processing this request.
 AxisServer getEngine()
          override AxisServlet.getEngine() in order to redirect to the corresponding AxisEngine.
 java.lang.String getTransportName()
           
protected  java.lang.String processHeaders(MessageContext ctx, Message msg)
           
protected  void processMessageBody(MessageContext mc, Message msg)
          Serialize the email message body into a SOAPMessage.
protected  void processMessages(Message[] msgs)
           
 void setTransportName(java.lang.String name)
           
 
Methods inherited from class org.jboss.net.axis.transport.mailto.AbstractMailTransportService (src)
closeFolder, closeStore, fetchMessages, getDeleteMail, getEngineName, getFolderName, getMailFolder, getMailSession, getMailStore, getSessionName, pollMail, setDeleteMail, setEngineName, setFolderName, setSessionName
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, createService, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, startService, stop, stopService
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailTransportService

public MailTransportService()
Method Detail

getTransportName

public java.lang.String getTransportName()
Returns:
The name this transport has been given.

setTransportName

public void setTransportName(java.lang.String name)
Parameters:
name - The name this transport will be known as (smtp for instance).

getEngine

public AxisServer getEngine()
                     throws AxisFault
override AxisServlet.getEngine() in order to redirect to the corresponding AxisEngine. This is taken pretty much verbatem from the AxisServiceServlet

Throws:
AxisFault

processMessages

protected void processMessages(Message[] msgs)
Specified by:
processMessages in class AbstractMailTransportService (src)

createMessageContext

protected MessageContext createMessageContext(AxisEngine engine,
                                              Message msg)
                                       throws AxisFault
Creates a message context that will be used while processing this request.

Parameters:
engine - Server engine
msg - Email message
Returns:
Throws:
AxisFault

processMessageBody

protected void processMessageBody(MessageContext mc,
                                  Message msg)
                           throws AxisFault
Serialize the email message body into a SOAPMessage.

Parameters:
mc - MessageContext that will be used while processing this message
msg - Email Message
Throws:
AxisFault - if we need to abort this message (drop the context and delete the email message with out sending a response message.)

processHeaders

protected java.lang.String processHeaders(MessageContext ctx,
                                          Message msg)
                                   throws AxisFault
Parameters:
ctx - MessageContext that is being used for processing this request
msg - Email message that is theoretically holding a SOAP request.
Returns:
The value of the first Message-ID header found.
Throws:
AxisFault

archiveMessage

protected void archiveMessage(java.lang.String msgID,
                              MessageContext msgCtx)
Override this method if you need to store incoming messages.
Note: If web service security handlers are in the handler chain, the message will not have been verified/decrypted yet.

Parameters:
msgID -
msgCtx -