/** * This is an ugly work-around the lack of ability to add channels to a view * in the view service API. We need to send some message through the stacklet * so it's connected but the server can't send us any message until we submit * the first delta, which requires a connected stacklet... */ private void initialiseLocallyCreatedStacklet(final Stacklet stacklet, final WaveletId waveletId, final ObservableWaveletData snapshot, final HashedVersion committedVersion, final HashedVersion currentVersion) throws ChannelException { if (state == State.CONNECTED) { try { stacklet.onWaveletSnapshot(snapshot, committedVersion, currentVersion); } catch (ChannelException e) { throw exceptionWithContext(e, waveletId); } } else { // Delay connecting the stacklet until the underlying view is connected. onConnected.add(new Runnable() { public void run() { try { stacklet.onWaveletSnapshot(snapshot, committedVersion, currentVersion); } catch (ChannelException e) { shutdown("Fake snapshot for wavelet channel " + waveId + "/" + waveletId + "failed", exceptionWithContext(e, waveletId)); } } }); } }