Java Code Examples for org.eclipse.microprofile.reactive.streams.operators.spi.Graph#getStages()
The following examples show how to use
org.eclipse.microprofile.reactive.streams.operators.spi.Graph#getStages() .
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: Engine.java From smallrye-mutiny with Apache License 2.0 | 6 votes |
@Override public <T> Publisher<T> buildPublisher(Graph graph) { Multi<T> publisher = null; for (Stage stage : graph.getStages()) { Operator operator = Stages.lookup(stage); if (publisher == null) { if (operator instanceof PublisherOperator) { publisher = createPublisher(stage, (PublisherOperator) operator); } else { throw new IllegalArgumentException("Expecting a publisher stage, got a " + stage); } } else { if (operator instanceof ProcessorOperator) { publisher = applyProcessors(publisher, stage, (ProcessorOperator) operator); } else { throw new IllegalArgumentException("Expecting a processor stage, got a " + stage); } } } return publisher; }
Example 2
Source File: Engine.java From smallrye-mutiny with Apache License 2.0 | 6 votes |
@Override public <T, R> SubscriberWithCompletionStage<T, R> buildSubscriber(Graph graph) { Processor<T, T> processor = new ConnectableProcessor<>(); Multi<T> flowable = Multi.createFrom().publisher(processor); for (Stage stage : graph.getStages()) { Operator operator = Stages.lookup(stage); if (operator instanceof ProcessorOperator) { flowable = applyProcessors(flowable, stage, (ProcessorOperator) operator); } else if (operator instanceof TerminalOperator) { CompletionStage<R> result = applySubscriber(Transformer.apply(flowable), stage, (TerminalOperator) operator); return new DefaultSubscriberWithCompletionStage<>(processor, result); } else { throw new UnsupportedStageException(stage); } } throw new IllegalArgumentException("The graph does not have a valid final stage"); }
Example 3
Source File: Engine.java From smallrye-mutiny with Apache License 2.0 | 6 votes |
@Override public <T> CompletionStage<T> buildCompletion(Graph graph) { Multi<?> flowable = null; for (Stage stage : graph.getStages()) { Operator operator = Stages.lookup(stage); if (operator instanceof PublisherOperator) { flowable = createPublisher(stage, (PublisherOperator) operator); } else if (operator instanceof ProcessorOperator) { flowable = applyProcessors(flowable, stage, (ProcessorOperator) operator); } else { return applySubscriber(flowable, stage, (TerminalOperator) operator); } } throw new IllegalArgumentException("Graph did not have terminal stage"); }
Example 4
Source File: Engine.java From smallrye-reactive-streams-operators with Apache License 2.0 | 6 votes |
@Override public <T> Publisher<T> buildPublisher(Graph graph) { Flowable<T> flowable = null; for (Stage stage : graph.getStages()) { Operator operator = Stages.lookup(stage); if (flowable == null) { if (operator instanceof PublisherOperator) { flowable = createPublisher(stage, (PublisherOperator) operator); } else { throw new IllegalArgumentException("Expecting a publisher stage, got a " + stage); } } else { if (operator instanceof ProcessorOperator) { flowable = applyProcessors(flowable, stage, (ProcessorOperator) operator); } else { throw new IllegalArgumentException("Expecting a processor stage, got a " + stage); } } } return flowable; }
Example 5
Source File: Engine.java From smallrye-reactive-streams-operators with Apache License 2.0 | 6 votes |
@Override public <T, R> SubscriberWithCompletionStage<T, R> buildSubscriber(Graph graph) { Processor<T, T> processor = new ConnectableProcessor<>(); Flowable<T> flowable = Flowable.fromPublisher(processor); for (Stage stage : graph.getStages()) { Operator operator = Stages.lookup(stage); if (operator instanceof ProcessorOperator) { flowable = applyProcessors(flowable, stage, (ProcessorOperator) operator); } else if (operator instanceof TerminalOperator) { CompletionStage<R> result = applySubscriber(Transformer.apply(flowable), stage, (TerminalOperator) operator); return new DefaultSubscriberWithCompletionStage<>(processor, result); } else { throw new UnsupportedStageException(stage); } } throw new IllegalArgumentException("The graph does not have a valid final stage"); }
Example 6
Source File: Engine.java From smallrye-reactive-streams-operators with Apache License 2.0 | 6 votes |
@Override public <T> CompletionStage<T> buildCompletion(Graph graph) { Flowable<?> flowable = null; for (Stage stage : graph.getStages()) { Operator operator = Stages.lookup(stage); if (operator instanceof PublisherOperator) { flowable = createPublisher(stage, (PublisherOperator) operator); } else if (operator instanceof ProcessorOperator) { flowable = applyProcessors(flowable, stage, (ProcessorOperator) operator); } else { return applySubscriber(flowable, stage, (TerminalOperator) operator); } } throw new IllegalArgumentException("Graph did not have terminal stage"); }
Example 7
Source File: Engine.java From smallrye-mutiny with Apache License 2.0 | 5 votes |
@Override public <T, R> Processor<T, R> buildProcessor(Graph graph) { Processor<T, T> processor = new ConnectableProcessor<>(); Multi<T> multi = Multi.createFrom().publisher(processor); for (Stage stage : graph.getStages()) { Operator operator = Stages.lookup(stage); multi = applyProcessors(multi, stage, (ProcessorOperator) operator); } //noinspection unchecked return (Processor<T, R>) new WrappedProcessor<>(processor, multi); }
Example 8
Source File: Engine.java From smallrye-reactive-streams-operators with Apache License 2.0 | 5 votes |
@Override public <T, R> Processor<T, R> buildProcessor(Graph graph) { Processor<T, T> processor = new ConnectableProcessor<>(); Flowable<T> flowable = Flowable.fromPublisher(processor); for (Stage stage : graph.getStages()) { Operator operator = Stages.lookup(stage); flowable = applyProcessors(flowable, stage, (ProcessorOperator) operator); } //noinspection unchecked return (Processor<T, R>) new WrappedProcessor<>(processor, flowable); }