Search in sources :

Example 1 with ServiceChooserAware

use of org.apache.camel.cloud.ServiceChooserAware in project camel by apache.

the class ServiceCallDefinition method createProcessor.

// *****************************
// Processor Factory
// *****************************
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
    final CamelContext camelContext = routeContext.getCamelContext();
    final ServiceDiscovery serviceDiscovery = retrieveServiceDiscovery(camelContext);
    final ServiceFilter serviceFilter = retrieveServiceFilter(camelContext);
    final ServiceChooser serviceChooser = retrieveServiceChooser(camelContext);
    final LoadBalancer loadBalancer = retrieveLoadBalancer(camelContext);
    final Expression expression = retrieveExpression(camelContext);
    if (loadBalancer instanceof CamelContextAware) {
        ((CamelContextAware) loadBalancer).setCamelContext(camelContext);
    }
    if (loadBalancer instanceof ServiceDiscoveryAware) {
        ((ServiceDiscoveryAware) loadBalancer).setServiceDiscovery(serviceDiscovery);
    }
    if (loadBalancer instanceof ServiceFilterAware) {
        ((ServiceFilterAware) loadBalancer).setServiceFilter(serviceFilter);
    }
    if (loadBalancer instanceof ServiceChooserAware) {
        ((ServiceChooserAware) loadBalancer).setServiceChooser(serviceChooser);
    }
    // The component is used to configure the default scheme to use (eg camel component name).
    // The component configured on EIP takes precedence vs configured on configuration.
    String component = this.component;
    if (component == null) {
        ServiceCallConfigurationDefinition conf = retrieveConfig(camelContext);
        if (conf != null) {
            component = conf.getComponent();
        }
    }
    if (component == null) {
        ServiceCallConfigurationDefinition conf = retrieveDefaultConfig(camelContext);
        if (conf != null) {
            component = conf.getComponent();
        }
    }
    return new DefaultServiceCallProcessor(camelContext, name, component, uri, pattern, loadBalancer, expression);
}
Also used : CamelContext(org.apache.camel.CamelContext) PassThroughServiceFilter(org.apache.camel.impl.cloud.PassThroughServiceFilter) ServiceFilter(org.apache.camel.cloud.ServiceFilter) HealthyServiceFilter(org.apache.camel.impl.cloud.HealthyServiceFilter) CamelContextAware(org.apache.camel.CamelContextAware) ServiceDiscoveryAware(org.apache.camel.cloud.ServiceDiscoveryAware) ServiceChooserAware(org.apache.camel.cloud.ServiceChooserAware) DefaultServiceCallProcessor(org.apache.camel.impl.cloud.DefaultServiceCallProcessor) DefaultLoadBalancer(org.apache.camel.impl.cloud.DefaultLoadBalancer) LoadBalancer(org.apache.camel.cloud.LoadBalancer) ServiceFilterAware(org.apache.camel.cloud.ServiceFilterAware) ServiceChooser(org.apache.camel.cloud.ServiceChooser) RoundRobinServiceChooser(org.apache.camel.impl.cloud.RoundRobinServiceChooser) RandomServiceChooser(org.apache.camel.impl.cloud.RandomServiceChooser) DefaultServiceCallExpression(org.apache.camel.impl.cloud.DefaultServiceCallExpression) Expression(org.apache.camel.Expression) ServiceDiscovery(org.apache.camel.cloud.ServiceDiscovery)

Aggregations

CamelContext (org.apache.camel.CamelContext)1 CamelContextAware (org.apache.camel.CamelContextAware)1 Expression (org.apache.camel.Expression)1 LoadBalancer (org.apache.camel.cloud.LoadBalancer)1 ServiceChooser (org.apache.camel.cloud.ServiceChooser)1 ServiceChooserAware (org.apache.camel.cloud.ServiceChooserAware)1 ServiceDiscovery (org.apache.camel.cloud.ServiceDiscovery)1 ServiceDiscoveryAware (org.apache.camel.cloud.ServiceDiscoveryAware)1 ServiceFilter (org.apache.camel.cloud.ServiceFilter)1 ServiceFilterAware (org.apache.camel.cloud.ServiceFilterAware)1 DefaultLoadBalancer (org.apache.camel.impl.cloud.DefaultLoadBalancer)1 DefaultServiceCallExpression (org.apache.camel.impl.cloud.DefaultServiceCallExpression)1 DefaultServiceCallProcessor (org.apache.camel.impl.cloud.DefaultServiceCallProcessor)1 HealthyServiceFilter (org.apache.camel.impl.cloud.HealthyServiceFilter)1 PassThroughServiceFilter (org.apache.camel.impl.cloud.PassThroughServiceFilter)1 RandomServiceChooser (org.apache.camel.impl.cloud.RandomServiceChooser)1 RoundRobinServiceChooser (org.apache.camel.impl.cloud.RoundRobinServiceChooser)1