protected void fillContext(final IoSession session, final Map<String, String> context) {
        if (mdcKeys.contains(MdcKey.handlerClass)) {
            context.put(MdcKey.handlerClass.name(), session.getHandler()
                    .getClass().getName());
        }
        if (mdcKeys.contains(MdcKey.remoteAddress)) {
            context.put(MdcKey.remoteAddress.name(), session.getRemoteAddress()
                    .toString());
        }
        if (mdcKeys.contains(MdcKey.localAddress)) {
            context.put(MdcKey.localAddress.name(), session.getLocalAddress()
                    .toString());
        }
        if (session.getTransportMetadata().getAddressType() == InetSocketAddress.class) {
            InetSocketAddress remoteAddress = (InetSocketAddress) session
                    .getRemoteAddress();
            InetSocketAddress localAddress = (InetSocketAddress) session
                    .getLocalAddress();
            if (mdcKeys.contains(MdcKey.remoteIp)) {
                context.put(MdcKey.remoteIp.name(), remoteAddress.getAddress()
                        .getHostAddress());
            }
            if (mdcKeys.contains(MdcKey.remotePort)) {
                context.put(MdcKey.remotePort.name(), String
                        .valueOf(remoteAddress.getPort()));
            }
            if (mdcKeys.contains(MdcKey.localIp)) {
                context.put(MdcKey.localIp.name(), localAddress.getAddress()
                        .getHostAddress());
            }
            if (mdcKeys.contains(MdcKey.localPort)) {
                context.put(MdcKey.localPort.name(), String
                        .valueOf(localAddress.getPort()));
            }
        }
    }
protected void fillContext ( final IoSession session , final Map < String , String > context ) { if ( mdcKeys . contains ( MdcKey . handlerClass ) ) { context . put ( MdcKey . handlerClass . name ( ) , session . getHandler ( ) . getClass ( ) . getName ( ) ) ; } if ( mdcKeys . contains ( MdcKey . remoteAddress ) ) { context . put ( MdcKey . remoteAddress . name ( ) , session . getRemoteAddress ( ) . toString ( ) ) ; } if ( mdcKeys . contains ( MdcKey . localAddress ) ) { context . put ( MdcKey . localAddress . name ( ) , session . getLocalAddress ( ) . toString ( ) ) ; } if ( session . getTransportMetadata ( ) . getAddressType ( ) == InetSocketAddress . class ) { InetSocketAddress remoteAddress = ( InetSocketAddress ) session . getRemoteAddress ( ) ; InetSocketAddress localAddress = ( InetSocketAddress ) session . getLocalAddress ( ) ; if ( mdcKeys . contains ( MdcKey . remoteIp ) ) { context . put ( MdcKey . remoteIp . name ( ) , remoteAddress . getAddress ( ) . getHostAddress ( ) ) ; } if ( mdcKeys . contains ( MdcKey . remotePort ) ) { context . put ( MdcKey . remotePort . name ( ) , String . valueOf ( remoteAddress . getPort ( ) ) ) ; } if ( mdcKeys . contains ( MdcKey . localIp ) ) { context . put ( MdcKey . localIp . name ( ) , localAddress . getAddress ( ) . getHostAddress ( ) ) ; } if ( mdcKeys . contains ( MdcKey . localPort ) ) { context . put ( MdcKey . localPort . name ( ) , String . valueOf ( localAddress . getPort ( ) ) ) ; } } }
write key properties of the session to the Mapped Diagnostic Context
sub-classes could override this method to map more/other attributes
@param session the session to map
@param context key properties will be added to this map