@Test public void getUserIdentifierShouldReturnTcpEndpointFromHttpAddress() throws Exception { ResourceAddressFactory addressFactory = ResourceAddressFactory.newResourceAddressFactory(); String addressURI = "http: final ResourceAddress address = addressFactory.newResourceAddress(addressURI); final IoServiceEx service = context.mock(IoServiceEx.class, "service"); final Subject subject = new Subject(); context.checking(new Expectations() { { oneOf(sessionEx).getService(); will(returnValue(service)); oneOf(sessionEx).getLocalAddress(); will(returnValue(address)); oneOf(sessionEx).getSubject(); will(returnValue(subject)); oneOf(sessionEx).getRemoteAddress(); will(returnValue(address)); } }); assertEquals("127.0.0.1:2121", LoggingUtils.getUserIdentifier(sessionEx)); }
static String getUserIdentifier(IoSession session) { boolean isAcceptor = isAcceptor(session); SocketAddress hostPortAddress = isAcceptor ? session.getRemoteAddress() : session.getLocalAddress(); SocketAddress identityAddress = isAcceptor ? session.getLocalAddress() : session.getRemoteAddress(); String identity = resolveIdentity(identityAddress, (IoSessionEx)session); String hostPort = getHostPort(hostPortAddress); return identity == null ? hostPort : format("%s %s", identity, hostPort); }
LoggingUtils { static String getUserIdentifier(IoSession session) { boolean isAcceptor = isAcceptor(session); SocketAddress hostPortAddress = isAcceptor ? session.getRemoteAddress() : session.getLocalAddress(); SocketAddress identityAddress = isAcceptor ? session.getLocalAddress() : session.getRemoteAddress(); String identity = resolveIdentity(identityAddress, (IoSessionEx)session); String hostPort = getHostPort(hostPortAddress); return identity == null ? hostPort : format("%s %s", identity, hostPort); } }
LoggingUtils { static String getUserIdentifier(IoSession session) { boolean isAcceptor = isAcceptor(session); SocketAddress hostPortAddress = isAcceptor ? session.getRemoteAddress() : session.getLocalAddress(); SocketAddress identityAddress = isAcceptor ? session.getLocalAddress() : session.getRemoteAddress(); String identity = resolveIdentity(identityAddress, (IoSessionEx)session); String hostPort = getHostPort(hostPortAddress); return identity == null ? hostPort : format("%s %s", identity, hostPort); } private  LoggingUtils(); }
LoggingUtils { static String getUserIdentifier(IoSession session) { boolean isAcceptor = isAcceptor(session); SocketAddress hostPortAddress = isAcceptor ? session.getRemoteAddress() : session.getLocalAddress(); SocketAddress identityAddress = isAcceptor ? session.getLocalAddress() : session.getRemoteAddress(); String identity = resolveIdentity(identityAddress, (IoSessionEx)session); String hostPort = getHostPort(hostPortAddress); return identity == null ? hostPort : format("%s %s", identity, hostPort); } private  LoggingUtils(); static String addSession(String message, IoSession session); static String getId(IoSession session); static void log(IoSession session, Throwable t); static void log(IoSession session, Logger logger, Throwable t); static void log(IoSession session, Logger logger, String message, Throwable t); }
LoggingUtils { static String getUserIdentifier(IoSession session) { boolean isAcceptor = isAcceptor(session); SocketAddress hostPortAddress = isAcceptor ? session.getRemoteAddress() : session.getLocalAddress(); SocketAddress identityAddress = isAcceptor ? session.getLocalAddress() : session.getRemoteAddress(); String identity = resolveIdentity(identityAddress, (IoSessionEx)session); String hostPort = getHostPort(hostPortAddress); return identity == null ? hostPort : format("%s %s", identity, hostPort); } private  LoggingUtils(); static String addSession(String message, IoSession session); static String getId(IoSession session); static void log(IoSession session, Throwable t); static void log(IoSession session, Logger logger, Throwable t); static void log(IoSession session, Logger logger, String message, Throwable t); static final String NETWORK_CONNECTIVITY_ERROR_MESSAGE; static final String EARLY_TERMINATION_OF_IOSESSION_MESSAGE; }