|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.openexchange.mail.api.MailAccess<F,M>
public abstract class MailAccess<F extends IMailFolderStorage,M extends IMailMessageStorage>
MailAccess - Handles connecting to the mailing system while using an internal cache for connected access objects (see
MailAccessCache).
Moreover it provides access to either message storage, folder storage and logic tools.
| Method Summary | |
|---|---|
void |
addWarnings(java.util.Collection<MailException> warnings)
Adds given warnings. |
void |
close(boolean put2Cache)
Closes this access. |
void |
connect()
Opens this access. |
void |
connect(boolean checkDefaultFolders)
Opens this access. |
boolean |
delegateCheckMailServerPort()
For delegating purpose. |
void |
delegateCloseInternal()
For delegating purpose. |
void |
delegateConnectInternal()
For delegating purpose. |
MailConfig |
delegateCreateNewMailConfig()
For delegating purpose. |
IMailProperties |
delegateCreateNewMailProperties()
For delegating purpose. |
void |
delegateReleaseResources()
For delegating purpose. |
int |
getAccountId()
Gets this mail access' account ID. |
int |
getCacheIdleSeconds()
Gets the number of seconds this mail access is allowed to remain idle in cache before being removed and
closed. |
static int |
getCounter()
|
abstract F |
getFolderStorage()
Gets the appropriate IMailFolderStorage implementation that is considered as the main entry point to a user's mailbox. |
static MailAccess<? extends IMailFolderStorage,? extends IMailMessageStorage> |
getInstance(int userId,
int contextId)
Gets the proper instance of MailAccess for specified user's default account. |
static MailAccess<? extends IMailFolderStorage,? extends IMailMessageStorage> |
getInstance(int userId,
int contextId,
int accountId)
Gets the proper instance of MailAccess for specified user and account ID. |
static MailAccess<? extends IMailFolderStorage,? extends IMailMessageStorage> |
getInstance(com.openexchange.session.Session session)
Gets the proper instance of MailAccess for session user's default mail account. |
static MailAccess<? extends IMailFolderStorage,? extends IMailMessageStorage> |
getInstance(com.openexchange.session.Session session,
int accountId)
Gets the proper instance of MailAccess parameterized with given session and account ID. |
abstract MailLogicTools |
getLogicTools()
Gets the appropriate MailLogicTools implementation that provides operations/methods to create a reply/forward message from a
referenced message. |
MailConfig |
getMailConfig()
Returns the mail configuration appropriate for current user. |
java.util.Properties |
getMailProperties()
Gets the optional properties used on connect. |
abstract M |
getMessageStorage()
Gets the appropriate IMailMessageStorage implementation that provides necessary message-related operations/methods. |
MailFolder |
getRootFolder()
Convenience method to obtain root folder in a fast way; meaning no default folder check is performed which is not necessary to return the root folder. |
java.lang.String |
getTrace()
Gets the trace of the thread that lastly obtained this access. |
int |
getUnreadMessagesCount(java.lang.String fullname)
Convenience method to obtain folder's number of unread messages in a fast way; meaning no default folder check is performed. |
java.util.Collection<MailException> |
getWarnings()
Gets possible warnings. |
boolean |
isCacheable()
Indicates if this mail access is cacheable. |
abstract boolean |
isConnected()
Checks if this connection is currently connected. |
abstract boolean |
isConnectedUnsafe()
Checks if this connection is currently connected in an unsafe, but faster manner than isConnected(). |
boolean |
ping()
Pings the mail server to check if a connection can be established and and immediately closes connection. |
void |
setCacheable(boolean cacheable)
Sets whether this mail access is cacheable or not. |
void |
setMailProperties(java.util.Properties mailProperties)
Sets optional properties used on connect. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public void addWarnings(java.util.Collection<MailException> warnings)
warnings - The warnings to addpublic java.util.Collection<MailException> getWarnings()
public static final MailAccess<? extends IMailFolderStorage,? extends IMailMessageStorage> getInstance(com.openexchange.session.Session session)
throws MailException
MailAccess for session user's default mail account.
When starting to work with obtained mail access at first its connect() method is supposed to be invoked.
On finished work the final close(boolean) must be called:
final MailAccess mailAccess = MailAccess.getInstance(session);
mailAccess.connect();
try {
// Do something
} finally {
mailAccess.close(putToCache)
}
session - The session
MailAccess
MailException - If instantiation fails or a caching error occurs
public static final MailAccess<? extends IMailFolderStorage,? extends IMailMessageStorage> getInstance(com.openexchange.session.Session session,
int accountId)
throws MailException
MailAccess parameterized with given session and account ID.
When starting to work with obtained mail access at first its connect() method is supposed to be invoked.
On finished work the final close(boolean) must be called:
final MailAccess mailAccess = MailAccess.getInstance(session, accountID);
mailAccess.connect();
try {
// Do something
} finally {
mailAccess.close(putToCache)
}
session - The sessionaccountId - The account ID
MailAccess
MailException - If instantiation fails or a caching error occurs
public static final MailAccess<? extends IMailFolderStorage,? extends IMailMessageStorage> getInstance(int userId,
int contextId)
throws MailException
MailAccess for specified user's default account.
When starting to work with obtained mail access at first its connect() method is supposed to be invoked.
On finished work the final close(boolean) must be called:
final MailAccess mailAccess = MailAccess.getInstance(session, accountID);
mailAccess.connect();
try {
// Do something
} finally {
mailAccess.close(putToCache)
}
userId - The user identifiercontextId - The context identifier
mail access
MailException - If instantiation fails or a caching error occurs
public static final MailAccess<? extends IMailFolderStorage,? extends IMailMessageStorage> getInstance(int userId,
int contextId,
int accountId)
throws MailException
MailAccess for specified user and account ID.
When starting to work with obtained mail access at first its connect() method is supposed to be invoked.
On finished work the final close(boolean) must be called:
final MailAccess mailAccess = MailAccess.getInstance(session, accountID);
mailAccess.connect();
try {
// Do something
} finally {
mailAccess.close(putToCache)
}
userId - The user identifiercontextId - The context identifieraccountId - The account identifier
mail access
MailException - If instantiation fails or a caching error occurspublic static final int getCounter()
public java.util.Properties getMailProperties()
public void setMailProperties(java.util.Properties mailProperties)
mailProperties - The properties
public boolean ping()
throws MailException
Default implementation just delegates to connect() but may be overridden in implementing subclass if not appropriate or a
faster way can be achieved.
true if a connection can be established; otherwise false
MailException - If the ping fails
public final void connect()
throws MailException
MailException - If the connection could not be established for various reasons
public final void connect(boolean checkDefaultFolders)
throws MailException
checkDefaultFolders - true to check existence of default folders; otherwise false to omit check
MailException - If the connection could not be established for various reasons
public MailFolder getRootFolder()
throws MailException
The same result is yielded through calling getFolderStorage().getRootFolder() on a connected MailAccess.
Since this mail access instance is connected if not already done before, the close(boolean) operation should be invoked
afterwards:
final MailAccess mailAccess = MailAccess.getInstance(session);
final MailFolder rootFolder = mailAccess.getRootFolder();
try {
// Do something with root folder
} finally {
mailAccess.close(putToCache)
}
MailException - If returning the root folder fails
public int getUnreadMessagesCount(java.lang.String fullname)
throws MailException
The same result is yielded through calling getFolderStorage().getFolder().getUnreadMessageCount() on a connected
MailAccess.
Since this mail access instance is connected if not already done before, the close(boolean) operation should be invoked
afterwards:
final MailAccess mailAccess = MailAccess.getInstance(session);
final int unreadCount = mailAccess.getNumberOfUnreadMessages();
try {
// Do something with unread count
} finally {
mailAccess.close(putToCache)
}
MailException - If returning the unread count fails
public void delegateConnectInternal()
throws MailException
MailExceptionpublic final void close(boolean put2Cache)
An already closed access is not going to be put into cache and is treated as a no-op.
put2Cache - true to try to put this mail connection into cache; otherwise falsepublic final java.lang.String getTrace()
This is useful to detect certain threads which uses an access for a long time
public MailConfig getMailConfig()
throws MailException
MailExceptionpublic int getAccountId()
public int getCacheIdleSeconds()
cache before being removed and
closed. If the default value shall be used for this mail access, return -1.
-1 to signal using default value.public boolean isCacheable()
true if this mail access is cacheable; otherwise falsepublic void setCacheable(boolean cacheable)
cacheable - true if this mail access is cacheable; otherwise falsepublic MailConfig delegateCreateNewMailConfig()
public IMailProperties delegateCreateNewMailProperties()
throws MailException
MailExceptionpublic boolean delegateCheckMailServerPort()
public void delegateReleaseResources()
public void delegateCloseInternal()
public abstract F getFolderStorage()
throws MailException
IMailFolderStorage implementation that is considered as the main entry point to a user's mailbox.
IMailFolderStorage implementation
MailException - If connection is not established
public abstract M getMessageStorage()
throws MailException
IMailMessageStorage implementation that provides necessary message-related operations/methods.
IMailMessageStorage implementation
MailException - If connection is not established
public abstract MailLogicTools getLogicTools()
throws MailException
MailLogicTools implementation that provides operations/methods to create a reply/forward message from a
referenced message.
MailLogicTools implementation
MailException - If connection is not establishedpublic abstract boolean isConnected()
true if connected; otherwise falseisConnectedUnsafe()public abstract boolean isConnectedUnsafe()
isConnected().
true if connected; otherwise falseisConnected()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||