当前位置: 首页>>代码示例>>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;未经允许,请勿转载。