CAMEL-11815: cluster-service : camel-zookeeper 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/a38615c6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a38615c6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a38615c6

Branch: refs/heads/master
Commit: a38615c61dac588ee9bf6b2151289df3216601d4
Parents: 3bed414
Author: lburgazzoli <lburgazz...@gmail.com>
Authored: Sat Sep 23 17:17:49 2017 +0200
Committer: lburgazzoli <lburgazz...@gmail.com>
Committed: Mon Sep 25 14:21:00 2017 +0200

----------------------------------------------------------------------
 ...ooKeeperClusterServiceAutoConfiguration.java | 55 ++++++++++++++++++++
 .../ZooKeeperClusterServiceConfiguration.java   | 49 +++++++++++++++++
 .../main/resources/META-INF/spring.factories    |  3 +-
 3 files changed, 106 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a38615c6/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/ha/springboot/ZooKeeperClusterServiceAutoConfiguration.java
----------------------------------------------------------------------
diff --git 
a/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/ha/springboot/ZooKeeperClusterServiceAutoConfiguration.java
 
b/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/ha/springboot/ZooKeeperClusterServiceAutoConfiguration.java
new file mode 100644
index 0000000..9cb27a0
--- /dev/null
+++ 
b/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/ha/springboot/ZooKeeperClusterServiceAutoConfiguration.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.zookeeper.ha.springboot;
+
+import org.apache.camel.component.zookeeper.ha.ZooKeeperClusterService;
+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.zookeeper", name = 
"enabled")
+@EnableConfigurationProperties(ZooKeeperClusterServiceConfiguration.class)
+public class ZooKeeperClusterServiceAutoConfiguration {
+    @Autowired
+    private ZooKeeperClusterServiceConfiguration configuration;
+
+    @Bean(initMethod = "start", destroyMethod = "stop")
+    @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
+    @ConditionalOnMissingBean
+    public CamelClusterService zookeeperClusterService() throws Exception {
+        ZooKeeperClusterService service = new ZooKeeperClusterService();
+
+        IntrospectionSupport.setProperties(
+            service,
+            IntrospectionSupport.getNonNullProperties(configuration)
+        );
+
+        return service;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a38615c6/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/ha/springboot/ZooKeeperClusterServiceConfiguration.java
----------------------------------------------------------------------
diff --git 
a/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/ha/springboot/ZooKeeperClusterServiceConfiguration.java
 
b/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/ha/springboot/ZooKeeperClusterServiceConfiguration.java
new file mode 100644
index 0000000..620ec0e
--- /dev/null
+++ 
b/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/ha/springboot/ZooKeeperClusterServiceConfiguration.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.zookeeper.ha.springboot;
+
+import org.apache.camel.component.zookeeper.ZooKeeperCuratorConfiguration;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@ConfigurationProperties(prefix = "camel.clustered.service.zookeeper")
+public class ZooKeeperClusterServiceConfiguration extends 
ZooKeeperCuratorConfiguration {
+    /**
+     * 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/a38615c6/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/resources/META-INF/spring.factories
----------------------------------------------------------------------
diff --git 
a/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/resources/META-INF/spring.factories
 
b/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/resources/META-INF/spring.factories
index b69b4b6..e494925 100644
--- 
a/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/resources/META-INF/spring.factories
+++ 
b/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/resources/META-INF/spring.factories
@@ -15,4 +15,5 @@
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-org.apache.camel.component.zookeeper.springboot.ZooKeeperComponentAutoConfiguration
+org.apache.camel.component.zookeeper.springboot.ZooKeeperComponentAutoConfiguration,\
+org.apache.camel.component.zookeeper.ha.springboot.ZooKeeperClusterServiceAutoConfiguration

Reply via email to