CAMEL-11816: cluster-service : camel-consul spring boot support
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/24cb5437 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/24cb5437 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/24cb5437 Branch: refs/heads/master Commit: 24cb5437f8437d806ba0c96a8b50f8b0baa66df3 Parents: a38615c Author: lburgazzoli <lburgazz...@gmail.com> Authored: Sat Sep 23 17:30:59 2017 +0200 Committer: lburgazzoli <lburgazz...@gmail.com> Committed: Mon Sep 25 14:21:00 2017 +0200 ---------------------------------------------------------------------- .../ConsulClusterServiceAutoConfiguration.java | 55 ++++++++++++++++++++ .../ha/ConsulClusterServiceConfiguration.java | 49 +++++++++++++++++ .../main/resources/META-INF/spring.factories | 1 + 3 files changed, 105 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/24cb5437/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ha/ConsulClusterServiceAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ha/ConsulClusterServiceAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ha/ConsulClusterServiceAutoConfiguration.java new file mode 100644 index 0000000..bd0dd8c --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ha/ConsulClusterServiceAutoConfiguration.java @@ -0,0 +1,55 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.consul.springboot.ha; + +import org.apache.camel.component.consul.ha.ConsulClusterService; +import org.apache.camel.ha.CamelClusterService; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ha.ClusteredRouteControllerAutoConfiguration; +import org.apache.camel.util.IntrospectionSupport; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; + +@Configuration +@AutoConfigureBefore({ ClusteredRouteControllerAutoConfiguration.class, CamelAutoConfiguration.class }) +@ConditionalOnProperty(prefix = "camel.clustered.service.consul", name = "enabled") +@EnableConfigurationProperties(ConsulClusterServiceConfiguration.class) +public class ConsulClusterServiceAutoConfiguration { + @Autowired + private ConsulClusterServiceConfiguration configuration; + + @Bean(initMethod = "start", destroyMethod = "stop") + @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) + @ConditionalOnMissingBean + public CamelClusterService consulClusterService() throws Exception { + ConsulClusterService service = new ConsulClusterService(); + + IntrospectionSupport.setProperties( + service, + IntrospectionSupport.getNonNullProperties(configuration) + ); + + return service; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/24cb5437/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ha/ConsulClusterServiceConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ha/ConsulClusterServiceConfiguration.java b/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ha/ConsulClusterServiceConfiguration.java new file mode 100644 index 0000000..d47aa71 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ha/ConsulClusterServiceConfiguration.java @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.consul.springboot.ha; + +import org.apache.camel.component.consul.ha.ConsulClusterConfiguration; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = "camel.clustered.service.consul") +public class ConsulClusterServiceConfiguration extends ConsulClusterConfiguration { + /** + * Sets if the zookeeper cluster service should be enabled or not, default is false. + */ + private boolean enabled; + + /** + * Cluster Service ID + */ + private String id; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/24cb5437/platforms/spring-boot/components-starter/camel-consul-starter/src/main/resources/META-INF/spring.factories ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-consul-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-consul-starter/src/main/resources/META-INF/spring.factories index 46411e2..9e50542 100644 --- a/platforms/spring-boot/components-starter/camel-consul-starter/src/main/resources/META-INF/spring.factories +++ b/platforms/spring-boot/components-starter/camel-consul-starter/src/main/resources/META-INF/spring.factories @@ -17,4 +17,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ org.apache.camel.component.consul.springboot.ConsulComponentAutoConfiguration,\ org.apache.camel.component.consul.springboot.cloud.ConsulServiceDiscoveryAutoConfiguration,\ +org.apache.camel.component.consul.springboot.ha.ConsulClusterServiceAutoConfiguration,\ org.apache.camel.component.consul.springboot.health.HealthCheckRepositoryAutoConfiguration \ No newline at end of file