Java Code Examples for org.eclipse.microprofile.reactive.streams.operators.spi.ReactiveStreamsEngine

The following examples show how to use org.eclipse.microprofile.reactive.streams.operators.spi.ReactiveStreamsEngine. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Creates a ReactiveStreamsFactory object
 * Only used internally from within {@link ReactiveStreams}
 *
 * @return ReactiveStreamsFactory an instance of ReactiveStreamsFactory
 */
public static ReactiveStreamsEngine instance() {
    if (instance == null) {
        synchronized (ReactiveStreamsEngineResolver.class) {
            if (instance != null) {
                return instance;
            }

            ClassLoader cl = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> Thread.currentThread().getContextClassLoader());
            if (cl == null) {
                cl = ReactiveStreamsEngine.class.getClassLoader();
            }

            ReactiveStreamsEngine newInstance = loadFromSpi(cl);

            if (newInstance == null) {
                throw new IllegalStateException(
                    "No ReactiveStreamsEngine implementation found!");
            }

            instance = newInstance;
        }
    }

    return instance;
}
 
Example 2
private static ReactiveStreamsEngine loadFromSpi(ClassLoader cl) {
    if (cl == null) {
        return null;
    }
    if (instance == null) {
        ServiceLoader<ReactiveStreamsEngine> sl = ServiceLoader.load(
            ReactiveStreamsEngine.class, cl);
        for (ReactiveStreamsEngine spi : sl) {
            if (instance != null) {
                throw new IllegalStateException(
                    "Multiple ReactiveStreamsEngine implementations found: "
                        + spi.getClass().getName() + " and "
                        + instance.getClass().getName());
            }
            else {
                instance = spi;
            }
        }
    }
    return instance;
}
 
Example 3
public ReactiveStreamsSpiVerification(TestEnvironment testEnvironment, ReactiveStreamsFactory rs,
    ReactiveStreamsEngine engine, ScheduledExecutorService executorService) {
    this.testEnvironment = testEnvironment;
    this.rs = rs;
    this.engine = engine;
    this.executorService = executorService;
}
 
Example 4
@BuildStep
public void build(BuildProducer<ServiceProviderBuildItem> serviceProvider) {
    serviceProvider
            .produce(new ServiceProviderBuildItem(ReactiveStreamsEngine.class.getName(), Engine.class.getName()));
    serviceProvider.produce(new ServiceProviderBuildItem(ReactiveStreamsFactory.class.getName(),
            ReactiveStreamsFactoryImpl.class.getName()));
}
 
Example 5
@BuildStep
public void build(BuildProducer<ServiceProviderBuildItem> serviceProvider,
        BuildProducer<FeatureBuildItem> feature) {
    feature.produce(new FeatureBuildItem(Feature.SMALLRYE_REACTIVE_STREAMS_OPERATORS));
    serviceProvider.produce(new ServiceProviderBuildItem(ReactiveStreamsEngine.class.getName(), Engine.class.getName()));
    serviceProvider.produce(new ServiceProviderBuildItem(ReactiveStreamsFactory.class.getName(),
            ReactiveStreamsFactoryImpl.class.getName()));
}
 
Example 6
/**
 * @return the reactive stream engine. It uses {@link ServiceLoader#load(Class)} to find an implementation from the
 *         Classpath.
 * @throws IllegalStateException if no implementations are found.
 */
@Produces
@ApplicationScoped
public ReactiveStreamsEngine getEngine() {
    Iterator<ReactiveStreamsEngine> iterator = ServiceLoader.load(ReactiveStreamsEngine.class).iterator();
    if (iterator.hasNext()) {
        return iterator.next();
    }
    throw new IllegalStateException("No implementation of the "
            + ReactiveStreamsEngine.class.getName() + " found in the Classpath");
}
 
Example 7
ReactiveStreamsEngine getEngine() {
    return engine;
}
 
Example 8
ReactiveStreamsEngine engine() {
    return engine;
}
 
Example 9
@Override
protected ReactiveStreamsEngine createEngine() {
    return engine;
}
 
Example 10
@Override
public Publisher<T> buildRs(ReactiveStreamsEngine engine) {
    Objects.requireNonNull(engine, "Engine must not be null");
    return engine.buildPublisher(toGraph());
}
 
Example 11
@Override
public CompletionSubscriber<T, R> build(ReactiveStreamsEngine engine) {
    Objects.requireNonNull(engine, "Engine must not be null");
    SubscriberWithCompletionStage<T, R> subscriberWithCompletionStage = engine.buildSubscriber(toGraph());
    return CompletionSubscriber.of(subscriberWithCompletionStage.getSubscriber(), subscriberWithCompletionStage.getCompletion());
}
 
Example 12
@Override
public Processor<T, R> buildRs(ReactiveStreamsEngine engine) {
    Objects.requireNonNull(engine, "Engine must not be null");
    return engine.buildProcessor(toGraph());
}
 
Example 13
@Override
public CompletionStage<T> run(ReactiveStreamsEngine engine) {
    Objects.requireNonNull(engine, "Engine must not be null");
    return engine.buildCompletion(toGraph());
}
 
Example 14
/**
 * Run this stream, using the supplied {@code ReactiveStreamsEngine}.
 *
 * @param engine The engine to run the stream with.
 * @return A completion stage that will be redeemed with the result of the stream, or an error if the stream fails.
 */
CompletionStage<T> run(ReactiveStreamsEngine engine);
 
Example 15
/**
 * Build this stream, using the supplied {@link ReactiveStreamsEngine}.
 *
 * @param engine The engine to run the stream with.
 * @return A {@link Processor} that will run this stream.
 */
Processor<T, R> buildRs(ReactiveStreamsEngine engine);
 
Example 16
/**
 * Build this stream, using the supplied {@link ReactiveStreamsEngine}.
 *
 * @param engine The engine to run the stream with.
 * @return A {@link Publisher} that will run this stream.
 */
Publisher<T> buildRs(ReactiveStreamsEngine engine);
 
Example 17
/**
 * Build this stream, using the supplied {@link ReactiveStreamsEngine}.
 *
 * @param engine The engine to run the stream with.
 * @return A {@link CompletionSubscriber} that will run this stream.
 */
CompletionSubscriber<T, R> build(ReactiveStreamsEngine engine);
 
Example 18
/**
 * Set the instance. It is used by OSGi environment while service loader
 * pattern is not supported.
 *
 * @param factory set the instance.
 */
public static void setInstance(ReactiveStreamsEngine factory) {
    instance = factory;
}