public Yoke deploy ( final @ NotNull JsonArray config , final Handler < Object > handler ) { if ( config . size ( ) == 0 ) { if ( handler == null ) { return this ; } else { handler . handle ( null ) ; return this ; } } // wait for all deployments before calling the real handler Handler < AsyncResult < String > > waitFor = new Handler < AsyncResult < String > > ( ) { private int latch = config . size ( ) ; private boolean handled = false ; @ Override public void handle ( AsyncResult < String > event ) { latch -- ; if ( handler != null ) { if ( ! handled && ( event . failed ( ) || latch == 0 ) ) { handled = true ; handler . handle ( event . failed ( ) ? event . cause ( ) : null ) ; } } } } ; for ( Object o : config ) { JsonObject json = ( JsonObject ) o ; vertx . deployVerticle ( json . getString ( "verticle" ) , new DeploymentOptions ( json ) , waitFor ) ; } return this ; }
Deploys required middleware from a config json element . The handler is only called once all middleware is deployed or in error . The order of deployment is not guaranteed since all deploy functions are called concurrently and do not wait for the previous result before deploying the next item .