Interface Service<Context,Result>
- Type Parameters:
Context- Context type, this will be the input that is used to generate the responseResult- Response type, this is what is produced by the service ("provided")
- All Superinterfaces:
Function<@NonNull Context,@Nullable Result>
- All Known Subinterfaces:
ConsumerService<Context>,PartialResultService<Context,,Result, Chunked> SideEffectService<Context>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface Service<Context,Result>
extends Function<@NonNull Context,@Nullable Result>
A service is anything that can take in a context, and produce a response. Most service
implementations will be side effect free, although some service implementations will have side
effects. Those that do, should be clearly labeled
-
Method Summary
-
Method Details
-
handle
Provide a response for the given context. If the service implementation cannot provide a response for the given context, it should returnnull- Parameters:
context- Context used in the generation of the response- Returns:
- Response. If the response isn't
null, the next service in the service chain will get to act on the context. Otherwise the execution halts, and the provided response is the final response. - Throws:
Exception- Any exception that occurs during the handling can be thrown, and will be wrapped by aPipelineException
-
apply
-
order
Get the execution order of the service. This should not be overridden, unless you know what you are doing- Returns:
- Execution order
-