当前位置: 首页>>代码示例>>Java>>正文


Java MessageCountEvent类代码示例

本文整理汇总了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);
}
 
开发者ID:camunda,项目名称:camunda-bpm-mail,代码行数:26,代码来源:MailNotificationService.java

示例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) {
		}
	}
}
 
开发者ID:SAP,项目名称:hana-native-adapters,代码行数:23,代码来源:IMAPAdapter.java

示例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();
		}
    }
}
 
开发者ID:Ardulink,项目名称:Ardulink-1,代码行数:17,代码来源:ArdulinkMailMessageCountAdapter.java

示例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();
		}
    }
}
 
开发者ID:Ardulink,项目名称:Ardulink-1,代码行数:15,代码来源:ArdulinkMailMessageCountListener.java

示例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++;
}
 
开发者ID:rektide,项目名称:javamaildir,代码行数:8,代码来源:SimpleCountListener.java

示例6: messagesAdded

import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
@Override
public void messagesAdded(final MessageCountEvent e) {
    addedCount++;

}
 
开发者ID:salyh,项目名称:javamail-mock2,代码行数:6,代码来源:Main.java

示例7: messagesRemoved

import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
@Override
public void messagesRemoved(final MessageCountEvent e) {
    removedCount++;

}
 
开发者ID:salyh,项目名称:javamail-mock2,代码行数:6,代码来源:Main.java

示例8: messagesRemoved

import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public void messagesRemoved(MessageCountEvent e) {
    lastReceivedEvent = e;
    removedMessageEvents++;
}
 
开发者ID:rektide,项目名称:javamaildir,代码行数:5,代码来源:SimpleCountListener.java

示例9: getLastReceivedEvent

import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public MessageCountEvent getLastReceivedEvent() {
    return lastReceivedEvent;
}
 
开发者ID:rektide,项目名称:javamaildir,代码行数:4,代码来源:SimpleCountListener.java

示例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);
}
 
开发者ID:rektide,项目名称:javamaildir,代码行数:53,代码来源:MaildirFolderTestCase.java

示例11: messagesAdded

import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public void messagesAdded(MessageCountEvent e) {
	
}
 
开发者ID:babymm,项目名称:mumu,代码行数:4,代码来源:EmailMessageCountListener.java

示例12: messagesRemoved

import javax.mail.event.MessageCountEvent; //导入依赖的package包/类
public void messagesRemoved(MessageCountEvent e) {
	
}
 
开发者ID:babymm,项目名称:mumu,代码行数:4,代码来源:EmailMessageCountListener.java


注:本文中的javax.mail.event.MessageCountEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。