With CDI, you can define a small extension, which will automatically handle the failover, exactly as we did with streams previously, without much effort. The extension will be composed of two main parts:
- It will identify all the implementations of a particular logic
- It will register a bean for chaining the implementations in the right order with the failover logic
To do so, we need a few API elements:
- To find a service implementation, we will mark an interface method with @Failoverable to identify that we need to create a failover implementation for this interface; we will also use this annotation to mark the implementations.
- To sort the services, we will use @Priority. We will just use the priority value as a sorting ...