http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-replicatedmap.xml ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-replicatedmap.xml b/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-replicatedmap.xml index f6fe6ca..568c59f 100644 --- a/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-replicatedmap.xml +++ b/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-replicatedmap.xml @@ -30,7 +30,7 @@ <setHeader headerName="CamelHazelcastOperationType"> <constant>put</constant> </setHeader> - <to uri="hazelcast:replicatedmap:bar" /> + <to uri="hazelcast-replicatedmap:bar" /> </route> <route> @@ -38,7 +38,7 @@ <setHeader headerName="CamelHazelcastOperationType"> <constant>get</constant> </setHeader> - <to uri="hazelcast:replicatedmap:bar" /> + <to uri="hazelcast-replicatedmap:bar" /> <to uri="seda:out" /> </route> @@ -47,7 +47,7 @@ <setHeader headerName="CamelHazelcastOperationType"> <constant>delete</constant> </setHeader> - <to uri="hazelcast:replicatedmap:bar" /> + <to uri="hazelcast-replicatedmap:bar" /> </route> <route> @@ -55,7 +55,7 @@ <setHeader headerName="CamelHazelcastOperationType"> <constant>clear</constant> </setHeader> - <to uri="hazelcast:replicatedmap:bar" /> + <to uri="hazelcast-replicatedmap:bar" /> </route> <route> @@ -63,7 +63,7 @@ <setHeader headerName="CamelHazelcastOperationType"> <constant>containsKey</constant> </setHeader> - <to uri="hazelcast:replicatedmap:bar" /> + <to uri="hazelcast-replicatedmap:bar" /> <to uri="seda:out" /> </route> @@ -72,7 +72,7 @@ <setHeader headerName="CamelHazelcastOperationType"> <constant>containsValue</constant> </setHeader> - <to uri="hazelcast:replicatedmap:bar" /> + <to uri="hazelcast-replicatedmap:bar" /> <to uri="seda:out" /> </route> </camelContext>
http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-ringbuffer.xml ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-ringbuffer.xml b/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-ringbuffer.xml index 59502e1..27ac4d5 100644 --- a/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-ringbuffer.xml +++ b/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-ringbuffer.xml @@ -30,7 +30,7 @@ <setHeader headerName="CamelHazelcastOperationType"> <constant>add</constant> </setHeader> - <to uri="hazelcast:ringbuffer:foo" /> + <to uri="hazelcast-ringbuffer:foo" /> </route> <route> @@ -38,7 +38,7 @@ <setHeader headerName="CamelHazelcastOperationType"> <constant>readonceHead</constant> </setHeader> - <to uri="hazelcast:ringbuffer:foo" /> + <to uri="hazelcast-ringbuffer:foo" /> </route> <route> @@ -46,7 +46,7 @@ <setHeader headerName="CamelHazelcastOperationType"> <constant>readonceTail</constant> </setHeader> - <to uri="hazelcast:ringbuffer:foo" /> + <to uri="hazelcast-ringbuffer:foo" /> </route> <route> @@ -54,7 +54,7 @@ <setHeader headerName="CamelHazelcastOperationType"> <constant>capacity</constant> </setHeader> - <to uri="hazelcast:ringbuffer:foo" /> + <to uri="hazelcast-ringbuffer:foo" /> </route> <route> @@ -62,7 +62,7 @@ <setHeader headerName="CamelHazelcastOperationType"> <constant>remainingCapacity</constant> </setHeader> - <to uri="hazelcast:ringbuffer:foo" /> + <to uri="hazelcast-ringbuffer:foo" /> </route> </camelContext> http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-seda.xml ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-seda.xml b/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-seda.xml index 4f8e307..f349707 100644 --- a/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-seda.xml +++ b/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-seda.xml @@ -28,13 +28,13 @@ <camelContext id="xmlRoute" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:start" /> - <to uri="hazelcast:seda:foo" /> + <to uri="hazelcast-seda:foo" /> </route> <route> - <from uri="hazelcast:seda:foo" /> + <from uri="hazelcast-seda:foo" /> <to uri="mock:result" /> </route> </camelContext> -</beans> \ No newline at end of file +</beans> http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/components/readme.adoc ---------------------------------------------------------------------- diff --git a/components/readme.adoc b/components/readme.adoc index 8b29ef2..56f2c8f 100644 --- a/components/readme.adoc +++ b/components/readme.adoc @@ -2,7 +2,7 @@ Components ^^^^^^^^^^ // components: START -Number of Components: 238 in 185 JAR artifacts (14 deprecated) +Number of Components: 248 in 185 JAR artifacts (14 deprecated) [width="100%",cols="4,1,5",options="header"] |======================================================================= @@ -269,8 +269,38 @@ Number of Components: 238 in 185 JAR artifacts (14 deprecated) | link:camel-guava-eventbus/src/main/docs/guava-eventbus-component.adoc[Guava EventBus] (camel-guava-eventbus) + `guava-eventbus:eventBusRef` | 2.10 | The guava-eventbus component provides integration bridge between Camel and Google Guava EventBus. -| link:camel-hazelcast/src/main/docs/hazelcast-component.adoc[Hazelcast] (camel-hazelcast) + -`hazelcast:command:cacheName` | 2.7 | The hazelcast component allows you to work with the Hazelcast distributed data grid / cache. +| link:camel-hazelcast/src/main/docs/hazelcast-atomicvalue-component.adoc[Hazelcast Atomic Number] (camel-hazelcast) + +`hazelcast-atomicvalue:cacheName` | 2.7 | The hazelcast-atomicvalue component is used to access Hazelcast atomic number which is an object that simply provides a grid wide number (long). + +| link:camel-hazelcast/src/main/docs/hazelcast-instance-component.adoc[Hazelcast Instance] (camel-hazelcast) + +`hazelcast-instance:cacheName` | 2.7 | The hazelcast-instance component is used to consume join/leave events of the cache instance in the cluster. + +| link:camel-hazelcast/src/main/docs/hazelcast-list-component.adoc[Hazelcast List] (camel-hazelcast) + +`hazelcast-list:cacheName` | 2.7 | The hazelcast-list component is used to access Hazelcast distributed list. + +| link:camel-hazelcast/src/main/docs/hazelcast-map-component.adoc[Hazelcast Map] (camel-hazelcast) + +`hazelcast-map:cacheName` | 2.7 | The hazelcast-map component is used to access Hazelcast distributed map. + +| link:camel-hazelcast/src/main/docs/hazelcast-multimap-component.adoc[Hazelcast Multimap] (camel-hazelcast) + +`hazelcast-multimap:cacheName` | 2.7 | The hazelcast-multimap component is used to to access Hazelcast distributed multimap. + +| link:camel-hazelcast/src/main/docs/hazelcast-queue-component.adoc[Hazelcast Queue] (camel-hazelcast) + +`hazelcast-queue:cacheName` | 2.7 | The hazelcast-queue component is used to access Hazelcast distributed queue. + +| link:camel-hazelcast/src/main/docs/hazelcast-replicatedmap-component.adoc[Hazelcast Replicated Map] (camel-hazelcast) + +`hazelcast-replicatedmap:cacheName` | 2.16 | The hazelcast-replicatedmap component is used to access Hazelcast replicated map. + +| link:camel-hazelcast/src/main/docs/hazelcast-ringbuffer-component.adoc[Hazelcast Ringbuffer] (camel-hazelcast) + +`hazelcast-ringbuffer:cacheName` | 2.16 | The hazelcast-ringbuffer component is used to access Hazelcast distributed ringbuffer. + +| link:camel-hazelcast/src/main/docs/hazelcast-seda-component.adoc[Hazelcast SEDA] (camel-hazelcast) + +`hazelcast-seda:cacheName` | 2.7 | The hazelcast-seda component is used to access Hazelcast BlockingQueue. + +| link:camel-hazelcast/src/main/docs/hazelcast-set-component.adoc[Hazelcast Set] (camel-hazelcast) + +`hazelcast-set:cacheName` | 2.7 | The camel Endpoint to access Hazelcast distributed set. + +| link:camel-hazelcast/src/main/docs/hazelcast-topic-component.adoc[Hazelcast Topic] (camel-hazelcast) + +`hazelcast-topic:cacheName` | 2.15 | The hazelcast-topic component is used to access Hazelcast distributed topic. | link:camel-hbase/src/main/docs/hbase-component.adoc[HBase] (camel-hbase) + `hbase:tableName` | 2.10 | For reading/writing from/to an HBase store (Hadoop database). http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/docs/user-manual/en/SUMMARY.md ---------------------------------------------------------------------- diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md index 5ffcb5b..c4302f4 100644 --- a/docs/user-manual/en/SUMMARY.md +++ b/docs/user-manual/en/SUMMARY.md @@ -201,7 +201,17 @@ * [Grape](grape-component.adoc) * [gRPC](grpc-component.adoc) * [Guava EventBus](guava-eventbus-component.adoc) - * [Hazelcast](hazelcast-component.adoc) + * [Hazelcast Atomic Number](hazelcast-atomicvalue-component.adoc) + * [Hazelcast Instance](hazelcast-instance-component.adoc) + * [Hazelcast List](hazelcast-list-component.adoc) + * [Hazelcast Map](hazelcast-map-component.adoc) + * [Hazelcast Multimap](hazelcast-multimap-component.adoc) + * [Hazelcast Queue](hazelcast-queue-component.adoc) + * [Hazelcast Replicated Map](hazelcast-replicatedmap-component.adoc) + * [Hazelcast Ringbuffer](hazelcast-ringbuffer-component.adoc) + * [Hazelcast SEDA](hazelcast-seda-component.adoc) + * [Hazelcast Set](hazelcast-set-component.adoc) + * [Hazelcast Topic](hazelcast-topic-component.adoc) * [HBase](hbase-component.adoc) * [HDFS](hdfs-component.adoc) * [HDFS2](hdfs2-component.adoc) http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/examples/camel-example-hazelcast-kubernetes/ReadMe.md ---------------------------------------------------------------------- diff --git a/examples/camel-example-hazelcast-kubernetes/ReadMe.md b/examples/camel-example-hazelcast-kubernetes/ReadMe.md index 0f6c893..83b958f 100644 --- a/examples/camel-example-hazelcast-kubernetes/ReadMe.md +++ b/examples/camel-example-hazelcast-kubernetes/ReadMe.md @@ -111,7 +111,7 @@ INFO: hz.client_0 [someGroup] [3.8] HazelcastClient 3.8 (20170217 - d7998b4) is 2017-03-10 10:05:23,995 [main ] INFO DefaultRuntimeEndpointRegistry - Runtime endpoint registry is in extended mode gathering usage statistics of all incoming and outgoing endpoints (cache limit: 1000) 2017-03-10 10:05:24,061 [main ] INFO SpringCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html 2017-03-10 10:05:24,114 [main ] INFO SpringCamelContext - Route: route1 started and consuming from: timer://foo?period=5000 -2017-03-10 10:05:24,115 [main ] INFO SpringCamelContext - Route: route2 started and consuming from: hazelcast://topic:foo +2017-03-10 10:05:24,115 [main ] INFO SpringCamelContext - Route: route2 started and consuming from: hazelcast-topic://foo 2017-03-10 10:05:24,116 [main ] INFO SpringCamelContext - Total 2 routes, of which 2 are started. 2017-03-10 10:05:24,119 [main ] INFO SpringCamelContext - Apache Camel 2.19.0-SNAPSHOT (CamelContext: camel-1) started in 0.265 seconds Mar 10, 2017 10:05:24 AM com.hazelcast.client.connection.ClientConnectionManager http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/examples/camel-example-hazelcast-kubernetes/src/main/java/org/apache/camel/example/kubernetes/fmp/HazelcastRoute.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-hazelcast-kubernetes/src/main/java/org/apache/camel/example/kubernetes/fmp/HazelcastRoute.java b/examples/camel-example-hazelcast-kubernetes/src/main/java/org/apache/camel/example/kubernetes/fmp/HazelcastRoute.java index b851680..b098513 100644 --- a/examples/camel-example-hazelcast-kubernetes/src/main/java/org/apache/camel/example/kubernetes/fmp/HazelcastRoute.java +++ b/examples/camel-example-hazelcast-kubernetes/src/main/java/org/apache/camel/example/kubernetes/fmp/HazelcastRoute.java @@ -26,8 +26,8 @@ import com.hazelcast.core.HazelcastInstance; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.hazelcast.HazelcastComponent; import org.apache.camel.component.hazelcast.HazelcastConstants; +import org.apache.camel.component.hazelcast.topic.HazelcastTopicComponent; public class HazelcastRoute extends RouteBuilder { @@ -41,9 +41,9 @@ public class HazelcastRoute extends RouteBuilder { HazelcastInstance instance = HazelcastClient.newHazelcastClient(config); // setup camel hazelcast - HazelcastComponent hazelcast = new HazelcastComponent(); + HazelcastTopicComponent hazelcast = new HazelcastTopicComponent(); hazelcast.setHazelcastInstance(instance); - getContext().addComponent("hazelcast", hazelcast); + getContext().addComponent("hazelcast-topic", hazelcast); from("timer:foo?period=5000") .log("Producer side: Sending data to Hazelcast topic..") @@ -55,9 +55,9 @@ public class HazelcastRoute extends RouteBuilder { exchange.getIn().setBody(payload); } }) - .to("hazelcast:topic:foo"); + .to("hazelcast-topic:foo"); - from("hazelcast:topic:foo") + from("hazelcast-topic:foo") .log("Consumer side: Detected following action: $simple{in.header.CamelHazelcastListenerAction}"); } http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentAutoConfiguration.java new file mode 100644 index 0000000..577a8c6 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentAutoConfiguration.java @@ -0,0 +1,115 @@ +/** + * 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.hazelcast.atomicnumber.springboot; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.hazelcast.atomicnumber.HazelcastAtomicnumberComponent; +import org.apache.camel.util.IntrospectionSupport; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionMessage; +import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.SpringBootCondition; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.core.type.AnnotatedTypeMetadata; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@Conditional(HazelcastAtomicnumberComponentAutoConfiguration.Condition.class) +@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(HazelcastAtomicnumberComponentConfiguration.class) +public class HazelcastAtomicnumberComponentAutoConfiguration { + + @Lazy + @Bean(name = "hazelcast-atomicvalue-component") + @ConditionalOnClass(CamelContext.class) + @ConditionalOnMissingBean(HazelcastAtomicnumberComponent.class) + public HazelcastAtomicnumberComponent configureHazelcastAtomicnumberComponent( + CamelContext camelContext, + HazelcastAtomicnumberComponentConfiguration configuration) + throws Exception { + HazelcastAtomicnumberComponent component = new HazelcastAtomicnumberComponent(); + component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); + return component; + } + + @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") + public static class Condition extends SpringBootCondition { + @Override + public ConditionOutcome getMatchOutcome( + ConditionContext conditionContext, + AnnotatedTypeMetadata annotatedTypeMetadata) { + boolean groupEnabled = isEnabled(conditionContext, + "camel.component.", true); + ConditionMessage.Builder message = ConditionMessage + .forCondition("camel.component.hazelcast-atomicvalue"); + if (isEnabled(conditionContext, + "camel.component.hazelcast-atomicvalue.", groupEnabled)) { + return ConditionOutcome.match(message.because("enabled")); + } + return ConditionOutcome.noMatch(message.because("not enabled")); + } + + private boolean isEnabled( + org.springframework.context.annotation.ConditionContext context, + java.lang.String prefix, boolean defaultValue) { + RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( + context.getEnvironment(), prefix); + return resolver.getProperty("enabled", Boolean.class, defaultValue); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentConfiguration.java new file mode 100644 index 0000000..0c7a749 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentConfiguration.java @@ -0,0 +1,77 @@ +/** + * 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.hazelcast.atomicnumber.springboot; + +import javax.annotation.Generated; +import com.hazelcast.core.HazelcastInstance; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * The hazelcast-atomicvalue component is used to access Hazelcast atomic number + * which is an object that simply provides a grid wide number (long). + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.hazelcast-atomicvalue") +public class HazelcastAtomicnumberComponentConfiguration { + + /** + * The hazelcast instance reference which can be used for hazelcast + * endpoint. If you don't specify the instance reference camel use the + * default hazelcast instance from the camel-hazelcast instance. + */ + @NestedConfigurationProperty + private HazelcastInstance hazelcastInstance; + /** + * The hazelcast mode reference which kind of instance should be used. If + * you don't specify the mode then the node mode will be the default. + */ + private String hazelcastMode = "node"; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public HazelcastInstance getHazelcastInstance() { + return hazelcastInstance; + } + + public void setHazelcastInstance(HazelcastInstance hazelcastInstance) { + this.hazelcastInstance = hazelcastInstance; + } + + public String getHazelcastMode() { + return hazelcastMode; + } + + public void setHazelcastMode(String hazelcastMode) { + this.hazelcastMode = hazelcastMode; + } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentAutoConfiguration.java new file mode 100644 index 0000000..480ce76 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentAutoConfiguration.java @@ -0,0 +1,115 @@ +/** + * 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.hazelcast.instance.springboot; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.hazelcast.instance.HazelcastInstanceComponent; +import org.apache.camel.util.IntrospectionSupport; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionMessage; +import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.SpringBootCondition; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.core.type.AnnotatedTypeMetadata; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@Conditional(HazelcastInstanceComponentAutoConfiguration.Condition.class) +@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(HazelcastInstanceComponentConfiguration.class) +public class HazelcastInstanceComponentAutoConfiguration { + + @Lazy + @Bean(name = "hazelcast-instance-component") + @ConditionalOnClass(CamelContext.class) + @ConditionalOnMissingBean(HazelcastInstanceComponent.class) + public HazelcastInstanceComponent configureHazelcastInstanceComponent( + CamelContext camelContext, + HazelcastInstanceComponentConfiguration configuration) + throws Exception { + HazelcastInstanceComponent component = new HazelcastInstanceComponent(); + component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); + return component; + } + + @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") + public static class Condition extends SpringBootCondition { + @Override + public ConditionOutcome getMatchOutcome( + ConditionContext conditionContext, + AnnotatedTypeMetadata annotatedTypeMetadata) { + boolean groupEnabled = isEnabled(conditionContext, + "camel.component.", true); + ConditionMessage.Builder message = ConditionMessage + .forCondition("camel.component.hazelcast-instance"); + if (isEnabled(conditionContext, + "camel.component.hazelcast-instance.", groupEnabled)) { + return ConditionOutcome.match(message.because("enabled")); + } + return ConditionOutcome.noMatch(message.because("not enabled")); + } + + private boolean isEnabled( + org.springframework.context.annotation.ConditionContext context, + java.lang.String prefix, boolean defaultValue) { + RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( + context.getEnvironment(), prefix); + return resolver.getProperty("enabled", Boolean.class, defaultValue); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentConfiguration.java new file mode 100644 index 0000000..a34e790 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentConfiguration.java @@ -0,0 +1,77 @@ +/** + * 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.hazelcast.instance.springboot; + +import javax.annotation.Generated; +import com.hazelcast.core.HazelcastInstance; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * The hazelcast-instance component is used to consume join/leave events of the + * cache instance in the cluster. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.hazelcast-instance") +public class HazelcastInstanceComponentConfiguration { + + /** + * The hazelcast instance reference which can be used for hazelcast + * endpoint. If you don't specify the instance reference camel use the + * default hazelcast instance from the camel-hazelcast instance. + */ + @NestedConfigurationProperty + private HazelcastInstance hazelcastInstance; + /** + * The hazelcast mode reference which kind of instance should be used. If + * you don't specify the mode then the node mode will be the default. + */ + private String hazelcastMode = "node"; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public HazelcastInstance getHazelcastInstance() { + return hazelcastInstance; + } + + public void setHazelcastInstance(HazelcastInstance hazelcastInstance) { + this.hazelcastInstance = hazelcastInstance; + } + + public String getHazelcastMode() { + return hazelcastMode; + } + + public void setHazelcastMode(String hazelcastMode) { + this.hazelcastMode = hazelcastMode; + } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentAutoConfiguration.java new file mode 100644 index 0000000..3a71585 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentAutoConfiguration.java @@ -0,0 +1,114 @@ +/** + * 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.hazelcast.list.springboot; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.hazelcast.list.HazelcastListComponent; +import org.apache.camel.util.IntrospectionSupport; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionMessage; +import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.SpringBootCondition; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.core.type.AnnotatedTypeMetadata; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@Conditional(HazelcastListComponentAutoConfiguration.Condition.class) +@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(HazelcastListComponentConfiguration.class) +public class HazelcastListComponentAutoConfiguration { + + @Lazy + @Bean(name = "hazelcast-list-component") + @ConditionalOnClass(CamelContext.class) + @ConditionalOnMissingBean(HazelcastListComponent.class) + public HazelcastListComponent configureHazelcastListComponent( + CamelContext camelContext, + HazelcastListComponentConfiguration configuration) throws Exception { + HazelcastListComponent component = new HazelcastListComponent(); + component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); + return component; + } + + @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") + public static class Condition extends SpringBootCondition { + @Override + public ConditionOutcome getMatchOutcome( + ConditionContext conditionContext, + AnnotatedTypeMetadata annotatedTypeMetadata) { + boolean groupEnabled = isEnabled(conditionContext, + "camel.component.", true); + ConditionMessage.Builder message = ConditionMessage + .forCondition("camel.component.hazelcast-list"); + if (isEnabled(conditionContext, "camel.component.hazelcast-list.", + groupEnabled)) { + return ConditionOutcome.match(message.because("enabled")); + } + return ConditionOutcome.noMatch(message.because("not enabled")); + } + + private boolean isEnabled( + org.springframework.context.annotation.ConditionContext context, + java.lang.String prefix, boolean defaultValue) { + RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( + context.getEnvironment(), prefix); + return resolver.getProperty("enabled", Boolean.class, defaultValue); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentConfiguration.java new file mode 100644 index 0000000..011f99d --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentConfiguration.java @@ -0,0 +1,76 @@ +/** + * 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.hazelcast.list.springboot; + +import javax.annotation.Generated; +import com.hazelcast.core.HazelcastInstance; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * The hazelcast-list component is used to access Hazelcast distributed list. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.hazelcast-list") +public class HazelcastListComponentConfiguration { + + /** + * The hazelcast instance reference which can be used for hazelcast + * endpoint. If you don't specify the instance reference camel use the + * default hazelcast instance from the camel-hazelcast instance. + */ + @NestedConfigurationProperty + private HazelcastInstance hazelcastInstance; + /** + * The hazelcast mode reference which kind of instance should be used. If + * you don't specify the mode then the node mode will be the default. + */ + private String hazelcastMode = "node"; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public HazelcastInstance getHazelcastInstance() { + return hazelcastInstance; + } + + public void setHazelcastInstance(HazelcastInstance hazelcastInstance) { + this.hazelcastInstance = hazelcastInstance; + } + + public String getHazelcastMode() { + return hazelcastMode; + } + + public void setHazelcastMode(String hazelcastMode) { + this.hazelcastMode = hazelcastMode; + } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentAutoConfiguration.java new file mode 100644 index 0000000..6b9603d --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentAutoConfiguration.java @@ -0,0 +1,114 @@ +/** + * 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.hazelcast.map.springboot; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.hazelcast.map.HazelcastMapComponent; +import org.apache.camel.util.IntrospectionSupport; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionMessage; +import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.SpringBootCondition; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.core.type.AnnotatedTypeMetadata; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@Conditional(HazelcastMapComponentAutoConfiguration.Condition.class) +@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(HazelcastMapComponentConfiguration.class) +public class HazelcastMapComponentAutoConfiguration { + + @Lazy + @Bean(name = "hazelcast-map-component") + @ConditionalOnClass(CamelContext.class) + @ConditionalOnMissingBean(HazelcastMapComponent.class) + public HazelcastMapComponent configureHazelcastMapComponent( + CamelContext camelContext, + HazelcastMapComponentConfiguration configuration) throws Exception { + HazelcastMapComponent component = new HazelcastMapComponent(); + component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); + return component; + } + + @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") + public static class Condition extends SpringBootCondition { + @Override + public ConditionOutcome getMatchOutcome( + ConditionContext conditionContext, + AnnotatedTypeMetadata annotatedTypeMetadata) { + boolean groupEnabled = isEnabled(conditionContext, + "camel.component.", true); + ConditionMessage.Builder message = ConditionMessage + .forCondition("camel.component.hazelcast-map"); + if (isEnabled(conditionContext, "camel.component.hazelcast-map.", + groupEnabled)) { + return ConditionOutcome.match(message.because("enabled")); + } + return ConditionOutcome.noMatch(message.because("not enabled")); + } + + private boolean isEnabled( + org.springframework.context.annotation.ConditionContext context, + java.lang.String prefix, boolean defaultValue) { + RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( + context.getEnvironment(), prefix); + return resolver.getProperty("enabled", Boolean.class, defaultValue); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentConfiguration.java new file mode 100644 index 0000000..d7fcf41 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentConfiguration.java @@ -0,0 +1,76 @@ +/** + * 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.hazelcast.map.springboot; + +import javax.annotation.Generated; +import com.hazelcast.core.HazelcastInstance; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * The hazelcast-map component is used to access Hazelcast distributed map. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.hazelcast-map") +public class HazelcastMapComponentConfiguration { + + /** + * The hazelcast instance reference which can be used for hazelcast + * endpoint. If you don't specify the instance reference camel use the + * default hazelcast instance from the camel-hazelcast instance. + */ + @NestedConfigurationProperty + private HazelcastInstance hazelcastInstance; + /** + * The hazelcast mode reference which kind of instance should be used. If + * you don't specify the mode then the node mode will be the default. + */ + private String hazelcastMode = "node"; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public HazelcastInstance getHazelcastInstance() { + return hazelcastInstance; + } + + public void setHazelcastInstance(HazelcastInstance hazelcastInstance) { + this.hazelcastInstance = hazelcastInstance; + } + + public String getHazelcastMode() { + return hazelcastMode; + } + + public void setHazelcastMode(String hazelcastMode) { + this.hazelcastMode = hazelcastMode; + } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentAutoConfiguration.java new file mode 100644 index 0000000..08b7115 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentAutoConfiguration.java @@ -0,0 +1,115 @@ +/** + * 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.hazelcast.multimap.springboot; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.hazelcast.multimap.HazelcastMultimapComponent; +import org.apache.camel.util.IntrospectionSupport; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionMessage; +import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.SpringBootCondition; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.core.type.AnnotatedTypeMetadata; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@Conditional(HazelcastMultimapComponentAutoConfiguration.Condition.class) +@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(HazelcastMultimapComponentConfiguration.class) +public class HazelcastMultimapComponentAutoConfiguration { + + @Lazy + @Bean(name = "hazelcast-multimap-component") + @ConditionalOnClass(CamelContext.class) + @ConditionalOnMissingBean(HazelcastMultimapComponent.class) + public HazelcastMultimapComponent configureHazelcastMultimapComponent( + CamelContext camelContext, + HazelcastMultimapComponentConfiguration configuration) + throws Exception { + HazelcastMultimapComponent component = new HazelcastMultimapComponent(); + component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); + return component; + } + + @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") + public static class Condition extends SpringBootCondition { + @Override + public ConditionOutcome getMatchOutcome( + ConditionContext conditionContext, + AnnotatedTypeMetadata annotatedTypeMetadata) { + boolean groupEnabled = isEnabled(conditionContext, + "camel.component.", true); + ConditionMessage.Builder message = ConditionMessage + .forCondition("camel.component.hazelcast-multimap"); + if (isEnabled(conditionContext, + "camel.component.hazelcast-multimap.", groupEnabled)) { + return ConditionOutcome.match(message.because("enabled")); + } + return ConditionOutcome.noMatch(message.because("not enabled")); + } + + private boolean isEnabled( + org.springframework.context.annotation.ConditionContext context, + java.lang.String prefix, boolean defaultValue) { + RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( + context.getEnvironment(), prefix); + return resolver.getProperty("enabled", Boolean.class, defaultValue); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentConfiguration.java new file mode 100644 index 0000000..2869489 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentConfiguration.java @@ -0,0 +1,77 @@ +/** + * 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.hazelcast.multimap.springboot; + +import javax.annotation.Generated; +import com.hazelcast.core.HazelcastInstance; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * The hazelcast-multimap component is used to to access Hazelcast distributed + * multimap. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.hazelcast-multimap") +public class HazelcastMultimapComponentConfiguration { + + /** + * The hazelcast instance reference which can be used for hazelcast + * endpoint. If you don't specify the instance reference camel use the + * default hazelcast instance from the camel-hazelcast instance. + */ + @NestedConfigurationProperty + private HazelcastInstance hazelcastInstance; + /** + * The hazelcast mode reference which kind of instance should be used. If + * you don't specify the mode then the node mode will be the default. + */ + private String hazelcastMode = "node"; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public HazelcastInstance getHazelcastInstance() { + return hazelcastInstance; + } + + public void setHazelcastInstance(HazelcastInstance hazelcastInstance) { + this.hazelcastInstance = hazelcastInstance; + } + + public String getHazelcastMode() { + return hazelcastMode; + } + + public void setHazelcastMode(String hazelcastMode) { + this.hazelcastMode = hazelcastMode; + } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentAutoConfiguration.java new file mode 100644 index 0000000..6873e44 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentAutoConfiguration.java @@ -0,0 +1,115 @@ +/** + * 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.hazelcast.queue.springboot; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.hazelcast.queue.HazelcastQueueComponent; +import org.apache.camel.util.IntrospectionSupport; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionMessage; +import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.SpringBootCondition; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.core.type.AnnotatedTypeMetadata; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@Conditional(HazelcastQueueComponentAutoConfiguration.Condition.class) +@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(HazelcastQueueComponentConfiguration.class) +public class HazelcastQueueComponentAutoConfiguration { + + @Lazy + @Bean(name = "hazelcast-queue-component") + @ConditionalOnClass(CamelContext.class) + @ConditionalOnMissingBean(HazelcastQueueComponent.class) + public HazelcastQueueComponent configureHazelcastQueueComponent( + CamelContext camelContext, + HazelcastQueueComponentConfiguration configuration) + throws Exception { + HazelcastQueueComponent component = new HazelcastQueueComponent(); + component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); + return component; + } + + @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") + public static class Condition extends SpringBootCondition { + @Override + public ConditionOutcome getMatchOutcome( + ConditionContext conditionContext, + AnnotatedTypeMetadata annotatedTypeMetadata) { + boolean groupEnabled = isEnabled(conditionContext, + "camel.component.", true); + ConditionMessage.Builder message = ConditionMessage + .forCondition("camel.component.hazelcast-queue"); + if (isEnabled(conditionContext, "camel.component.hazelcast-queue.", + groupEnabled)) { + return ConditionOutcome.match(message.because("enabled")); + } + return ConditionOutcome.noMatch(message.because("not enabled")); + } + + private boolean isEnabled( + org.springframework.context.annotation.ConditionContext context, + java.lang.String prefix, boolean defaultValue) { + RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( + context.getEnvironment(), prefix); + return resolver.getProperty("enabled", Boolean.class, defaultValue); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentConfiguration.java new file mode 100644 index 0000000..60fb9bb --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentConfiguration.java @@ -0,0 +1,76 @@ +/** + * 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.hazelcast.queue.springboot; + +import javax.annotation.Generated; +import com.hazelcast.core.HazelcastInstance; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * The hazelcast-queue component is used to access Hazelcast distributed queue. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.hazelcast-queue") +public class HazelcastQueueComponentConfiguration { + + /** + * The hazelcast instance reference which can be used for hazelcast + * endpoint. If you don't specify the instance reference camel use the + * default hazelcast instance from the camel-hazelcast instance. + */ + @NestedConfigurationProperty + private HazelcastInstance hazelcastInstance; + /** + * The hazelcast mode reference which kind of instance should be used. If + * you don't specify the mode then the node mode will be the default. + */ + private String hazelcastMode = "node"; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public HazelcastInstance getHazelcastInstance() { + return hazelcastInstance; + } + + public void setHazelcastInstance(HazelcastInstance hazelcastInstance) { + this.hazelcastInstance = hazelcastInstance; + } + + public String getHazelcastMode() { + return hazelcastMode; + } + + public void setHazelcastMode(String hazelcastMode) { + this.hazelcastMode = hazelcastMode; + } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf10d278/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/replicatedmap/springboot/HazelcastReplicatedmapComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/replicatedmap/springboot/HazelcastReplicatedmapComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/replicatedmap/springboot/HazelcastReplicatedmapComponentAutoConfiguration.java new file mode 100644 index 0000000..df46cf9 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/replicatedmap/springboot/HazelcastReplicatedmapComponentAutoConfiguration.java @@ -0,0 +1,115 @@ +/** + * 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.hazelcast.replicatedmap.springboot; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.hazelcast.replicatedmap.HazelcastReplicatedmapComponent; +import org.apache.camel.util.IntrospectionSupport; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionMessage; +import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.SpringBootCondition; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.core.type.AnnotatedTypeMetadata; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@Conditional(HazelcastReplicatedmapComponentAutoConfiguration.Condition.class) +@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(HazelcastReplicatedmapComponentConfiguration.class) +public class HazelcastReplicatedmapComponentAutoConfiguration { + + @Lazy + @Bean(name = "hazelcast-replicatedmap-component") + @ConditionalOnClass(CamelContext.class) + @ConditionalOnMissingBean(HazelcastReplicatedmapComponent.class) + public HazelcastReplicatedmapComponent configureHazelcastReplicatedmapComponent( + CamelContext camelContext, + HazelcastReplicatedmapComponentConfiguration configuration) + throws Exception { + HazelcastReplicatedmapComponent component = new HazelcastReplicatedmapComponent(); + component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); + return component; + } + + @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") + public static class Condition extends SpringBootCondition { + @Override + public ConditionOutcome getMatchOutcome( + ConditionContext conditionContext, + AnnotatedTypeMetadata annotatedTypeMetadata) { + boolean groupEnabled = isEnabled(conditionContext, + "camel.component.", true); + ConditionMessage.Builder message = ConditionMessage + .forCondition("camel.component.hazelcast-replicatedmap"); + if (isEnabled(conditionContext, + "camel.component.hazelcast-replicatedmap.", groupEnabled)) { + return ConditionOutcome.match(message.because("enabled")); + } + return ConditionOutcome.noMatch(message.because("not enabled")); + } + + private boolean isEnabled( + org.springframework.context.annotation.ConditionContext context, + java.lang.String prefix, boolean defaultValue) { + RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( + context.getEnvironment(), prefix); + return resolver.getProperty("enabled", Boolean.class, defaultValue); + } + } +} \ No newline at end of file