本文整理匯總了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);
}