本文整理汇总了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();
}
示例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();
}
}
}
}
示例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);
}
}
}