本文整理汇总了Java中javax.mail.event.ConnectionEvent类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionEvent类的具体用法?Java ConnectionEvent怎么用?Java ConnectionEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionEvent类属于javax.mail.event包,在下文中一共展示了ConnectionEvent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import javax.mail.event.ConnectionEvent; //导入依赖的package包/类
@Override
public void open(int mode) throws MessagingException {
this.mode = mode;
try {
if (!exists()) {
throw new FolderNotFoundException();
}
ItemView view = new ItemView(ITEM_VIEW_MAX_ITEMS);
folder = Folder.bind(getService(), folder.getId());
if (prefetchItems) {
FindItemsResults<Item> lFindResults = getService().findItems(folder.getId(), view);
messages = new ArrayList<>(lFindResults.getTotalCount());
unreadMessages = new ArrayList<>();
for (Item aItem : lFindResults) {
if (aItem instanceof EmailMessage) {
logger.info("Fetching content of item {}", aItem.getId());
EmailMessage aEmailMessage = (EmailMessage) aItem;
EwsMailConverter aConverter = new EwsMailConverter(this, aEmailMessage, messages.size() + 1);
messages.add(aConverter.convert());
} else {
logger.warn("Skipping item {} as it is a {}", aItem.getId(), aItem.getClass());
}
}
} else {
}
timestamp = new Date();
getStore().notifyConnectionListeners(ConnectionEvent.OPENED);
} catch (Exception e) {
throw new MessagingException(e.getMessage(), e);
}
}
示例2: close
import javax.mail.event.ConnectionEvent; //导入依赖的package包/类
@Override
public void close(boolean expunge) throws MessagingException {
if (mode == javax.mail.Folder.READ_WRITE) {
try {
if (expunge) {
expunge();
}
// Update the messages
markMessageRead(messages);
markMessageRead(unreadMessages);
// and the folder itself
folder.update();
} catch (Exception e) {
// Close anyway
throw new MessagingException(e.getMessage(), e);
} finally {
folder = null;
getStore().notifyConnectionListeners(ConnectionEvent.CLOSED);
}
}
}
示例3: testConnectClose
import javax.mail.event.ConnectionEvent; //导入依赖的package包/类
@Test
public void testConnectClose() throws Exception {
transport.connect();
waitForListeners();
verify(connectionListener, times(1)).opened(any(ConnectionEvent.class));
transport.close();
waitForListeners();
verify(connectionListener).disconnected(any(ConnectionEvent.class));
verify(connectionListener).closed(any(ConnectionEvent.class));
}
示例4: close
import javax.mail.event.ConnectionEvent; //导入依赖的package包/类
@Override
public synchronized void close() throws MessagingException {
connected = false;
mailbox = null;
notifyConnectionListeners(ConnectionEvent.CLOSED);
logger.debug("Closed " + objectId);
}
示例5: close
import javax.mail.event.ConnectionEvent; //导入依赖的package包/类
@Override
public synchronized void close(final boolean expunge) throws MessagingException {
checkOpened();
if (expunge) {
mailboxFolder.expunge();
}
opened = false;
logger.debug("Folder closed " + objectId);
notifyConnectionListeners(ConnectionEvent.CLOSED);
}
示例6: open
import javax.mail.event.ConnectionEvent; //导入依赖的package包/类
@Override
public synchronized void open(final int mode) throws MessagingException {
checkClosed();
opened = true;
logger.debug("Open " + objectId);
notifyConnectionListeners(ConnectionEvent.OPENED);
}
示例7: close
import javax.mail.event.ConnectionEvent; //导入依赖的package包/类
@Override
public synchronized void close(final boolean expunge) throws MessagingException {
abortIdle();
checkOpened();
checkExists();
if (expunge) {
expunge();
}
opened = false;
logger.debug("Folder " + getFullName() + " closed (" + objectId + ")");
notifyConnectionListeners(ConnectionEvent.CLOSED);
}
示例8: open
import javax.mail.event.ConnectionEvent; //导入依赖的package包/类
@Override
public void open(final int mode) throws MessagingException {
checkClosed();
checkExists();
opened = true;
openMode = mode;
logger.debug("Open folder " + getFullName() + " (" + objectId + ")");
notifyConnectionListeners(ConnectionEvent.OPENED);
}
示例9: connect
import javax.mail.event.ConnectionEvent; //导入依赖的package包/类
@Override
public void connect(final String host, final int port, final String user, final String password) throws MessagingException {
if (isConnected()) {
throw new IllegalStateException("already connected");
}
setConnected(true);
notifyConnectionListeners(ConnectionEvent.OPENED);
}
示例10: connect
import javax.mail.event.ConnectionEvent; //导入依赖的package包/类
@Override
public void connect(String host, int port, String user, String password) throws MessagingException {
// do nothing because we do not need to connect anywhere
notifyConnectionListeners(ConnectionEvent.OPENED);
}
示例11: close
import javax.mail.event.ConnectionEvent; //导入依赖的package包/类
@Override
public void close() throws MessagingException {
// do nothing, we didn't have to connect so we also do not have to disconnect.
notifyConnectionListeners(ConnectionEvent.DISCONNECTED);
notifyConnectionListeners(ConnectionEvent.CLOSED);
}
示例12: close
import javax.mail.event.ConnectionEvent; //导入依赖的package包/类
@Override
public synchronized void close() throws MessagingException {
this.connected = false;
notifyConnectionListeners(ConnectionEvent.CLOSED);
logger.debug("Closed " + objectId);
}