org.jboss.jca.adapters.mail.inflow
Class MailFolder

java.lang.Object
  extended by org.jboss.jca.adapters.mail.inflow.MailFolder
All Implemented Interfaces:
Iterator
Direct Known Subclasses:
IMAPMailFolder, POP3MailFolder

public abstract class MailFolder
extends Object
implements Iterator

An encapsulation of a mail store folder used by the MailActivation.run to poll and retrieve new messages.

Author:
Scott Stark, Jesper Pedersen

Constructor Summary
MailFolder(MailActivationSpec spec)
          Constructor
 
Method Summary
 void close()
          Closes the mail session
protected  void close(boolean checkSuccessful)
          Closes a mail session
protected abstract  void closeStore(boolean success, javax.mail.Store store, javax.mail.Folder folder)
          Close a store
static MailFolder getInstance(MailActivationSpec mailActivationSpec)
          Get an instance of a mail folder
protected abstract  javax.mail.Message[] getMessages(javax.mail.Folder folder)
          Get the messages from a folder
 boolean hasNext()
          
protected abstract  void markMessageSeen(javax.mail.Message message)
          Mark a message as seen
 Object next()
          
 void open()
          Open a mail session
protected abstract  javax.mail.Store openStore(javax.mail.Session session)
          Open a store
 void remove()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailFolder

public MailFolder(MailActivationSpec spec)
Constructor

Parameters:
spec - The mail activation spec
Method Detail

open

public void open()
          throws Exception
Open a mail session

Throws:
Exception - Thrown if a session can't be established

close

public void close()
           throws javax.mail.MessagingException
Closes the mail session

Throws:
javax.mail.MessagingException - Thrown if an error occurs duing close

hasNext

public boolean hasNext()

Specified by:
hasNext in interface Iterator

next

public Object next()

Specified by:
next in interface Iterator

remove

public void remove()

Specified by:
remove in interface Iterator

close

protected void close(boolean checkSuccessful)
Closes a mail session

Parameters:
checkSuccessful - Check if it was a successful close

getInstance

public static MailFolder getInstance(MailActivationSpec mailActivationSpec)
Get an instance of a mail folder

Parameters:
mailActivationSpec - The mail activation spec
Returns:
The mail folder; null if not IMAP / POP based

openStore

protected abstract javax.mail.Store openStore(javax.mail.Session session)
                                       throws javax.mail.NoSuchProviderException
Open a store

Parameters:
session - The mail session
Returns:
The store
Throws:
javax.mail.NoSuchProviderException - Thrown if there is no provider

closeStore

protected abstract void closeStore(boolean success,
                                   javax.mail.Store store,
                                   javax.mail.Folder folder)
                            throws javax.mail.MessagingException
Close a store

Parameters:
success - Check for successful close
store - The store
folder - The folder
Throws:
javax.mail.MessagingException - Thrown if there is an error

getMessages

protected abstract javax.mail.Message[] getMessages(javax.mail.Folder folder)
                                             throws javax.mail.MessagingException
Get the messages from a folder

Parameters:
folder - The folder
Returns:
The messages
Throws:
javax.mail.MessagingException - Thrown if there is an error

markMessageSeen

protected abstract void markMessageSeen(javax.mail.Message message)
                                 throws javax.mail.MessagingException
Mark a message as seen

Parameters:
message - The messages
Throws:
javax.mail.MessagingException - Thrown if there is an error


Copyright © 2008 Red Hat Middleware LLC (http://www.jboss.com/)