com.pushtotest.tool.protocolhandler
Class MailProtocol

java.lang.Object
  extended by com.pushtotest.tool.protocolhandler.ProtocolWrapper
      extended by com.pushtotest.tool.protocolhandler.MailProtocol
All Implemented Interfaces:
Protocol, java.lang.Runnable

public class MailProtocol
extends ProtocolWrapper

This is the implementation of the Mail Protocol handler to support SMTP, POP3 and IMAP email protocols. TOOL uses the Java Mail API to handle email.


Field Summary
 
Fields inherited from class com.pushtotest.tool.protocolhandler.ProtocolWrapper
body, errno, header, host, name, pass, path, port, proxyHost, proxyPass, proxyPort, proxyUser, query, response, running, scheme, timeout, type, url
 
Fields inherited from interface com.pushtotest.tool.protocolhandler.Protocol
IOERROR, NOERROR, NOTREADY, OTHER, TIMEOUT
 
Constructor Summary
MailProtocol()
           
 
Method Summary
 Response connect()
          Opens a connection to the mail host to receive messages
 java.lang.String getProtocol()
          Gets the protocol for receiving mail, either POP3 or IMAP
 javax.mail.Session getSession()
           
 java.lang.String id()
          Returns an id for this protocol.
 void send()
          Calling this method causes a connection to the mail host to be made.
 void setProtocol(java.lang.String theprot)
          Sets the POP3 or IMAP protocol for receiving mail Default is POP3.
protected  boolean supports(java.lang.String id)
          Tests to see if this protocol will support a specific type.
 
Methods inherited from class com.pushtotest.tool.protocolhandler.ProtocolWrapper
getBody, getErrno, getHost, getPassword, getResponse, getTimeout, getUrl, getUrl, getURL, getUsername, isRunning, parseUrl, run, setBody, setErrno, setHeader, setHost, setPassword, setPath, setPort, setProxyHost, setProxyPass, setProxyPort, setProxyUser, setQueryString, setScheme, setTimeout, setType, setUrl, setUsername, supportsBody, supportsHeader, supportsResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailProtocol

public MailProtocol()
Method Detail

id

public java.lang.String id()
Returns an id for this protocol. The id is a string that will be used to uniquily identify the protocol.

Specified by:
id in interface Protocol
Specified by:
id in class ProtocolWrapper
Returns:
The id for this Protocol.

send

public void send()
          throws NotReadyException,
                 NoSuchClassException,
                 ToolException,
                 java.io.IOException
Calling this method causes a connection to the mail host to be made. The message created in the Body object is sent to the host.

Specified by:
send in class ProtocolWrapper
Throws:
NotReadyException - If the connect is called without all of the proper pieces set that it needs to connect to the given protocol.
ConnectionTimeoutException - If a timeout was set and that timeout is reached before the connection is completed.
NoSuchClassException
ToolException
java.io.IOException

getSession

public javax.mail.Session getSession()

setProtocol

public void setProtocol(java.lang.String theprot)
Sets the POP3 or IMAP protocol for receiving mail Default is POP3.


getProtocol

public java.lang.String getProtocol()
Gets the protocol for receiving mail, either POP3 or IMAP


connect

public Response connect()
                 throws NotReadyException,
                        NoSuchClassException,
                        ToolException,
                        java.io.IOException
Opens a connection to the mail host to receive messages

Specified by:
connect in interface Protocol
Specified by:
connect in class ProtocolWrapper
Returns:
Response object provides methods to get and delete email messages
Throws:
NotReadyException - If the connect is called without all of the proper pieces set that it needs to connect to the given protocol.
ConnectionTimeoutException - If a timeout was set and that timeout is reached before the connection is completed.
NoSuchClassException
ToolException
java.io.IOException

supports

protected boolean supports(java.lang.String id)
Tests to see if this protocol will support a specific type. Can be used to determine if a given Header, Body, etc can be passed into this Protocol. This uses the inherited supportsBody, supportsHeader, etc since they should all use either 'mail'.

Overrides:
supports in class ProtocolWrapper
Parameters:
id - The string id to test.