dschulten opened a new pull request #5332: URL: https://github.com/apache/camel/pull/5332
fixes https://issues.apache.org/jira/browse/CAMEL-16449 Main goal: pass the current exchange to `ServiceFilter.apply` without breaking existing `ServiceFilter` and `ServiceLoadBalancer` implementations. Make it as convenient as possible to implement service filters with access to the current exchange. Trade-off: the old method cannot be executed upwards-compatibly on the new `ContentBasedServiceFilter`. Hence the implementation is a bit more convoluted than I would like it to be. Implementation steps: 1. Introduce new `ServiceFilter.apply(exchange, services)` method with default impl that calls the old apply method without passing the exchange 2. Introduce new ServiceLoadBalancer.process(exchange, serviceName, serviceLoadBalancerFunction) method with default impl that calls the old process method without passing the exchange 3. Call the new ServiceFilter.apply method from new DefaultLoadBalancer.process method 4. Let the old `DefaultLoadBalancer.process` method call the new one, passing a `null` exchange. The old method cannot throw an exception since that would break existing `ServiceLoadBalancer` impls. I pass `null`, but it should never be passed on to actual service filters because of the next step: 5. The default ServiceFilter.apply(exchange, services) method calls the old apply(services) without passing the `null` exchange, so that existing ServiceFilter and ServiceLoadBalancer impls remain compatible and the `null` exchange should usually not be encountered anywhere at runtime. 5. Introduce new functional interface `ContentBasedServiceFilter` with a `ContentBasedServiceFilterAdapter` so that users can write a lambda based `ContentBasedServiceFilter` which is also a ServiceFilter (see `LoadBalancerTest#testLoadBalancerWithContentBasedServiceFilter)` 6. `ContentBasedServiceFilterAdapter` throws an exception if its old `apply(services)` method gets called, so that people who try to run a `ContentBasedServiceFilter` without passing an exchange are being told that this filter requires an exchange and that they might have to adjust their custom `ServiceLoadBalancer`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org