http://git-wip-us.apache.org/repos/asf/camel/blob/bb64dca0/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/search/springboot/TwitterSearchComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/search/springboot/TwitterSearchComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/search/springboot/TwitterSearchComponentAutoConfiguration.java new file mode 100644 index 0000000..f78e44c --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/search/springboot/TwitterSearchComponentAutoConfiguration.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.twitter.search.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.twitter.search.TwitterSearchComponent; +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, + TwitterSearchComponentAutoConfiguration.GroupConditions.class}) +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + TwitterSearchComponentConfiguration.class}) +public class TwitterSearchComponentAutoConfiguration { + + private static final Logger LOGGER = LoggerFactory + .getLogger(TwitterSearchComponentAutoConfiguration.class); + @Autowired + private ApplicationContext applicationContext; + @Autowired + private CamelContext camelContext; + @Autowired + private TwitterSearchComponentConfiguration configuration; + @Autowired(required = false) + private List<ComponentCustomizer<TwitterSearchComponent>> customizers; + + static class GroupConditions extends GroupCondition { + public GroupConditions() { + super("camel.component", "camel.component.twitter-search"); + } + } + + @Lazy + @Bean(name = "twitter-search-component") + @ConditionalOnMissingBean(TwitterSearchComponent.class) + public TwitterSearchComponent configureTwitterSearchComponent() + throws Exception { + TwitterSearchComponent component = new TwitterSearchComponent(); + 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<TwitterSearchComponent> customizer : customizers) { + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.twitter-search.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.twitter-search.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/bb64dca0/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/search/springboot/TwitterSearchComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/search/springboot/TwitterSearchComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/search/springboot/TwitterSearchComponentConfiguration.java new file mode 100644 index 0000000..8d89f17 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/search/springboot/TwitterSearchComponentConfiguration.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.twitter.search.springboot; + +import javax.annotation.Generated; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * The Twitter Search component consumes search results. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.twitter-search") +public class TwitterSearchComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { + + /** + * The access token + */ + private String accessToken; + /** + * The access token secret + */ + private String accessTokenSecret; + /** + * The consumer key + */ + private String consumerKey; + /** + * The consumer secret + */ + private String consumerSecret; + /** + * The http proxy host which can be used for the camel-twitter. + */ + private String httpProxyHost; + /** + * The http proxy user which can be used for the camel-twitter. + */ + private String httpProxyUser; + /** + * The http proxy password which can be used for the camel-twitter. + */ + private String httpProxyPassword; + /** + * The http proxy port which can be used for the camel-twitter. + */ + private Integer httpProxyPort; + /** + * 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 String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public String getAccessTokenSecret() { + return accessTokenSecret; + } + + public void setAccessTokenSecret(String accessTokenSecret) { + this.accessTokenSecret = accessTokenSecret; + } + + public String getConsumerKey() { + return consumerKey; + } + + public void setConsumerKey(String consumerKey) { + this.consumerKey = consumerKey; + } + + public String getConsumerSecret() { + return consumerSecret; + } + + public void setConsumerSecret(String consumerSecret) { + this.consumerSecret = consumerSecret; + } + + public String getHttpProxyHost() { + return httpProxyHost; + } + + public void setHttpProxyHost(String httpProxyHost) { + this.httpProxyHost = httpProxyHost; + } + + public String getHttpProxyUser() { + return httpProxyUser; + } + + public void setHttpProxyUser(String httpProxyUser) { + this.httpProxyUser = httpProxyUser; + } + + public String getHttpProxyPassword() { + return httpProxyPassword; + } + + public void setHttpProxyPassword(String httpProxyPassword) { + this.httpProxyPassword = httpProxyPassword; + } + + public Integer getHttpProxyPort() { + return httpProxyPort; + } + + public void setHttpProxyPort(Integer httpProxyPort) { + this.httpProxyPort = httpProxyPort; + } + + 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/bb64dca0/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentConfiguration.java index 1a0baa6..a3f7991 100644 --- a/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentConfiguration.java @@ -21,8 +21,8 @@ import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; /** - * This component integrates with Twitter to send tweets or search for tweets - * and more. + * Use twitter-directmessage twitter-search twitter-streaming and + * twitter-timeline instead of this component. * * Generated by camel-package-maven-plugin - do not edit this file! */ http://git-wip-us.apache.org/repos/asf/camel/blob/bb64dca0/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/streaming/springboot/TwitterStreamingComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/streaming/springboot/TwitterStreamingComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/streaming/springboot/TwitterStreamingComponentAutoConfiguration.java new file mode 100644 index 0000000..2dfa3d9 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/streaming/springboot/TwitterStreamingComponentAutoConfiguration.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.twitter.streaming.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.twitter.streaming.TwitterStreamingComponent; +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, + TwitterStreamingComponentAutoConfiguration.GroupConditions.class}) +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + TwitterStreamingComponentConfiguration.class}) +public class TwitterStreamingComponentAutoConfiguration { + + private static final Logger LOGGER = LoggerFactory + .getLogger(TwitterStreamingComponentAutoConfiguration.class); + @Autowired + private ApplicationContext applicationContext; + @Autowired + private CamelContext camelContext; + @Autowired + private TwitterStreamingComponentConfiguration configuration; + @Autowired(required = false) + private List<ComponentCustomizer<TwitterStreamingComponent>> customizers; + + static class GroupConditions extends GroupCondition { + public GroupConditions() { + super("camel.component", "camel.component.twitter-streaming"); + } + } + + @Lazy + @Bean(name = "twitter-streaming-component") + @ConditionalOnMissingBean(TwitterStreamingComponent.class) + public TwitterStreamingComponent configureTwitterStreamingComponent() + throws Exception { + TwitterStreamingComponent component = new TwitterStreamingComponent(); + 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<TwitterStreamingComponent> customizer : customizers) { + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.twitter-streaming.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.twitter-streaming.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/bb64dca0/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/streaming/springboot/TwitterStreamingComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/streaming/springboot/TwitterStreamingComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/streaming/springboot/TwitterStreamingComponentConfiguration.java new file mode 100644 index 0000000..683c392 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/streaming/springboot/TwitterStreamingComponentConfiguration.java @@ -0,0 +1,146 @@ +/** + * 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.twitter.streaming.springboot; + +import javax.annotation.Generated; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * The Twitter Streaming component consumes twitter statuses using Streaming + * API. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.twitter-streaming") +public class TwitterStreamingComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { + + /** + * The access token + */ + private String accessToken; + /** + * The access token secret + */ + private String accessTokenSecret; + /** + * The consumer key + */ + private String consumerKey; + /** + * The consumer secret + */ + private String consumerSecret; + /** + * The http proxy host which can be used for the camel-twitter. + */ + private String httpProxyHost; + /** + * The http proxy user which can be used for the camel-twitter. + */ + private String httpProxyUser; + /** + * The http proxy password which can be used for the camel-twitter. + */ + private String httpProxyPassword; + /** + * The http proxy port which can be used for the camel-twitter. + */ + private Integer httpProxyPort; + /** + * 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 String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public String getAccessTokenSecret() { + return accessTokenSecret; + } + + public void setAccessTokenSecret(String accessTokenSecret) { + this.accessTokenSecret = accessTokenSecret; + } + + public String getConsumerKey() { + return consumerKey; + } + + public void setConsumerKey(String consumerKey) { + this.consumerKey = consumerKey; + } + + public String getConsumerSecret() { + return consumerSecret; + } + + public void setConsumerSecret(String consumerSecret) { + this.consumerSecret = consumerSecret; + } + + public String getHttpProxyHost() { + return httpProxyHost; + } + + public void setHttpProxyHost(String httpProxyHost) { + this.httpProxyHost = httpProxyHost; + } + + public String getHttpProxyUser() { + return httpProxyUser; + } + + public void setHttpProxyUser(String httpProxyUser) { + this.httpProxyUser = httpProxyUser; + } + + public String getHttpProxyPassword() { + return httpProxyPassword; + } + + public void setHttpProxyPassword(String httpProxyPassword) { + this.httpProxyPassword = httpProxyPassword; + } + + public Integer getHttpProxyPort() { + return httpProxyPort; + } + + public void setHttpProxyPort(Integer httpProxyPort) { + this.httpProxyPort = httpProxyPort; + } + + 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/bb64dca0/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/timeline/springboot/TwitterTimelineComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/timeline/springboot/TwitterTimelineComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/timeline/springboot/TwitterTimelineComponentAutoConfiguration.java new file mode 100644 index 0000000..5d6d381 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/timeline/springboot/TwitterTimelineComponentAutoConfiguration.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.twitter.timeline.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.twitter.timeline.TwitterTimelineComponent; +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, + TwitterTimelineComponentAutoConfiguration.GroupConditions.class}) +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + TwitterTimelineComponentConfiguration.class}) +public class TwitterTimelineComponentAutoConfiguration { + + private static final Logger LOGGER = LoggerFactory + .getLogger(TwitterTimelineComponentAutoConfiguration.class); + @Autowired + private ApplicationContext applicationContext; + @Autowired + private CamelContext camelContext; + @Autowired + private TwitterTimelineComponentConfiguration configuration; + @Autowired(required = false) + private List<ComponentCustomizer<TwitterTimelineComponent>> customizers; + + static class GroupConditions extends GroupCondition { + public GroupConditions() { + super("camel.component", "camel.component.twitter-timeline"); + } + } + + @Lazy + @Bean(name = "twitter-timeline-component") + @ConditionalOnMissingBean(TwitterTimelineComponent.class) + public TwitterTimelineComponent configureTwitterTimelineComponent() + throws Exception { + TwitterTimelineComponent component = new TwitterTimelineComponent(); + 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<TwitterTimelineComponent> customizer : customizers) { + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.twitter-timeline.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.twitter-timeline.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/bb64dca0/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/timeline/springboot/TwitterTimelineComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/timeline/springboot/TwitterTimelineComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/timeline/springboot/TwitterTimelineComponentConfiguration.java new file mode 100644 index 0000000..375c226 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/timeline/springboot/TwitterTimelineComponentConfiguration.java @@ -0,0 +1,146 @@ +/** + * 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.twitter.timeline.springboot; + +import javax.annotation.Generated; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * The Twitter Timeline component consumes twitter timeline or update the status + * of specific user. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.twitter-timeline") +public class TwitterTimelineComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { + + /** + * The access token + */ + private String accessToken; + /** + * The access token secret + */ + private String accessTokenSecret; + /** + * The consumer key + */ + private String consumerKey; + /** + * The consumer secret + */ + private String consumerSecret; + /** + * The http proxy host which can be used for the camel-twitter. + */ + private String httpProxyHost; + /** + * The http proxy user which can be used for the camel-twitter. + */ + private String httpProxyUser; + /** + * The http proxy password which can be used for the camel-twitter. + */ + private String httpProxyPassword; + /** + * The http proxy port which can be used for the camel-twitter. + */ + private Integer httpProxyPort; + /** + * 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 String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public String getAccessTokenSecret() { + return accessTokenSecret; + } + + public void setAccessTokenSecret(String accessTokenSecret) { + this.accessTokenSecret = accessTokenSecret; + } + + public String getConsumerKey() { + return consumerKey; + } + + public void setConsumerKey(String consumerKey) { + this.consumerKey = consumerKey; + } + + public String getConsumerSecret() { + return consumerSecret; + } + + public void setConsumerSecret(String consumerSecret) { + this.consumerSecret = consumerSecret; + } + + public String getHttpProxyHost() { + return httpProxyHost; + } + + public void setHttpProxyHost(String httpProxyHost) { + this.httpProxyHost = httpProxyHost; + } + + public String getHttpProxyUser() { + return httpProxyUser; + } + + public void setHttpProxyUser(String httpProxyUser) { + this.httpProxyUser = httpProxyUser; + } + + public String getHttpProxyPassword() { + return httpProxyPassword; + } + + public void setHttpProxyPassword(String httpProxyPassword) { + this.httpProxyPassword = httpProxyPassword; + } + + public Integer getHttpProxyPort() { + return httpProxyPort; + } + + public void setHttpProxyPort(Integer httpProxyPort) { + this.httpProxyPort = httpProxyPort; + } + + 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/bb64dca0/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/resources/META-INF/spring.factories ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/resources/META-INF/spring.factories index fdac1c5..79e7484 100644 --- a/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/resources/META-INF/spring.factories +++ b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/resources/META-INF/spring.factories @@ -15,4 +15,12 @@ ## limitations under the License. ## --------------------------------------------------------------------------- org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.camel.component.twitter.springboot.TwitterComponentAutoConfiguration +org.apache.camel.component.twitter.springboot.TwitterComponentAutoConfiguration,\ +org.apache.camel.component.twitter.timeline.springboot.TwitterTimelineComponentAutoConfiguration,\ +org.apache.camel.component.twitter.search.springboot.TwitterSearchComponentAutoConfiguration,\ +org.apache.camel.component.twitter.directmessage.springboot.TwitterDirectMessageComponentAutoConfiguration,\ +org.apache.camel.component.twitter.streaming.springboot.TwitterStreamingComponentAutoConfiguration + + + +