public final class MailServiceImpl extends java.lang.Object implements MailService
MailServiceImpl
- The mail service implementationConstructor and Description |
---|
MailServiceImpl()
Initializes a new
MailServiceImpl |
Modifier and Type | Method and Description |
---|---|
MailAccess<? extends IMailFolderStorage,? extends IMailMessageStorage> |
getMailAccess(int userId,
int contextId,
int accountId)
Gets an appropriate instance of
mail access parameterized with given session. |
MailAccess<? extends IMailFolderStorage,? extends IMailMessageStorage> |
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. |
public MailServiceImpl()
MailServiceImpl
public MailAccess<? extends IMailFolderStorage,? extends IMailMessageStorage> getMailAccess(com.openexchange.session.Session session, int accountId) throws com.openexchange.exception.OXException
MailService
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:
MailAccess mailAccess = null; try { mailAccess = mailService.getMailAccess(session); mailAccess.connect(); // Do something } finally { if (mailAccess != null) { mailAccess.close(putToCache); } }
getMailAccess
in interface MailService
session
- The sessionaccountId
- The account IDMailAccess
com.openexchange.exception.OXException
- If an appropriate instance of mail access
cannot be initializedpublic MailAccess<? extends IMailFolderStorage,? extends IMailMessageStorage> getMailAccess(int userId, int contextId, int accountId) throws com.openexchange.exception.OXException
MailService
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:
MailAccess mailAccess = null; try { mailAccess = mailService.getMailAccess(...); mailAccess.connect(); // Do something } finally { if (mailAccess != null) { mailAccess.close(putToCache); } }
getMailAccess
in interface MailService
userId
- The user IDcontextId
- The context IDaccountId
- The account IDMailAccess
com.openexchange.exception.OXException
- If an appropriate instance of mail access
cannot be initializedpublic MailTransport getMailTransport(com.openexchange.session.Session session, int accountId) throws com.openexchange.exception.OXException
MailService
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(); }
getMailTransport
in interface MailService
session
- The session providing needed user dataaccountId
- The account IDMailTransport
com.openexchange.exception.OXException
- If an appropriate instance of mail transport
cannot be initialized