com.openexchange.mail.service.impl
Class MailServiceImpl

java.lang.Object
  extended by com.openexchange.mail.service.impl.MailServiceImpl
All Implemented Interfaces:
MailService

public final class MailServiceImpl
extends java.lang.Object
implements MailService

MailServiceImpl - The mail service implementation

Author:
Thorben Betten

Constructor Summary
MailServiceImpl()
          Initializes a new MailServiceImpl
 
Method Summary
 MailAccess<?,?> getMailAccess(com.openexchange.session.Session session, int accountId)
          Gets an appropriate instance of mail access parameterized with given session.
 MailTransport getMailTransport(com.openexchange.session.Session session, int accountId)
          Gets an appropriate instance of mail transport parameterized with given session.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailServiceImpl

public MailServiceImpl()
Initializes a new MailServiceImpl

Method Detail

getMailAccess

public MailAccess<?,?> getMailAccess(com.openexchange.session.Session session,
                                     int accountId)
                              throws MailException
Description copied from interface: MailService
Gets an appropriate instance of mail access parameterized with given session.

When starting to work with obtained mail access at first its MailAccess.connect() method is supposed to be invoked. On finished work the final MailAccess.close(boolean) must be called in order to release resources:

 final MailAccess mailAccess = mailService.getMailAccess(session);
 mailAccess.connect();
 try {
        // Do something
 } finally {
        mailAccess.close(putToCache)
 }
 

Specified by:
getMailAccess in interface MailService
Parameters:
session - The session
accountId - The account ID
Returns:
An appropriate instance of MailAccess
Throws:
MailException - If an appropriate instance of mail access cannot be initialized

getMailTransport

public MailTransport getMailTransport(com.openexchange.session.Session session,
                                      int accountId)
                               throws MailException
Description copied from interface: MailService
Gets an appropriate instance of mail transport parameterized with given session.

Note: Don't forget to call final MailTransport.close() on obtained mail transport:

 final MailTransport mailTransport = mailService.getMailTransport(session);
 try {
     // Do something
 } finally {
     mailTransport.close();
 }
 

Specified by:
getMailTransport in interface MailService
Parameters:
session - The session providing needed user data
accountId - The account ID
Returns:
An appropriate instance of MailTransport
Throws:
MailException - If an appropriate instance of mail transport cannot be initialized