Java 类javax.mail.event.ConnectionEvent 实例源码

项目:javamail4ews    文件:EwsFolder.java   
@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);
        }
    }
}
项目:javamail4ews    文件:EwsFolder.java   
@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);
    }
}
项目:javamail    文件:AbstractTransportTest.java   
@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));
}
项目:javamail-mock2    文件:POP3MockStore.java   
@Override
public synchronized void close() throws MessagingException {
    connected = false;
    mailbox = null;
    notifyConnectionListeners(ConnectionEvent.CLOSED);
    logger.debug("Closed " + objectId);
}
项目:javamail-mock2    文件:POP3MockFolder.java   
@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);
}
项目:javamail-mock2    文件:POP3MockFolder.java   
@Override
public synchronized void open(final int mode) throws MessagingException {
    checkClosed();
    opened = true;
    logger.debug("Open " + objectId);
    notifyConnectionListeners(ConnectionEvent.OPENED);
}
项目:javamail-mock2    文件:IMAPMockFolder.java   
@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);
}
项目:javamail-mock2    文件:IMAPMockFolder.java   
@Override
public void open(final int mode) throws MessagingException {
    checkClosed();
    checkExists();
    opened = true;
    openMode = mode;
    logger.debug("Open folder " + getFullName() + " (" + objectId + ")");
    notifyConnectionListeners(ConnectionEvent.OPENED);
}
项目:javamail-mock2    文件:MockTransport.java   
@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);
}
项目:javamail    文件:AbstractTransport.java   
@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);
}
项目:javamail    文件:AbstractTransport.java   
@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);
}
项目:javamail-mock2    文件:IMAPMockStore.java   
@Override
public synchronized void close() throws MessagingException {
    this.connected = false;
    notifyConnectionListeners(ConnectionEvent.CLOSED);
    logger.debug("Closed " + objectId);
}