public class JPAMessageMapper extends AbstractMessageMapper<Long> implements MessageMapper<Long>
MessageMapper. This class is not thread-safe!MessageMapper.FetchTypeMapper.Transaction<T>, Mapper.VoidTransaction| Modifier and Type | Field and Description |
|---|---|
protected javax.persistence.EntityManager |
entityManager |
protected javax.persistence.EntityManagerFactory |
entityManagerFactory |
mailboxSession| Constructor and Description |
|---|
JPAMessageMapper(MailboxSession session,
UidProvider<Long> uidProvider,
ModSeqProvider<Long> modSeqProvider,
javax.persistence.EntityManagerFactory entityManagerFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
begin()
Begin transaction
|
protected void |
commit()
Commit the Transaction and close the EntityManager
|
protected MessageMetaData |
copy(Mailbox<Long> mailbox,
long uid,
long modSeq,
Message<Long> original)
Copy the Message to the Mailbox, using the given uid and modSeq for the new Message
|
long |
countMessagesInMailbox(Mailbox<Long> mailbox)
Return the count of messages in the mailbox
|
long |
countUnseenMessagesInMailbox(Mailbox<Long> mailbox)
Return the count of unseen messages in the mailbox
|
void |
delete(Mailbox<Long> mailbox,
Message<Long> message)
Delete the given
Message |
void |
endRequest()
Close open
EntityManager |
Map<Long,MessageMetaData> |
expungeMarkedForDeletionInMailbox(Mailbox<Long> mailbox,
MessageRange set)
Return a
Iterator which holds the uids for all deleted Messages for the given MessageRange which are marked for deletion
The list must be ordered |
Long |
findFirstUnseenMessageUid(Mailbox<Long> mailbox)
Return the uid of the first unseen message.
|
Iterator<Message<Long>> |
findInMailbox(Mailbox<Long> mailbox,
MessageRange set,
MessageMapper.FetchType fType,
int max)
|
List<Long> |
findRecentMessageUidsInMailbox(Mailbox<Long> mailbox)
Return a List of
Message which are recent. |
javax.persistence.EntityManager |
getEntityManager()
Return the currently used
EntityManager or a new one if none exists. |
protected void |
rollback()
Rollback transaction
|
protected MessageMetaData |
save(Mailbox<Long> mailbox,
Message<Long> message)
|
add, copy, getHighestModSeq, getLastUid, updateFlagsexecuteclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadd, copy, getHighestModSeq, getLastUid, updateFlagsprotected javax.persistence.EntityManagerFactory entityManagerFactory
protected javax.persistence.EntityManager entityManager
public JPAMessageMapper(MailboxSession session, UidProvider<Long> uidProvider, ModSeqProvider<Long> modSeqProvider, javax.persistence.EntityManagerFactory entityManagerFactory)
public javax.persistence.EntityManager getEntityManager()
EntityManager or a new one if none exists.protected void begin()
throws MailboxException
TransactionalMapperbegin in class TransactionalMapperMailboxExceptionTransactionalMapper.begin()protected void commit()
throws MailboxException
commit in class TransactionalMapperMailboxExceptionprotected void rollback()
throws MailboxException
TransactionalMapperrollback in class TransactionalMapperMailboxExceptionTransactionalMapper.rollback()public void endRequest()
EntityManagerendRequest in interface Mapperpublic Iterator<Message<Long>> findInMailbox(Mailbox<Long> mailbox, MessageRange set, MessageMapper.FetchType fType, int max) throws MailboxException
MessageMapperIterator which holds the messages for the given criterias
The list must be ordered by the Message uidfindInMailbox in interface MessageMapper<Long>mailbox - The mailbox to searchset - message range for batch processingmax - the maximal limit of returned Message's. Use -1 to set no limit. In any case the caller MUST not expect the limit to get applied in all cases as the implementation
MAY just ignore itMailboxExceptionMessageMapper.findInMailbox(org.apache.james.mailbox.store.mail.model.Mailbox, org.apache.james.mailbox.model.MessageRange, org.apache.james.mailbox.store.mail.MessageMapper.FetchType, int)public long countMessagesInMailbox(Mailbox<Long> mailbox) throws MailboxException
MessageMappercountMessagesInMailbox in interface MessageMapper<Long>MailboxExceptionMessageMapper.countMessagesInMailbox(Mailbox)public long countUnseenMessagesInMailbox(Mailbox<Long> mailbox) throws MailboxException
MessageMappercountUnseenMessagesInMailbox in interface MessageMapper<Long>MailboxExceptionMessageMapper.countUnseenMessagesInMailbox(Mailbox)public void delete(Mailbox<Long> mailbox, Message<Long> message) throws MailboxException
MessageMapperMessagedelete in interface MessageMapper<Long>MailboxExceptionMessageMapper.delete(org.apache.james.mailbox.store.mail.model.Mailbox, org.apache.james.mailbox.store.mail.model.Message)public Long findFirstUnseenMessageUid(Mailbox<Long> mailbox) throws MailboxException
MessageMapperfindFirstUnseenMessageUid in interface MessageMapper<Long>MailboxExceptionMessageMapper.findFirstUnseenMessageUid(Mailbox)public List<Long> findRecentMessageUidsInMailbox(Mailbox<Long> mailbox) throws MailboxException
MessageMapperfindRecentMessageUidsInMailbox in interface MessageMapper<Long>MailboxExceptionMessageMapper.findRecentMessageUidsInMailbox(Mailbox)protected MessageMetaData copy(Mailbox<Long> mailbox, long uid, long modSeq, Message<Long> original) throws MailboxException
AbstractMessageMappercopy in class AbstractMessageMapper<Long>MailboxExceptionAbstractMessageMapper.copy(Mailbox, long, long, Message)protected MessageMetaData save(Mailbox<Long> mailbox, Message<Long> message) throws MailboxException
AbstractMessageMappersave in class AbstractMessageMapper<Long>MailboxExceptionAbstractMessageMapper.save(Mailbox, Message)public Map<Long,MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox<Long> mailbox, MessageRange set) throws MailboxException
MessageMapperIterator which holds the uids for all deleted Messages for the given MessageRange which are marked for deletion
The list must be orderedexpungeMarkedForDeletionInMailbox in interface MessageMapper<Long>MailboxExceptionCopyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.