private void addContext ( final EvaluatorRuntimeProtocol . AddContextProto addContextProto ) throws ContextClientCodeException { synchronized ( this . contextStack ) { try { final ContextRuntime currentTopContext = this . contextStack . peek ( ) ; if ( ! currentTopContext . getIdentifier ( ) . equals ( addContextProto . getParentContextId ( ) ) ) { throw new IllegalStateException ( "Trying to instantiate a child context on context with id `" + addContextProto . getParentContextId ( ) + "` while the current top context id is `" + currentTopContext . getIdentifier ( ) + "`" ) ; } final Configuration contextConfiguration = this . configurationSerializer . fromString ( addContextProto . getContextConfiguration ( ) ) ; final ContextRuntime newTopContext ; if ( addContextProto . hasServiceConfiguration ( ) ) { newTopContext = currentTopContext . spawnChildContext ( contextConfiguration , this . configurationSerializer . fromString ( addContextProto . getServiceConfiguration ( ) ) ) ; } else { newTopContext = currentTopContext . spawnChildContext ( contextConfiguration ) ; } this . contextStack . push ( newTopContext ) ; } catch ( final IOException | BindException e ) { throw new RuntimeException ( "Unable to read configuration." , e ) ; } } }
Add a context to the stack .