本文整理汇总了Java中javax.mail.event.MessageCountEvent类的典型用法代码示例。如果您正苦于以下问题:Java MessageCountEvent类的具体用法?Java MessageCountEvent怎么用?Java MessageCountEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageCountEvent类属于javax.mail.event包,在下文中一共展示了MessageCountEvent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public void start(String folderName) throws Exception {
executorService = Executors.newSingleThreadExecutor();
Folder folder = mailService.ensureOpenFolder(folderName);
folder.addMessageCountListener(new MessageCountAdapter() {
@Override
public void messagesAdded(MessageCountEvent event) {
List<Message> messages = Arrays.asList(event.getMessages());
handlers.forEach(handler -> handler.accept(messages));
}
});
if (supportsIdle(folder)) {
notificationWorker = new IdleNotificationWorker(mailService, (IMAPFolder) folder);
} else {
notificationWorker = new PollNotificationWorker(mailService, folder,
configuration.getNotificationLookupTime());
}
LOGGER.debug("start notification service: {}", notificationWorker);
executorService.submit(notificationWorker);
}
示例2: messagesAdded
import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public void messagesAdded(MessageCountEvent ev) {
Message[] msgs = ev.getMessages();
try {
for (int i = 0; i < msgs.length; i++) {
addCDCRow(INBOX, msgs[i], RowType.INSERT);
msgs[i].writeTo(System.out);
}
commit();
} catch (IOException | MessagingException | AdapterException e) {
e.printStackTrace();
try {
Subscriptions s = getSubscriptions();
SubscriptionInformationPerTablename sub = s.get("RSSFEED");
if (sub != null) {
for (SubscriptionRuntimeInformation rs : sub.getSubscriptionList().values()) {
stop(rs.getSubscriptionSpecification());
}
}
} catch (AdapterException e1) {
}
}
}
示例3: messagesAdded
import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public void messagesAdded(MessageCountEvent ev) {
Message[] msgs = ev.getMessages();
System.out.println("Got " + msgs.length + " new messages");
for (int i = 0; i < msgs.length; i++) {
try {
manageMessage(msgs[i]);
} catch (IOException ioex) {
ioex.printStackTrace();
} catch (MessagingException mex) {
mex.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例4: messagesAdded
import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public void messagesAdded(MessageCountEvent ev) {
Message[] msgs = ev.getMessages();
logger.info("Got {} new messages", msgs.length);
for (int i = 0; i < msgs.length; i++) {
try {
manageMessage(msgs[i]);
} catch (IOException ioex) {
ioex.printStackTrace();
} catch (MessagingException mex) {
mex.printStackTrace();
}
}
}
示例5: messagesAdded
import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public void messagesAdded(MessageCountEvent e) {
//log.debug("MessageCountEvent: "+e);
//log.debug("msgs: "+e.getMessages().length);
lastReceivedEvent = e;
addedMessageEvents++;
}
示例6: messagesAdded
import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
@Override
public void messagesAdded(final MessageCountEvent e) {
addedCount++;
}
示例7: messagesRemoved
import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
@Override
public void messagesRemoved(final MessageCountEvent e) {
removedCount++;
}
示例8: messagesRemoved
import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public void messagesRemoved(MessageCountEvent e) {
lastReceivedEvent = e;
removedMessageEvents++;
}
示例9: getLastReceivedEvent
import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public MessageCountEvent getLastReceivedEvent() {
return lastReceivedEvent;
}
示例10: testAppendMessages
import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public void testAppendMessages() throws Exception {
final Folder f1 = currentStore.getFolder("subone");
f1.open(Folder.READ_ONLY);
final SimpleCountListener listener = new SimpleCountListener();
f1.open(Folder.READ_WRITE);
f1.addMessageCountListener(listener);
final int origCount = f1.getMessageCount();
final int origUnread = f1.getUnreadMessageCount();
System.out.println("count: " + origCount);
System.out.println("unread: " + origUnread);
final MimeMessage mm = new MimeMessage((Session) null);
mm.setText("Test content.");
mm.setFrom(new InternetAddress("[email protected]"));
mm.setRecipients(Message.RecipientType.TO, "[email protected]");
final String subjectString = "test message.";
mm.setSubject(subjectString);
final MimeMessage duplicate = new MimeMessage(mm);
final Message[] messages = new Message[]{
mm, duplicate
};
f1.appendMessages(messages);
assertEquals(origCount + 2, f1.getMessageCount());
assertEquals(origUnread + 2, f1.getUnreadMessageCount());
// sleep just in case there are threading problems.
if (listener.getLastReceivedEvent() == null) {
try {
Thread.sleep(1000);
} catch (Exception e) {
}
}
final MessageCountEvent mce = listener.getLastReceivedEvent();
if (mce == null)
fail("appendMessages: no MessageCountEvent for listener.");
log.debug("mce.getMessages: " + mce.getMessages().length);
assertEquals(MessageCountEvent.ADDED, mce.getType());
assertEquals(2, mce.getMessages().length);
assertEquals(subjectString, mce.getMessages()[0].getSubject());
log.debug("--- done");
f1.close(false);
}
示例11: messagesAdded
import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public void messagesAdded(MessageCountEvent e) {
}
示例12: messagesRemoved
import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public void messagesRemoved(MessageCountEvent e) {
}