LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, false );
LdapContext ctx = ( LdapContext ) SessionRegistry.getSingleton().getLdapContext( session, null, false );
    public void messageReceived( IoSession session, Object request )    {        SessionRegistry registry = SessionRegistry.getSingleton();        try        {            LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, false );            if ( ctx != null )            {                ctx.close();            }            registry.terminateSession( session );            registry.remove( session );        }        catch ( NamingException e )        {            log.error( "failed to unbind session properly", e );        }    }