Repository: camel Updated Branches: refs/heads/master e4e7aba12 -> 3756fba22
http://git-wip-us.apache.org/repos/asf/camel/blob/3756fba2/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/messaging/springboot/AtomixMessagingComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/messaging/springboot/AtomixMessagingComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/messaging/springboot/AtomixMessagingComponentAutoConfiguration.java new file mode 100644 index 0000000..3bc3f46 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/messaging/springboot/AtomixMessagingComponentAutoConfiguration.java @@ -0,0 +1,129 @@ +/** + * 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.atomix.client.messaging.springboot; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.atomix.client.messaging.AtomixMessagingComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; +import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; +import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@Conditional({ConditionalOnCamelContextAndAutoConfigurationBeans.class, + AtomixMessagingComponentAutoConfiguration.GroupConditions.class}) +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + AtomixMessagingComponentConfiguration.class}) +public class AtomixMessagingComponentAutoConfiguration { + + private static final Logger LOGGER = LoggerFactory + .getLogger(AtomixMessagingComponentAutoConfiguration.class); + @Autowired + private ApplicationContext applicationContext; + @Autowired + private CamelContext camelContext; + @Autowired + private AtomixMessagingComponentConfiguration configuration; + @Autowired(required = false) + private List<ComponentCustomizer<AtomixMessagingComponent>> customizers; + + static class GroupConditions extends GroupCondition { + public GroupConditions() { + super("camel.component", "camel.component.atomix-messaging"); + } + } + + @Lazy + @Bean(name = "atomix-messaging-component") + @ConditionalOnMissingBean(AtomixMessagingComponent.class) + public AtomixMessagingComponent configureAtomixMessagingComponent() + throws Exception { + AtomixMessagingComponent component = new AtomixMessagingComponent(); + 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); + if (ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<AtomixMessagingComponent> customizer : customizers) { + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.atomix-messaging.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.atomix-messaging.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } + } + } + return component; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3756fba2/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/messaging/springboot/AtomixMessagingComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/messaging/springboot/AtomixMessagingComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/messaging/springboot/AtomixMessagingComponentConfiguration.java new file mode 100644 index 0000000..e1525b3 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/messaging/springboot/AtomixMessagingComponentConfiguration.java @@ -0,0 +1,170 @@ +/** + * 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.atomix.client.messaging.springboot; + +import java.util.List; +import javax.annotation.Generated; +import io.atomix.AtomixClient; +import io.atomix.catalyst.transport.Address; +import org.apache.camel.component.atomix.client.messaging.AtomixMessaging.Action; +import org.apache.camel.component.atomix.client.messaging.AtomixMessaging.BroadcastType; +import org.apache.camel.component.atomix.client.messaging.AtomixMessagingComponent; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * Camel Atomix support + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.atomix-messaging") +public class AtomixMessagingComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { + + /** + * The shared component configuration + */ + private AtomixMessagingConfigurationNestedConfiguration configuration; + /** + * The shared AtomixClient instance + */ + @NestedConfigurationProperty + private AtomixClient atomix; + /** + * The nodes the AtomixClient should connect to + */ + private List<Address> nodes; + /** + * The path to the AtomixClient configuration + */ + private String configurationUri; + /** + * 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 AtomixMessagingConfigurationNestedConfiguration getConfiguration() { + return configuration; + } + + public void setConfiguration( + AtomixMessagingConfigurationNestedConfiguration configuration) { + this.configuration = configuration; + } + + public AtomixClient getAtomix() { + return atomix; + } + + public void setAtomix(AtomixClient atomix) { + this.atomix = atomix; + } + + public List<Address> getNodes() { + return nodes; + } + + public void setNodes(List<Address> nodes) { + this.nodes = nodes; + } + + public String getConfigurationUri() { + return configurationUri; + } + + public void setConfigurationUri(String configurationUri) { + this.configurationUri = configurationUri; + } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } + + public static class AtomixMessagingConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.atomix.client.messaging.AtomixMessagingConfiguration.class; + /** + * The default action. + */ + private Action defaultAction = Action.DIRECT; + /** + * The Atomix Group member name + */ + private String memberName; + /** + * The messaging channel name + */ + private String channelName; + /** + * The broadcast type. + */ + private BroadcastType broadcastType = BroadcastType.ALL; + /** + * The header that wil carry the result. + */ + private String resultHeader; + + public Action getDefaultAction() { + return defaultAction; + } + + public void setDefaultAction(Action defaultAction) { + this.defaultAction = defaultAction; + } + + public String getMemberName() { + return memberName; + } + + public void setMemberName(String memberName) { + this.memberName = memberName; + } + + public String getChannelName() { + return channelName; + } + + public void setChannelName(String channelName) { + this.channelName = channelName; + } + + public BroadcastType getBroadcastType() { + return broadcastType; + } + + public void setBroadcastType(BroadcastType broadcastType) { + this.broadcastType = broadcastType; + } + + public String getResultHeader() { + return resultHeader; + } + + public void setResultHeader(String resultHeader) { + this.resultHeader = resultHeader; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3756fba2/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/multimap/springboot/AtomixMultiMapComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/multimap/springboot/AtomixMultiMapComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/multimap/springboot/AtomixMultiMapComponentAutoConfiguration.java new file mode 100644 index 0000000..1e44ed0 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/multimap/springboot/AtomixMultiMapComponentAutoConfiguration.java @@ -0,0 +1,129 @@ +/** + * 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.atomix.client.multimap.springboot; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.atomix.client.multimap.AtomixMultiMapComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; +import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; +import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@Conditional({ConditionalOnCamelContextAndAutoConfigurationBeans.class, + AtomixMultiMapComponentAutoConfiguration.GroupConditions.class}) +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + AtomixMultiMapComponentConfiguration.class}) +public class AtomixMultiMapComponentAutoConfiguration { + + private static final Logger LOGGER = LoggerFactory + .getLogger(AtomixMultiMapComponentAutoConfiguration.class); + @Autowired + private ApplicationContext applicationContext; + @Autowired + private CamelContext camelContext; + @Autowired + private AtomixMultiMapComponentConfiguration configuration; + @Autowired(required = false) + private List<ComponentCustomizer<AtomixMultiMapComponent>> customizers; + + static class GroupConditions extends GroupCondition { + public GroupConditions() { + super("camel.component", "camel.component.atomix-multimap"); + } + } + + @Lazy + @Bean(name = "atomix-multimap-component") + @ConditionalOnMissingBean(AtomixMultiMapComponent.class) + public AtomixMultiMapComponent configureAtomixMultiMapComponent() + throws Exception { + AtomixMultiMapComponent component = new AtomixMultiMapComponent(); + 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); + if (ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<AtomixMultiMapComponent> customizer : customizers) { + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.atomix-multimap.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.atomix-multimap.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } + } + } + return component; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3756fba2/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/multimap/springboot/AtomixMultiMapComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/multimap/springboot/AtomixMultiMapComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/multimap/springboot/AtomixMultiMapComponentConfiguration.java new file mode 100644 index 0000000..79ce365 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/multimap/springboot/AtomixMultiMapComponentConfiguration.java @@ -0,0 +1,158 @@ +/** + * 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.atomix.client.multimap.springboot; + +import java.util.List; +import javax.annotation.Generated; +import io.atomix.AtomixClient; +import io.atomix.catalyst.transport.Address; +import org.apache.camel.component.atomix.client.multimap.AtomixMultiMap.Action; +import org.apache.camel.component.atomix.client.multimap.AtomixMultiMapComponent; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * Camel Atomix support + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.atomix-multimap") +public class AtomixMultiMapComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { + + /** + * The shared component configuration + */ + private AtomixMultiMapConfigurationNestedConfiguration configuration; + /** + * The shared AtomixClient instance + */ + @NestedConfigurationProperty + private AtomixClient atomix; + /** + * The nodes the AtomixClient should connect to + */ + private List<Address> nodes; + /** + * The path to the AtomixClient configuration + */ + private String configurationUri; + /** + * 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 AtomixMultiMapConfigurationNestedConfiguration getConfiguration() { + return configuration; + } + + public void setConfiguration( + AtomixMultiMapConfigurationNestedConfiguration configuration) { + this.configuration = configuration; + } + + public AtomixClient getAtomix() { + return atomix; + } + + public void setAtomix(AtomixClient atomix) { + this.atomix = atomix; + } + + public List<Address> getNodes() { + return nodes; + } + + public void setNodes(List<Address> nodes) { + this.nodes = nodes; + } + + public String getConfigurationUri() { + return configurationUri; + } + + public void setConfigurationUri(String configurationUri) { + this.configurationUri = configurationUri; + } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } + + public static class AtomixMultiMapConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.atomix.client.multimap.AtomixMultiMapConfiguration.class; + /** + * The default action. + */ + private Action defaultAction = Action.PUT; + /** + * The key to use if none is set in the header or to listen for events + * for a specific key. + */ + private Object key; + /** + * The resource ttl. + */ + private Long ttl; + /** + * The header that wil carry the result. + */ + private String resultHeader; + + public Action getDefaultAction() { + return defaultAction; + } + + public void setDefaultAction(Action defaultAction) { + this.defaultAction = defaultAction; + } + + public Object getKey() { + return key; + } + + public void setKey(Object key) { + this.key = key; + } + + public Long getTtl() { + return ttl; + } + + public void setTtl(Long ttl) { + this.ttl = ttl; + } + + public String getResultHeader() { + return resultHeader; + } + + public void setResultHeader(String resultHeader) { + this.resultHeader = resultHeader; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3756fba2/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/queue/springboot/AtomixQueueComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/queue/springboot/AtomixQueueComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/queue/springboot/AtomixQueueComponentAutoConfiguration.java new file mode 100644 index 0000000..cae94ce --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/queue/springboot/AtomixQueueComponentAutoConfiguration.java @@ -0,0 +1,129 @@ +/** + * 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.atomix.client.queue.springboot; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.atomix.client.queue.AtomixQueueComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; +import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; +import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@Conditional({ConditionalOnCamelContextAndAutoConfigurationBeans.class, + AtomixQueueComponentAutoConfiguration.GroupConditions.class}) +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + AtomixQueueComponentConfiguration.class}) +public class AtomixQueueComponentAutoConfiguration { + + private static final Logger LOGGER = LoggerFactory + .getLogger(AtomixQueueComponentAutoConfiguration.class); + @Autowired + private ApplicationContext applicationContext; + @Autowired + private CamelContext camelContext; + @Autowired + private AtomixQueueComponentConfiguration configuration; + @Autowired(required = false) + private List<ComponentCustomizer<AtomixQueueComponent>> customizers; + + static class GroupConditions extends GroupCondition { + public GroupConditions() { + super("camel.component", "camel.component.atomix-queue"); + } + } + + @Lazy + @Bean(name = "atomix-queue-component") + @ConditionalOnMissingBean(AtomixQueueComponent.class) + public AtomixQueueComponent configureAtomixQueueComponent() + throws Exception { + AtomixQueueComponent component = new AtomixQueueComponent(); + 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); + if (ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<AtomixQueueComponent> customizer : customizers) { + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.atomix-queue.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.atomix-queue.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } + } + } + return component; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3756fba2/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/queue/springboot/AtomixQueueComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/queue/springboot/AtomixQueueComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/queue/springboot/AtomixQueueComponentConfiguration.java new file mode 100644 index 0000000..5475e16 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/queue/springboot/AtomixQueueComponentConfiguration.java @@ -0,0 +1,133 @@ +/** + * 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.atomix.client.queue.springboot; + +import java.util.List; +import javax.annotation.Generated; +import io.atomix.AtomixClient; +import io.atomix.catalyst.transport.Address; +import org.apache.camel.component.atomix.client.queue.AtomixQueue.Action; +import org.apache.camel.component.atomix.client.queue.AtomixQueueComponent; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * Camel Atomix support + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.atomix-queue") +public class AtomixQueueComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { + + /** + * The shared component configuration + */ + private AtomixQueueConfigurationNestedConfiguration configuration; + /** + * The shared AtomixClient instance + */ + @NestedConfigurationProperty + private AtomixClient atomix; + /** + * The nodes the AtomixClient should connect to + */ + private List<Address> nodes; + /** + * The path to the AtomixClient configuration + */ + private String configurationUri; + /** + * 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 AtomixQueueConfigurationNestedConfiguration getConfiguration() { + return configuration; + } + + public void setConfiguration( + AtomixQueueConfigurationNestedConfiguration configuration) { + this.configuration = configuration; + } + + public AtomixClient getAtomix() { + return atomix; + } + + public void setAtomix(AtomixClient atomix) { + this.atomix = atomix; + } + + public List<Address> getNodes() { + return nodes; + } + + public void setNodes(List<Address> nodes) { + this.nodes = nodes; + } + + public String getConfigurationUri() { + return configurationUri; + } + + public void setConfigurationUri(String configurationUri) { + this.configurationUri = configurationUri; + } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } + + public static class AtomixQueueConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.atomix.client.queue.AtomixQueueConfiguration.class; + /** + * The default action. + */ + private Action defaultAction = Action.ADD; + /** + * The header that wil carry the result. + */ + private String resultHeader; + + public Action getDefaultAction() { + return defaultAction; + } + + public void setDefaultAction(Action defaultAction) { + this.defaultAction = defaultAction; + } + + public String getResultHeader() { + return resultHeader; + } + + public void setResultHeader(String resultHeader) { + this.resultHeader = resultHeader; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3756fba2/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/set/springboot/AtomixSetComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/set/springboot/AtomixSetComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/set/springboot/AtomixSetComponentAutoConfiguration.java new file mode 100644 index 0000000..a7b8685 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/set/springboot/AtomixSetComponentAutoConfiguration.java @@ -0,0 +1,128 @@ +/** + * 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.atomix.client.set.springboot; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.atomix.client.set.AtomixSetComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; +import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; +import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@Conditional({ConditionalOnCamelContextAndAutoConfigurationBeans.class, + AtomixSetComponentAutoConfiguration.GroupConditions.class}) +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + AtomixSetComponentConfiguration.class}) +public class AtomixSetComponentAutoConfiguration { + + private static final Logger LOGGER = LoggerFactory + .getLogger(AtomixSetComponentAutoConfiguration.class); + @Autowired + private ApplicationContext applicationContext; + @Autowired + private CamelContext camelContext; + @Autowired + private AtomixSetComponentConfiguration configuration; + @Autowired(required = false) + private List<ComponentCustomizer<AtomixSetComponent>> customizers; + + static class GroupConditions extends GroupCondition { + public GroupConditions() { + super("camel.component", "camel.component.atomix-set"); + } + } + + @Lazy + @Bean(name = "atomix-set-component") + @ConditionalOnMissingBean(AtomixSetComponent.class) + public AtomixSetComponent configureAtomixSetComponent() throws Exception { + AtomixSetComponent component = new AtomixSetComponent(); + 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); + if (ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<AtomixSetComponent> customizer : customizers) { + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.atomix-set.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.atomix-set.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } + } + } + return component; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3756fba2/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/set/springboot/AtomixSetComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/set/springboot/AtomixSetComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/set/springboot/AtomixSetComponentConfiguration.java new file mode 100644 index 0000000..de3fce6 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/set/springboot/AtomixSetComponentConfiguration.java @@ -0,0 +1,145 @@ +/** + * 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.atomix.client.set.springboot; + +import java.util.List; +import javax.annotation.Generated; +import io.atomix.AtomixClient; +import io.atomix.catalyst.transport.Address; +import org.apache.camel.component.atomix.client.set.AtomixSet.Action; +import org.apache.camel.component.atomix.client.set.AtomixSetComponent; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * Camel Atomix support + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.atomix-set") +public class AtomixSetComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { + + /** + * The shared component configuration + */ + private AtomixSetConfigurationNestedConfiguration configuration; + /** + * The shared AtomixClient instance + */ + @NestedConfigurationProperty + private AtomixClient atomix; + /** + * The nodes the AtomixClient should connect to + */ + private List<Address> nodes; + /** + * The path to the AtomixClient configuration + */ + private String configurationUri; + /** + * 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 AtomixSetConfigurationNestedConfiguration getConfiguration() { + return configuration; + } + + public void setConfiguration( + AtomixSetConfigurationNestedConfiguration configuration) { + this.configuration = configuration; + } + + public AtomixClient getAtomix() { + return atomix; + } + + public void setAtomix(AtomixClient atomix) { + this.atomix = atomix; + } + + public List<Address> getNodes() { + return nodes; + } + + public void setNodes(List<Address> nodes) { + this.nodes = nodes; + } + + public String getConfigurationUri() { + return configurationUri; + } + + public void setConfigurationUri(String configurationUri) { + this.configurationUri = configurationUri; + } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } + + public static class AtomixSetConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.atomix.client.set.AtomixSetConfiguration.class; + /** + * The default action. + */ + private Action defaultAction = Action.ADD; + /** + * The resource ttl. + */ + private Long ttl; + /** + * The header that wil carry the result. + */ + private String resultHeader; + + public Action getDefaultAction() { + return defaultAction; + } + + public void setDefaultAction(Action defaultAction) { + this.defaultAction = defaultAction; + } + + public Long getTtl() { + return ttl; + } + + public void setTtl(Long ttl) { + this.ttl = ttl; + } + + public String getResultHeader() { + return resultHeader; + } + + public void setResultHeader(String resultHeader) { + this.resultHeader = resultHeader; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3756fba2/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/value/springboot/AtomixValueComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/value/springboot/AtomixValueComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/value/springboot/AtomixValueComponentAutoConfiguration.java new file mode 100644 index 0000000..eb4da67 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/value/springboot/AtomixValueComponentAutoConfiguration.java @@ -0,0 +1,129 @@ +/** + * 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.atomix.client.value.springboot; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.atomix.client.value.AtomixValueComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; +import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; +import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@Conditional({ConditionalOnCamelContextAndAutoConfigurationBeans.class, + AtomixValueComponentAutoConfiguration.GroupConditions.class}) +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + AtomixValueComponentConfiguration.class}) +public class AtomixValueComponentAutoConfiguration { + + private static final Logger LOGGER = LoggerFactory + .getLogger(AtomixValueComponentAutoConfiguration.class); + @Autowired + private ApplicationContext applicationContext; + @Autowired + private CamelContext camelContext; + @Autowired + private AtomixValueComponentConfiguration configuration; + @Autowired(required = false) + private List<ComponentCustomizer<AtomixValueComponent>> customizers; + + static class GroupConditions extends GroupCondition { + public GroupConditions() { + super("camel.component", "camel.component.atomix-value"); + } + } + + @Lazy + @Bean(name = "atomix-value-component") + @ConditionalOnMissingBean(AtomixValueComponent.class) + public AtomixValueComponent configureAtomixValueComponent() + throws Exception { + AtomixValueComponent component = new AtomixValueComponent(); + 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); + if (ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<AtomixValueComponent> customizer : customizers) { + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.atomix-value.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.atomix-value.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } + } + } + return component; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3756fba2/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/value/springboot/AtomixValueComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/value/springboot/AtomixValueComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/value/springboot/AtomixValueComponentConfiguration.java new file mode 100644 index 0000000..6edc61d --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/java/org/apache/camel/component/atomix/client/value/springboot/AtomixValueComponentConfiguration.java @@ -0,0 +1,145 @@ +/** + * 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.atomix.client.value.springboot; + +import java.util.List; +import javax.annotation.Generated; +import io.atomix.AtomixClient; +import io.atomix.catalyst.transport.Address; +import org.apache.camel.component.atomix.client.value.AtomixValue.Action; +import org.apache.camel.component.atomix.client.value.AtomixValueComponent; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * Camel Atomix support + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.atomix-value") +public class AtomixValueComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { + + /** + * The shared component configuration + */ + private AtomixValueConfigurationNestedConfiguration configuration; + /** + * The shared AtomixClient instance + */ + @NestedConfigurationProperty + private AtomixClient atomix; + /** + * The nodes the AtomixClient should connect to + */ + private List<Address> nodes; + /** + * The path to the AtomixClient configuration + */ + private String configurationUri; + /** + * 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 AtomixValueConfigurationNestedConfiguration getConfiguration() { + return configuration; + } + + public void setConfiguration( + AtomixValueConfigurationNestedConfiguration configuration) { + this.configuration = configuration; + } + + public AtomixClient getAtomix() { + return atomix; + } + + public void setAtomix(AtomixClient atomix) { + this.atomix = atomix; + } + + public List<Address> getNodes() { + return nodes; + } + + public void setNodes(List<Address> nodes) { + this.nodes = nodes; + } + + public String getConfigurationUri() { + return configurationUri; + } + + public void setConfigurationUri(String configurationUri) { + this.configurationUri = configurationUri; + } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } + + public static class AtomixValueConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.atomix.client.value.AtomixValueConfiguration.class; + /** + * The default action. + */ + private Action defaultAction = Action.SET; + /** + * The resource ttl. + */ + private Long ttl; + /** + * The header that wil carry the result. + */ + private String resultHeader; + + public Action getDefaultAction() { + return defaultAction; + } + + public void setDefaultAction(Action defaultAction) { + this.defaultAction = defaultAction; + } + + public Long getTtl() { + return ttl; + } + + public void setTtl(Long ttl) { + this.ttl = ttl; + } + + public String getResultHeader() { + return resultHeader; + } + + public void setResultHeader(String resultHeader) { + this.resultHeader = resultHeader; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3756fba2/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/resources/META-INF/spring.factories ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/resources/META-INF/spring.factories index a0f99a3..c8186fd 100644 --- a/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/resources/META-INF/spring.factories +++ b/platforms/spring-boot/components-starter/camel-atomix-starter/src/main/resources/META-INF/spring.factories @@ -16,4 +16,26 @@ ## --------------------------------------------------------------------------- org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.camel.component.atomix.client.map.springboot.AtomixClientMapComponentAutoConfiguration +org.apache.camel.component.atomix.client.map.springboot.AtomixClientMapComponentAutoConfiguration,\ +org.apache.camel.component.atomix.client.multimap.springboot.AtomixClientMultiMapComponentAutoConfiguration,\ +org.apache.camel.component.atomix.client.set.springboot.AtomixClientSetComponentAutoConfiguration,\ +org.apache.camel.component.atomix.client.value.springboot.AtomixClientValueComponentAutoConfiguration,\ +org.apache.camel.component.atomix.client.queue.springboot.AtomixClientQueueComponentAutoConfiguration,\ +org.apache.camel.component.atomix.client.messaging.springboot.AtomixClientMessagingComponentAutoConfiguration,\ +org.apache.camel.component.atomix.client.set.springboot.AtomixSetComponentAutoConfiguration,\ +org.apache.camel.component.atomix.client.queue.springboot.AtomixQueueComponentAutoConfiguration,\ +org.apache.camel.component.atomix.client.map.springboot.AtomixMapComponentAutoConfiguration,\ +org.apache.camel.component.atomix.client.multimap.springboot.AtomixMultiMapComponentAutoConfiguration,\ +org.apache.camel.component.atomix.client.value.springboot.AtomixValueComponentAutoConfiguration,\ +org.apache.camel.component.atomix.client.messaging.springboot.AtomixMessagingComponentAutoConfiguration + + + + + + + + + + +