当前位置: 首页>>代码示例>>Java>>正文


Java IoSession.getService方法代码示例

本文整理汇总了Java中org.apache.mina.core.session.IoSession.getService方法的典型用法代码示例。如果您正苦于以下问题:Java IoSession.getService方法的具体用法?Java IoSession.getService怎么用?Java IoSession.getService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mina.core.session.IoSession的用法示例。


在下文中一共展示了IoSession.getService方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: StringBuilder

import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
/**
 * An extended toString() method for sessions. If the SSL handshake
 * is not yet completed, we will print (ssl) in small caps. Once it's
 * completed, we will use SSL capitalized.
 */
/* no qualifier */String getSessionInfo(IoSession session) {
    StringBuilder sb = new StringBuilder();

    if (session.getService() instanceof IoAcceptor) {
        sb.append("Session Server");

    } else {
        sb.append("Session Client");
    }

    sb.append('[').append(session.getId()).append(']');

    SslHandler handler = (SslHandler) session.getAttribute(SSL_HANDLER);

    if (handler == null) {
        sb.append("(no sslEngine)");
    } else if (isSslStarted(session)) {
        if (handler.isHandshakeComplete()) {
            sb.append("(SSL)");
        } else {
            sb.append("(ssl...)");
        }
    }

    return sb.toString();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:32,代码来源:SslFilter.java

示例2: fireSessionDestroyed

import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
/**
 * Calls {@link IoServiceListener#sessionDestroyed(IoSession)} for all registered listeners.
 * 
 * @param session The session which has been destroyed
 */
public void fireSessionDestroyed(IoSession session) {
    // Try to remove the remaining empty session set after removal.
    if (managedSessions.remove(session.getId()) == null) {
        return;
    }

    // Fire session events.
    session.getFilterChain().fireSessionClosed();

    // Fire listener events.
    try {
        for (IoServiceListener l : listeners) {
            try {
                l.sessionDestroyed(session);
            } catch (Throwable e) {
                ExceptionMonitor.getInstance().exceptionCaught(e);
            }
        }
    } finally {
        // Fire a virtual service deactivation event for the last session of the connector.
        if (session.getService() instanceof IoConnector) {
            boolean lastSession = false;

            synchronized (managedSessions) {
                lastSession = managedSessions.isEmpty();
            }

            if (lastSession) {
                fireServiceDeactivated();
            }
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:39,代码来源:IoServiceListenerSupport.java

示例3: fireSessionCreated

import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
/**
 * Calls {@link IoServiceListener#sessionCreated(IoSession)} for all registered listeners.
 * 
 * @param session The session which has been created
 */
public void fireSessionCreated(IoSession session) {
    boolean firstSession = false;

    if (session.getService() instanceof IoConnector) {
        synchronized (managedSessions) {
            firstSession = managedSessions.isEmpty();
        }
    }

    // If already registered, ignore.
    if (managedSessions.putIfAbsent(session.getId(), session) != null) {
        return;
    }

    // If the first connector session, fire a virtual service activation event.
    if (firstSession) {
        fireServiceActivated();
    }

    // Fire session events.
    IoFilterChain filterChain = session.getFilterChain();
    filterChain.fireSessionCreated();
    filterChain.fireSessionOpened();

    int managedSessionCount = managedSessions.size();

    if (managedSessionCount > largestManagedSessionCount) {
        largestManagedSessionCount = managedSessionCount;
    }

    cumulativeManagedSessionCount++;

    // Fire listener events.
    for (IoServiceListener l : listeners) {
        try {
            l.sessionCreated(session);
        } catch (Throwable e) {
            ExceptionMonitor.getInstance().exceptionCaught(e);
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:47,代码来源:IoServiceListenerSupport.java


注:本文中的org.apache.mina.core.session.IoSession.getService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。