private void doCounterGet ( final Message < JsonObject > message ) { final String name = message . body ( ) . getString ( "name" ) ; if ( name == null ) { message . reply ( new JsonObject ( ) . putString ( "status" , "error" ) . putString ( "message" , "No name specified." ) ) ; return ; } context . execute ( new Action < Long > ( ) { @ Override public Long perform ( ) { Map < Object , Long > counters = data . getMap ( formatKey ( "counters" ) ) ; Long value = counters . get ( name ) ; if ( value == null ) { value = 0L ; } return value ; } } , new Handler < AsyncResult < Long > > ( ) { @ Override public void handle ( AsyncResult < Long > result ) { if ( result . failed ( ) ) { message . reply ( new JsonObject ( ) . putString ( "status" , "error" ) . putString ( "message" , result . cause ( ) . getMessage ( ) ) ) ; } else { message . reply ( new JsonObject ( ) . putString ( "status" , "ok" ) . putNumber ( "result" , result . result ( ) ) ) ; } } } ) ; }
Handles getting a counter .