Package org.waveprotocol.wave.federation

Examples of org.waveprotocol.wave.federation.WaveletFederationListener$Factory


   * Listener for notifications coming from the Federation Remote. For now we accept updates
   * for wavelets on any domain.
   */
  @Override
  public WaveletFederationListener listenerForDomain(final String domain) {
    return new WaveletFederationListener() {
      @Override
      public void waveletDeltaUpdate(final WaveletName waveletName,
          List<ByteString> deltas, final WaveletUpdateCallback callback) {
        Preconditions.checkArgument(!deltas.isEmpty());

View Full Code Here


        callback.onFailure(FederationErrors.badRequest(
            "Couldn't decode wavelet name: " + waveletUpdate.attributeValue("wavelet-name")));
        continue;
      }

      WaveletFederationListener listener =
          updatesListenerFactory.listenerForDomain(waveletName.waveletId.getDomain());

      // Submit all applied deltas to the domain-focused listener.
      ImmutableList.Builder<ByteString> builder = ImmutableList.builder();
      for (Element appliedDeltaElement :
          XmppUtil.toSafeElementList(waveletUpdate.elements("applied-delta"))) {
        builder.add(Base64Util.decode(appliedDeltaElement.getText()));
      }
      ImmutableList<ByteString> deltas = builder.build();
      if (!deltas.isEmpty()) {
        callbackCount.incrementAndGet(); // Increment required callbacks.
        listener.waveletDeltaUpdate(waveletName, deltas, callback);
      }

      // Optionally submit any received last committed notice.
      Element commitNoticeElement = waveletUpdate.element("commit-notice");
      if (commitNoticeElement != null) {
        ProtocolHashedVersion version = ProtocolHashedVersion.newBuilder()
            .setHistoryHash(Base64Util.decode(commitNoticeElement.attributeValue("history-hash")))
            .setVersion(Long.parseLong(commitNoticeElement.attributeValue("version"))).build();
        callbackCount.incrementAndGet(); // Increment required callbacks.
        listener.waveletCommitUpdate(waveletName, version, callback);
      }
    }

    // Release sentinel so that 'expected' callbacks from the WS don't invoke
    // sending a receipt.
View Full Code Here

*/
public class NoOpFederationHost implements WaveletFederationListener.Factory {

  @Override
  public WaveletFederationListener listenerForDomain(String domain) {
    return new WaveletFederationListener() {
      @Override
      public void waveletDeltaUpdate(WaveletName waveletName, List<ByteString> deltas,
          WaveletUpdateCallback callback) {
        callback.onFailure(FederationErrors.badRequest("Federation is not enabled!"));
      }
View Full Code Here

*/
public class NoOpFederationHost implements WaveletFederationListener.Factory {

  @Override
  public WaveletFederationListener listenerForDomain(String domain) {
    return new WaveletFederationListener() {
      @Override
      public void waveletDeltaUpdate(WaveletName waveletName, List<ByteString> deltas,
          WaveletUpdateCallback callback) {
        callback.onFailure(FederationErrors.badRequest("Federation is not enabled!"));
      }
View Full Code Here

        callback.onFailure(FederationErrors.badRequest(
            "Couldn't decode wavelet name: " + waveletUpdate.attributeValue("wavelet-name")));
        continue;
      }

      WaveletFederationListener listener =
          updatesListenerFactory.listenerForDomain(waveletName.waveletId.getDomain());

      // Submit all applied deltas to the domain-focused listener.
      ImmutableList.Builder<ByteString> builder = ImmutableList.builder();
      for (Element appliedDeltaElement :
          XmppUtil.toSafeElementList(waveletUpdate.elements("applied-delta"))) {
        builder.add(Base64Util.decode(appliedDeltaElement.getText()));
      }
      ImmutableList<ByteString> deltas = builder.build();
      if (!deltas.isEmpty()) {
        callbackCount.incrementAndGet(); // Increment required callbacks.
        listener.waveletDeltaUpdate(waveletName, deltas, callback);
      }

      // Optionally submit any received last committed notice.
      Element commitNoticeElement = waveletUpdate.element("commit-notice");
      if (commitNoticeElement != null) {
        ProtocolHashedVersion version = ProtocolHashedVersion.newBuilder()
            .setHistoryHash(Base64Util.decode(commitNoticeElement.attributeValue("history-hash")))
            .setVersion(Long.parseLong(commitNoticeElement.attributeValue("version"))).build();
        callbackCount.incrementAndGet(); // Increment required callbacks.
        listener.waveletCommitUpdate(waveletName, version, callback);
      }
    }

    // Release sentinel so that 'expected' callbacks from the WS don't invoke
    // sending a receipt.
View Full Code Here

   * Listener for notifications coming from the Federation Remote. For now we accept updates
   * for wavelets on any domain.
   */
  @Override
  public WaveletFederationListener listenerForDomain(final String domain) {
    return new WaveletFederationListener() {
      @Override
      public void waveletDeltaUpdate(final WaveletName waveletName,
          List<ByteString> deltas, final WaveletUpdateCallback callback) {
        Preconditions.checkArgument(!deltas.isEmpty());

View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.federation.WaveletFederationListener$Factory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.