public class JPAMessageMapper extends AbstractMessageMapper<Long> implements MessageMapper<Long>
MessageMapper
. This class is not thread-safe!MessageMapper.FetchType
Mapper.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, updateFlags
execute
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
add, copy, getHighestModSeq, getLastUid, updateFlags
protected 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
TransactionalMapper
begin
in class TransactionalMapper
MailboxException
TransactionalMapper.begin()
protected void commit() throws MailboxException
commit
in class TransactionalMapper
MailboxException
protected void rollback() throws MailboxException
TransactionalMapper
rollback
in class TransactionalMapper
MailboxException
TransactionalMapper.rollback()
public void endRequest()
EntityManager
endRequest
in interface Mapper
public Iterator<Message<Long>> findInMailbox(Mailbox<Long> mailbox, MessageRange set, MessageMapper.FetchType fType, int max) throws MailboxException
MessageMapper
Iterator
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 itMailboxException
MessageMapper.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
MessageMapper
countMessagesInMailbox
in interface MessageMapper<Long>
MailboxException
MessageMapper.countMessagesInMailbox(Mailbox)
public long countUnseenMessagesInMailbox(Mailbox<Long> mailbox) throws MailboxException
MessageMapper
countUnseenMessagesInMailbox
in interface MessageMapper<Long>
MailboxException
MessageMapper.countUnseenMessagesInMailbox(Mailbox)
public void delete(Mailbox<Long> mailbox, Message<Long> message) throws MailboxException
MessageMapper
Message
delete
in interface MessageMapper<Long>
MailboxException
MessageMapper.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
MessageMapper
findFirstUnseenMessageUid
in interface MessageMapper<Long>
MailboxException
MessageMapper.findFirstUnseenMessageUid(Mailbox)
public List<Long> findRecentMessageUidsInMailbox(Mailbox<Long> mailbox) throws MailboxException
MessageMapper
findRecentMessageUidsInMailbox
in interface MessageMapper<Long>
MailboxException
MessageMapper.findRecentMessageUidsInMailbox(Mailbox)
protected MessageMetaData copy(Mailbox<Long> mailbox, long uid, long modSeq, Message<Long> original) throws MailboxException
AbstractMessageMapper
copy
in class AbstractMessageMapper<Long>
MailboxException
AbstractMessageMapper.copy(Mailbox, long, long, Message)
protected MessageMetaData save(Mailbox<Long> mailbox, Message<Long> message) throws MailboxException
AbstractMessageMapper
save
in class AbstractMessageMapper<Long>
MailboxException
AbstractMessageMapper.save(Mailbox, Message)
public Map<Long,MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox<Long> mailbox, MessageRange set) throws MailboxException
MessageMapper
Iterator
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>
MailboxException
Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.