private void createActiveNetwork ( final NetworkContext context , final Handler < AsyncResult < ActiveNetwork > > doneHandler ) { final DefaultActiveNetwork active = new DefaultActiveNetwork ( context . config ( ) , DefaultCluster . this ) ; vertx . eventBus ( ) . registerHandler ( String . format ( "%s.%s.change" , context . name ( ) , context . name ( ) ) , new Handler < Message < JsonObject > > ( ) { @ Override public void handle ( Message < JsonObject > message ) { String event = message . body ( ) . getString ( "type" ) ; if ( event . equals ( "change" ) && message . body ( ) . getString ( "value" ) != null ) { active . update ( Contexts . < NetworkContext > deserialize ( new JsonObject ( message . body ( ) . getString ( "value" ) ) ) ) ; } } } , new Handler < AsyncResult < Void > > ( ) { @ Override public void handle ( AsyncResult < Void > result ) { if ( result . failed ( ) ) { new DefaultFutureResult < ActiveNetwork > ( new ClusterException ( result . cause ( ) ) ) . setHandler ( doneHandler ) ; } else { new DefaultFutureResult < ActiveNetwork > ( active ) . setHandler ( doneHandler ) ; } } } ) ; }
Creates and returns an active network .