當前位置: 首頁>>代碼示例>>Java>>正文


Java ConnectionEvent類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:gartcimore,項目名稱:javamail4ews,代碼行數:38,代碼來源:EwsFolder.java

示例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);
        }
    }
}
 
開發者ID:gartcimore,項目名稱:javamail4ews,代碼行數:23,代碼來源:EwsFolder.java

示例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));
}
 
開發者ID:m-szalik,項目名稱:javamail,代碼行數:11,代碼來源:AbstractTransportTest.java

示例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);
}
 
開發者ID:salyh,項目名稱:javamail-mock2,代碼行數:8,代碼來源:POP3MockStore.java

示例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);
}
 
開發者ID:salyh,項目名稱:javamail-mock2,代碼行數:15,代碼來源:POP3MockFolder.java

示例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);
}
 
開發者ID:salyh,項目名稱:javamail-mock2,代碼行數:8,代碼來源:POP3MockFolder.java

示例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);
}
 
開發者ID:salyh,項目名稱:javamail-mock2,代碼行數:15,代碼來源:IMAPMockFolder.java

示例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);
}
 
開發者ID:salyh,項目名稱:javamail-mock2,代碼行數:10,代碼來源:IMAPMockFolder.java

示例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);
}
 
開發者ID:salyh,項目名稱:javamail-mock2,代碼行數:12,代碼來源:MockTransport.java

示例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);
}
 
開發者ID:m-szalik,項目名稱:javamail,代碼行數:6,代碼來源:AbstractTransport.java

示例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);
}
 
開發者ID:m-szalik,項目名稱:javamail,代碼行數:7,代碼來源:AbstractTransport.java

示例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);
}
 
開發者ID:salyh,項目名稱:javamail-mock2,代碼行數:7,代碼來源:IMAPMockStore.java


注:本文中的javax.mail.event.ConnectionEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。