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

The following examples show how to use org.eclipse.microprofile.reactive.streams.operators.spi.ReactiveStreamsEngine. 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
Source File: ReactiveStreamsEngineResolver.java    From microprofile-reactive-streams-operators with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: ReactiveStreamsEngineResolver.java    From microprofile-reactive-streams-operators with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #3
Source File: ReactiveEngineProvider.java    From smallrye-reactive-streams-operators with Apache License 2.0 5 votes vote down vote up
/**
 * @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 #4
Source File: SmallRyeReactiveStreamsOperatorsProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@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 #5
Source File: MutinyReactiveStreamsOperatorsProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@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 #6
Source File: ReactiveStreamsSpiVerification.java    From microprofile-reactive-streams-operators with Apache License 2.0 5 votes vote down vote up
public ReactiveStreamsSpiVerification(TestEnvironment testEnvironment, ReactiveStreamsFactory rs,
    ReactiveStreamsEngine engine, ScheduledExecutorService executorService) {
    this.testEnvironment = testEnvironment;
    this.rs = rs;
    this.engine = engine;
    this.executorService = executorService;
}
 
Example #7
Source File: ReactiveStreamsSpiVerification.java    From microprofile-reactive-streams-operators with Apache License 2.0 4 votes vote down vote up
ReactiveStreamsEngine engine() {
    return engine;
}
 
Example #8
Source File: ReactiveStreamsCdiTck.java    From microprofile-reactive-streams-operators with Apache License 2.0 4 votes vote down vote up
@Override
protected ReactiveStreamsEngine createEngine() {
    return engine;
}
 
Example #9
Source File: AbstractStageVerification.java    From microprofile-reactive-streams-operators with Apache License 2.0 4 votes vote down vote up
ReactiveStreamsEngine getEngine() {
    return engine;
}
 
Example #10
Source File: PublisherBuilderImpl.java    From microprofile-reactive-streams-operators with Apache License 2.0 4 votes vote down vote up
@Override
public Publisher<T> buildRs(ReactiveStreamsEngine engine) {
    Objects.requireNonNull(engine, "Engine must not be null");
    return engine.buildPublisher(toGraph());
}
 
Example #11
Source File: SubscriberBuilderImpl.java    From microprofile-reactive-streams-operators with Apache License 2.0 4 votes vote down vote up
@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
Source File: ProcessorBuilderImpl.java    From microprofile-reactive-streams-operators with Apache License 2.0 4 votes vote down vote up
@Override
public Processor<T, R> buildRs(ReactiveStreamsEngine engine) {
    Objects.requireNonNull(engine, "Engine must not be null");
    return engine.buildProcessor(toGraph());
}
 
Example #13
Source File: CompletionRunnerImpl.java    From microprofile-reactive-streams-operators with Apache License 2.0 4 votes vote down vote up
@Override
public CompletionStage<T> run(ReactiveStreamsEngine engine) {
    Objects.requireNonNull(engine, "Engine must not be null");
    return engine.buildCompletion(toGraph());
}
 
Example #14
Source File: SubscriberBuilder.java    From microprofile-reactive-streams-operators with Apache License 2.0 2 votes vote down vote up
/**
 * 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 #15
Source File: ReactiveStreamsEngineResolver.java    From microprofile-reactive-streams-operators with Apache License 2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #16
Source File: PublisherBuilder.java    From microprofile-reactive-streams-operators with Apache License 2.0 2 votes vote down vote up
/**
 * 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
Source File: ProcessorBuilder.java    From microprofile-reactive-streams-operators with Apache License 2.0 2 votes vote down vote up
/**
 * 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 #18
Source File: CompletionRunner.java    From microprofile-reactive-streams-operators with Apache License 2.0 2 votes vote down vote up
/**
 * 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);