public void apply()

in camel-k-master/impl/src/main/java/org/apache/camel/k/master/MasterContextCustomizer.java [41:84]


    public void apply(CamelContext camelContext) {
        try {
            boolean existsService = false;
            KubernetesClusterService clusterService = new KubernetesClusterService();

            if (this.rebalancing == null || this.rebalancing) {
                RebalancingCamelClusterService existingRebalancingService =  camelContext.hasService(RebalancingCamelClusterService.class);
                if (existingRebalancingService != null){
                    existsService = true;
                    clusterService = (KubernetesClusterService)existingRebalancingService.getDelegate();
                }
            } else {
                if (camelContext.hasService(KubernetesClusterService.class) != null) {
                    clusterService = camelContext.hasService(KubernetesClusterService.class);
                    existsService = true;
                }
            }

            String resourceName = this.kubernetesResourceName;
            if (ObjectHelper.isEmpty(resourceName)) {
                resourceName = this.configMapName;
            }
            if (ObjectHelper.isNotEmpty(resourceName)) {
                clusterService.setKubernetesResourceName(resourceName);
            }
            if (ObjectHelper.isNotEmpty(this.labelKey) && ObjectHelper.isNotEmpty(this.labelValue)) {
                clusterService.setClusterLabels(Collections.singletonMap(this.labelKey, this.labelValue));
            }
            if (this.leaseResourceType != null) {
                clusterService.setLeaseResourceType(this.leaseResourceType);
            }

            if (!existsService) {
                if (this.rebalancing == null || this.rebalancing) {
                    RebalancingCamelClusterService rebalancingService = new RebalancingCamelClusterService(clusterService, clusterService.getRenewDeadlineMillis());
                    camelContext.addService(rebalancingService);
                } else {
                    camelContext.addService(clusterService);
                }
            }
        } catch (Exception ex) {
            throw new RuntimeCamelException(ex);
        }
    }