All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vlingo.reactivestreams.StreamPublisher Maven / Gradle / Ivy

There is a newer version: 1.7.5
Show newest version
// Copyright © 2012-2020 VLINGO LABS. All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL
// was not distributed with this file, You can obtain
// one at https://mozilla.org/MPL/2.0/.

package io.vlingo.reactivestreams;

import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;

import io.vlingo.actors.Actor;
import io.vlingo.actors.Stoppable;
import io.vlingo.common.Scheduled;

public class StreamPublisher extends Actor implements Publisher, ControlledSubscription, Scheduled, Stoppable {
  private final StreamPublisherDelegate delegate;

  @SuppressWarnings("unchecked")
  public StreamPublisher(final Source source, final PublisherConfiguration configuration) {
    this.delegate = new StreamPublisherDelegate<>(source, configuration, selfAs(ControlledSubscription.class), scheduler(), selfAs(Scheduled.class), selfAs(Stoppable.class));
  }

  //===================================
  // Publisher
  //===================================

  @Override
  public void subscribe(final Subscriber subscriber) {
    if (subscriber != null) {
      delegate.subscribe(subscriber);
    }
  }

  //===================================
  // ControlledSubscription
  //===================================

  @Override
  public void cancel(final SubscriptionController controller) {
    delegate.cancel(controller);
  }

  @Override
  public void request(final SubscriptionController controller, final long maximum) {
    delegate.request(controller, maximum);
  }

  //===================================
  // Scheduled
  //===================================

  @Override
  public void intervalSignal(final Scheduled scheduled, final Void data) {
    delegate.processNext();
  }

  //===================================
  // Internal implementation
  //===================================

  @Override
  public void stop() {
    delegate.stop();

    super.stop();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy