Skip to content

Commit 62cbc50

Browse files
authored
CAMEL-22756 - Create a Camel Stripe Starter for Spring Boot (#1587)
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
1 parent 86b9b27 commit 62cbc50

12 files changed

Lines changed: 574 additions & 7 deletions

File tree

catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ stitch
343343
stomp
344344
stream
345345
string-template
346+
stripe
346347
stub
347348
tahu-edge
348349
tahu-host
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"component": {
3+
"kind": "component",
4+
"name": "stripe",
5+
"title": "Stripe",
6+
"description": "Camel Stripe component",
7+
"deprecated": false,
8+
"firstVersion": "4.17.0",
9+
"label": "cloud",
10+
"javaType": "org.apache.camel.component.stripe.StripeComponent",
11+
"supportLevel": "Preview",
12+
"groupId": "org.apache.camel.springboot",
13+
"artifactId": "camel-stripe-starter",
14+
"version": "4.17.0-SNAPSHOT",
15+
"scheme": "stripe",
16+
"extendsScheme": "",
17+
"syntax": "stripe:operation",
18+
"async": false,
19+
"api": false,
20+
"consumerOnly": false,
21+
"producerOnly": true,
22+
"lenientProperties": false,
23+
"browsable": false,
24+
"remote": true
25+
},
26+
"componentProperties": {
27+
"lazyStartProducer": { "index": 0, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." },
28+
"apiBase": { "index": 1, "kind": "property", "displayName": "Api Base", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Override the default Stripe API base URL (for testing purposes)" },
29+
"autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." },
30+
"apiKey": { "index": 3, "kind": "property", "displayName": "Api Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "description": "The Stripe API key for authentication" }
31+
},
32+
"headers": {
33+
"CamelStripeOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform", "constantName": "org.apache.camel.component.stripe.StripeConstants#OPERATION_HEADER" },
34+
"CamelStripeMethod": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The method to invoke (create, retrieve, update, delete, list, cancel, capture)", "constantName": "org.apache.camel.component.stripe.StripeConstants#METHOD_HEADER" },
35+
"CamelStripeObjectId": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The ID of the object to retrieve, update, or delete", "constantName": "org.apache.camel.component.stripe.StripeConstants#OBJECT_ID" }
36+
},
37+
"properties": {
38+
"operation": { "index": 0, "kind": "path", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.stripe.StripeConfiguration", "configurationField": "configuration", "description": "The Stripe operation to perform" },
39+
"lazyStartProducer": { "index": 1, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." },
40+
"apiBase": { "index": 2, "kind": "parameter", "displayName": "Api Base", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.stripe.StripeConfiguration", "configurationField": "configuration", "description": "Override the default Stripe API base URL (for testing purposes)" },
41+
"apiKey": { "index": 3, "kind": "parameter", "displayName": "Api Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.stripe.StripeConfiguration", "configurationField": "configuration", "description": "The Stripe API key for authentication" }
42+
}
43+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<parent>
23+
<groupId>org.apache.camel.springboot</groupId>
24+
<artifactId>components-starter</artifactId>
25+
<version>4.17.0-SNAPSHOT</version>
26+
</parent>
27+
<artifactId>camel-stripe-starter</artifactId>
28+
<packaging>jar</packaging>
29+
<name>Camel SB Starters :: stripe</name>
30+
<dependencies>
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter</artifactId>
34+
<version>${spring-boot-version}</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.apache.camel</groupId>
38+
<artifactId>camel-stripe</artifactId>
39+
<version>${camel-version}</version>
40+
</dependency>
41+
<!--START OF GENERATED CODE-->
42+
<dependency>
43+
<groupId>org.apache.camel.springboot</groupId>
44+
<artifactId>camel-core-starter</artifactId>
45+
</dependency>
46+
<!--END OF GENERATED CODE-->
47+
</dependencies>
48+
</project>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"groups": [
3+
{
4+
"name": "camel.component.stripe",
5+
"type": "org.apache.camel.component.stripe.springboot.StripeComponentConfiguration",
6+
"sourceType": "org.apache.camel.component.stripe.springboot.StripeComponentConfiguration"
7+
},
8+
{
9+
"name": "camel.component.stripe.customizer",
10+
"type": "org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon$CustomizerProperties",
11+
"sourceType": "org.apache.camel.component.stripe.springboot.StripeComponentConfiguration",
12+
"sourceMethod": "getCustomizer()"
13+
}
14+
],
15+
"properties": [
16+
{
17+
"name": "camel.component.stripe.api-base",
18+
"type": "java.lang.String",
19+
"description": "Override the default Stripe API base URL (for testing purposes)",
20+
"sourceType": "org.apache.camel.component.stripe.springboot.StripeComponentConfiguration"
21+
},
22+
{
23+
"name": "camel.component.stripe.api-key",
24+
"type": "java.lang.String",
25+
"description": "The Stripe API key for authentication",
26+
"sourceType": "org.apache.camel.component.stripe.springboot.StripeComponentConfiguration"
27+
},
28+
{
29+
"name": "camel.component.stripe.autowired-enabled",
30+
"type": "java.lang.Boolean",
31+
"description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.",
32+
"sourceType": "org.apache.camel.component.stripe.springboot.StripeComponentConfiguration",
33+
"defaultValue": true
34+
},
35+
{
36+
"name": "camel.component.stripe.customizer.enabled",
37+
"type": "java.lang.Boolean",
38+
"sourceType": "org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon$CustomizerProperties"
39+
},
40+
{
41+
"name": "camel.component.stripe.enabled",
42+
"type": "java.lang.Boolean",
43+
"description": "Whether to enable auto configuration of the stripe component. This is enabled by default.",
44+
"sourceType": "org.apache.camel.component.stripe.springboot.StripeComponentConfiguration"
45+
},
46+
{
47+
"name": "camel.component.stripe.lazy-start-producer",
48+
"type": "java.lang.Boolean",
49+
"description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.",
50+
"sourceType": "org.apache.camel.component.stripe.springboot.StripeComponentConfiguration",
51+
"defaultValue": false
52+
}
53+
],
54+
"hints": [],
55+
"ignored": {
56+
"properties": []
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel.component.stripe.springboot;
18+
19+
import org.apache.camel.CamelContext;
20+
import org.apache.camel.Component;
21+
import org.apache.camel.component.stripe.StripeComponent;
22+
import org.apache.camel.spi.ComponentCustomizer;
23+
import org.apache.camel.spring.boot.CamelAutoConfiguration;
24+
import org.apache.camel.spring.boot.ComponentConfigurationProperties;
25+
import org.apache.camel.spring.boot.util.CamelPropertiesHelper;
26+
import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans;
27+
import org.apache.camel.spring.boot.util.ConditionalOnHierarchicalProperties;
28+
import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator;
29+
import org.springframework.beans.factory.annotation.Autowired;
30+
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
31+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
32+
import org.springframework.context.ApplicationContext;
33+
import org.springframework.context.annotation.Bean;
34+
import org.springframework.context.annotation.Conditional;
35+
import org.springframework.context.annotation.Configuration;
36+
import org.springframework.context.annotation.Lazy;
37+
38+
/**
39+
* Generated by camel-package-maven-plugin - do not edit this file!
40+
*/
41+
@Configuration(proxyBeanMethods = false)
42+
@Conditional(ConditionalOnCamelContextAndAutoConfigurationBeans.class)
43+
@EnableConfigurationProperties({ComponentConfigurationProperties.class,StripeComponentConfiguration.class})
44+
@ConditionalOnHierarchicalProperties({"camel.component", "camel.component.stripe"})
45+
@AutoConfigureAfter(CamelAutoConfiguration.class)
46+
public class StripeComponentAutoConfiguration {
47+
48+
@Autowired
49+
private ApplicationContext applicationContext;
50+
private final CamelContext camelContext;
51+
@Autowired
52+
private StripeComponentConfiguration configuration;
53+
54+
public StripeComponentAutoConfiguration(
55+
org.apache.camel.CamelContext camelContext) {
56+
this.camelContext = camelContext;
57+
}
58+
59+
@Lazy
60+
@Bean
61+
public ComponentCustomizer configureStripeComponent() {
62+
return new ComponentCustomizer() {
63+
@Override
64+
public void configure(String name, Component target) {
65+
CamelPropertiesHelper.copyProperties(camelContext, configuration, target);
66+
}
67+
@Override
68+
public boolean isEnabled(String name, Component target) {
69+
return HierarchicalPropertiesEvaluator.evaluate(
70+
applicationContext,
71+
"camel.component.customizer",
72+
"camel.component.stripe.customizer")
73+
&& target instanceof StripeComponent;
74+
}
75+
};
76+
}
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel.component.stripe.springboot;
18+
19+
import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
20+
import org.springframework.boot.context.properties.ConfigurationProperties;
21+
22+
/**
23+
* Camel Stripe component
24+
*
25+
* Generated by camel-package-maven-plugin - do not edit this file!
26+
*/
27+
@ConfigurationProperties(prefix = "camel.component.stripe")
28+
public class StripeComponentConfiguration
29+
extends
30+
ComponentConfigurationPropertiesCommon {
31+
32+
/**
33+
* Whether to enable auto configuration of the stripe component. This is
34+
* enabled by default.
35+
*/
36+
private Boolean enabled;
37+
/**
38+
* Whether the producer should be started lazy (on the first message). By
39+
* starting lazy you can use this to allow CamelContext and routes to
40+
* startup in situations where a producer may otherwise fail during starting
41+
* and cause the route to fail being started. By deferring this startup to
42+
* be lazy then the startup failure can be handled during routing messages
43+
* via Camel's routing error handlers. Beware that when the first message is
44+
* processed then creating and starting the producer may take a little time
45+
* and prolong the total processing time of the processing.
46+
*/
47+
private Boolean lazyStartProducer = false;
48+
/**
49+
* Override the default Stripe API base URL (for testing purposes)
50+
*/
51+
private String apiBase;
52+
/**
53+
* Whether autowiring is enabled. This is used for automatic autowiring
54+
* options (the option must be marked as autowired) by looking up in the
55+
* registry to find if there is a single instance of matching type, which
56+
* then gets configured on the component. This can be used for automatic
57+
* configuring JDBC data sources, JMS connection factories, AWS Clients,
58+
* etc.
59+
*/
60+
private Boolean autowiredEnabled = true;
61+
/**
62+
* The Stripe API key for authentication
63+
*/
64+
private String apiKey;
65+
66+
public Boolean getLazyStartProducer() {
67+
return lazyStartProducer;
68+
}
69+
70+
public void setLazyStartProducer(Boolean lazyStartProducer) {
71+
this.lazyStartProducer = lazyStartProducer;
72+
}
73+
74+
public String getApiBase() {
75+
return apiBase;
76+
}
77+
78+
public void setApiBase(String apiBase) {
79+
this.apiBase = apiBase;
80+
}
81+
82+
public Boolean getAutowiredEnabled() {
83+
return autowiredEnabled;
84+
}
85+
86+
public void setAutowiredEnabled(Boolean autowiredEnabled) {
87+
this.autowiredEnabled = autowiredEnabled;
88+
}
89+
90+
public String getApiKey() {
91+
return apiKey;
92+
}
93+
94+
public void setApiKey(String apiKey) {
95+
this.apiKey = apiKey;
96+
}
97+
}

0 commit comments

Comments
 (0)