当前位置: 首页>>代码示例>>Java>>正文


Java Flow.Subscriber方法代码示例

本文整理汇总了Java中java.util.concurrent.Flow.Subscriber方法的典型用法代码示例。如果您正苦于以下问题:Java Flow.Subscriber方法的具体用法?Java Flow.Subscriber怎么用?Java Flow.Subscriber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.Flow的用法示例。


在下文中一共展示了Flow.Subscriber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: subscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public synchronized void subscribe(Flow.Subscriber<? super ByteBuffer> subscriber) {

    InputStream is = streamSupplier.get();
    if (is == null) {
        throw new UncheckedIOException(new IOException("no inputstream supplied"));
    }
    this.delegate = new PullPublisher<>(() -> new StreamIterator(is));
    delegate.subscribe(subscriber);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:RequestProcessors.java

示例2: testErredJson

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Test
public void testErredJson() {

  jsonConverter = new JsonConverter();
  Flow.Subscription subscription = Mockito.mock(Flow.Subscription.class);
  jsonConverter.onSubscribe(subscription);
  Flow.Subscriber subscriber = Mockito.mock(Flow.Subscriber.class);
  jsonConverter.subscribe(subscriber);
  jsonConverter.onNext("{]".getBytes());

  Mockito.verify(subscriber).onError(Mockito.any(IllegalArgumentException.class));
  Mockito.verify(subscription).cancel();
}
 
开发者ID:openknowledge,项目名称:reactive-jax-rs,代码行数:14,代码来源:JsonConverterTest.java

示例3: testOnErrorShouldDontFireCompletion

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Test
public void testOnErrorShouldDontFireCompletion() {

  Flow.Subscriber subscriber = Mockito.mock(Flow.Subscriber.class);
  jsonConverter.subscribe(subscriber);
  jsonConverter.onComplete();
  jsonConverter.onError(new Exception());
  jsonConverter.onNext("{}".getBytes());

  Mockito.verify(subscriber).onError(Mockito.any(Exception.class));
  Mockito.verify(subscriber, Mockito.times(0)).onComplete();
}
 
开发者ID:openknowledge,项目名称:reactive-jax-rs,代码行数:13,代码来源:JsonConverterTest.java

示例4: testFireErrorIfParsingComplete

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Test
public void testFireErrorIfParsingComplete() {

  Flow.Subscriber subscriber = Mockito.mock(Flow.Subscriber.class);
  jsonConverter.subscribe(subscriber);
  jsonConverter.onNext("{}{}".getBytes());

  Mockito.verify(subscriber).onError(Mockito.any(IllegalArgumentException.class));
}
 
开发者ID:openknowledge,项目名称:reactive-jax-rs,代码行数:10,代码来源:JsonConverterTest.java

示例5: StreamSubscription

import java.util.concurrent.Flow; //导入方法依赖的package包/类
StreamSubscription(Flow.Subscriber<? super T> subscriber) {
    this.subscriber = subscriber;
    Iterator<? extends T> iterator = null;

    try {
        iterator = streamSupplier.get().iterator();
    } catch (Throwable e) {
        error.set(e);
    }

    this.iterator = iterator;
}
 
开发者ID:OlegDokuka,项目名称:reactive-streams-tck_playground,代码行数:13,代码来源:StreamPublisher.java

示例6: subscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void subscribe(Flow.Subscriber<? super T> flow) {
    if (flow == null) {
        reactiveStreams.subscribe(null);
        return;
    }
    reactiveStreams.subscribe(new ReactiveToFlowSubscriber<T>(flow));
}
 
开发者ID:OlegDokuka,项目名称:reactive-streams-tck_playground,代码行数:9,代码来源:ReactiveStreamsFlowBridge.java

示例7: onNext

import java.util.concurrent.Flow; //导入方法依赖的package包/类
public static <T> void onNext(Flow.Subscriber<T> actual, Object target, VarHandle WIP, VarHandle ERRORS, T item) {
    if ((int)WIP.getAcquire(target) == 0 && WIP.compareAndSet(target, 0, 1)) {
        actual.onNext(item);
        if (!WIP.compareAndSet(target, 1, 0)) {
            Throwable ex = ExceptionHelper.terminate(target, ERRORS);
            if (ex == null) {
                actual.onComplete();
            } else {
                actual.onError(ex);
            }
        }
    }
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:14,代码来源:HalfSerializer.java

示例8: subscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void subscribe(Flow.Subscriber<? super T> subscriber) {
    try {
        subscriber.onSubscribe(new Subscription(subscriber));
    } catch (RejectedExecutionException e) {
        subscriber.onError(new IllegalStateException(e));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:DefaultPublisher.java

示例9: Subscription

import java.util.concurrent.Flow; //导入方法依赖的package包/类
public Subscription(Flow.Subscriber subscriber,
                    ExecutorService executor) {
    this.subscriber = subscriber;
    this.executor = executor;
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Cookbook,代码行数:6,代码来源:Subscription.java

示例10: subscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void subscribe(Flow.Subscriber<? super String> subscriber) {

  this.subscriber = subscriber;
}
 
开发者ID:openknowledge,项目名称:reactive-jax-rs,代码行数:6,代码来源:JsonConverter.java

示例11: subscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void subscribe(Flow.Subscriber<? super T> subscriber) {
    subscription = new Subscription(subscriber);
    subscriber.onSubscribe(subscription);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:PushPublisher.java

示例12: subscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void subscribe(Flow.Subscriber<? super T> subscriber) {
    subscriber.onSubscribe(new Subscription(subscriber));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:PseudoPublisher.java

示例13: Subscription

import java.util.concurrent.Flow; //导入方法依赖的package包/类
Subscription(Flow.Subscriber<? super T> subscriber) {
    this.subscriber = subscriber;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:PseudoPublisher.java

示例14: subscribe

import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void subscribe(Flow.Subscriber<? super ByteBuffer> subscriber) {
    delegate.subscribe(subscriber);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:ShortRequestBody.java

示例15: StrictSubscriber

import java.util.concurrent.Flow; //导入方法依赖的package包/类
public StrictSubscriber(Flow.Subscriber<? super T> actual) {
    this.actual = actual;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:4,代码来源:StrictSubscriber.java


注:本文中的java.util.concurrent.Flow.Subscriber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。