You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/12/10 09:49:45 UTC
[camel-quarkus] branch master updated: Add SQL component extension
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new 546fe67 Add SQL component extension
new 97df21d Merge pull request #533 from jamesnetherton/sql-extension
546fe67 is described below
commit 546fe6723d7f301bf71b3fd11a19345aa25d8e35
Author: James Netherton <ja...@gmail.com>
AuthorDate: Tue Dec 10 07:50:57 2019 +0000
Add SQL component extension
fixes #505
---
docs/modules/ROOT/pages/extensions/sql.adoc | 29 +++++
.../pages/list-of-camel-quarkus-extensions.adoc | 8 +-
extensions/pom.xml | 1 +
extensions/readme.adoc | 8 +-
extensions/sql/deployment/pom.xml | 84 +++++++++++++
.../component/sql/deployment/SqlProcessor.java | 68 ++++++++++
extensions/sql/pom.xml | 39 ++++++
extensions/sql/runtime/pom.xml | 108 ++++++++++++++++
.../quarkus/component/sql/CamelSqlConfig.java | 33 +++++
.../component/sql/graal/SpringSubstitutions.java | 129 +++++++++++++++++++
.../main/resources/META-INF/quarkus-extension.yaml | 28 +++++
integration-tests/pom.xml | 1 +
integration-tests/sql/pom.xml | 137 +++++++++++++++++++++
.../quarkus/component/sql/it/SqlResource.java | 112 +++++++++++++++++
.../it/storedproc/NumberAddStoredProcedure.java | 24 ++++
.../sql/src/main/resources/application.properties | 34 +++++
.../sql/src/main/resources/sql/get-camels.sql | 18 +++
.../camel/quarkus/component/sql/it/SqlIT.java | 24 ++++
.../camel/quarkus/component/sql/it/SqlTest.java | 60 +++++++++
poms/bom-deployment/pom.xml | 5 +
poms/bom/pom.xml | 10 ++
21 files changed, 958 insertions(+), 2 deletions(-)
diff --git a/docs/modules/ROOT/pages/extensions/sql.adoc b/docs/modules/ROOT/pages/extensions/sql.adoc
new file mode 100644
index 0000000..49cedfe
--- /dev/null
+++ b/docs/modules/ROOT/pages/extensions/sql.adoc
@@ -0,0 +1,29 @@
+[[sql]]
+= SQL Extension
+
+*Since Camel Quarkus 1.1.0*
+
+The SQL component allows you to work with databases using JDBC queries.
+
+Maven users will need to add the following dependency to their `pom.xml` for this extension.
+
+[source,xml]
+------------------------------------------------------------
+<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-sql</artifactId>
+</dependency>
+------------------------------------------------------------
+
+== Usage
+
+The extension provides support for the Camel https://camel.apache.org/components/latest/sql-component.html[SQL Component].
+
+=== Configuration
+
+When configuring `sql` or `sql-stored` endpoints to reference script files from the classpath, set the following configuration property to ensure that they are available in native mode.
+
+[source,properties]
+----
+quarkus.camel.sql.script-files = queries.sql, classpath:sql/insert.sql
+----
diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
index e4266af..17e3b51 100644
--- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
+++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
@@ -6,7 +6,7 @@ As of Camel Quarkus {camel-quarkus-last-release} the following Camel artifacts a
== Camel Components
// components: START
-Number of Camel components: 49 in 42 JAR artifacts (0 deprecated)
+Number of Camel components: 51 in 43 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -138,6 +138,12 @@ Number of Camel components: 49 in 42 JAR artifacts (0 deprecated)
| link:https://camel.apache.org/components/latest/slack-component.html[Slack] (camel-quarkus-slack) +
`slack:channel` | 0.3.0 | The slack component allows you to send messages to Slack.
+| xref:extensions/sql.adoc[SQL] (camel-quarkus-sql) +
+`sql:query` | 1.1.0 | The sql component allows you to work with databases using JDBC SQL queries.
+
+| xref:extensions/sql.adoc[SQL Stored Procedure] (camel-quarkus-sql) +
+`sql-stored:template` | 1.1.0 | The sql component allows you to work with databases using JDBC Stored Procedure queries.
+
| link:https://camel.apache.org/components/latest/timer-component.html[Timer] (camel-quarkus-timer) +
`timer:timerName` | 0.2.0 | The timer component is used for generating message exchanges when a timer fires.
diff --git a/extensions/pom.xml b/extensions/pom.xml
index ace5549..06ffb38 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -88,6 +88,7 @@
<module>sjms2</module>
<module>slack</module>
<module>snakeyaml</module>
+ <module>sql</module>
<module>tagsoup</module>
<module>tarfile</module>
<module>timer</module>
diff --git a/extensions/readme.adoc b/extensions/readme.adoc
index 6dae093..aa43ae0 100644
--- a/extensions/readme.adoc
+++ b/extensions/readme.adoc
@@ -5,7 +5,7 @@ Apache Camel Quarkus supports the following Camel artifacts as Quarkus Extension
== Camel Components
// components: START
-Number of Camel components: 49 in 42 JAR artifacts (0 deprecated)
+Number of Camel components: 51 in 43 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -137,6 +137,12 @@ Number of Camel components: 49 in 42 JAR artifacts (0 deprecated)
| link:https://camel.apache.org/components/latest/slack-component.html[Slack] (camel-quarkus-slack) +
`slack:channel` | 0.3.0 | The slack component allows you to send messages to Slack.
+| xref:extensions/sql.adoc[SQL] (camel-quarkus-sql) +
+`sql:query` | 1.1.0 | The sql component allows you to work with databases using JDBC SQL queries.
+
+| xref:extensions/sql.adoc[SQL Stored Procedure] (camel-quarkus-sql) +
+`sql-stored:template` | 1.1.0 | The sql component allows you to work with databases using JDBC Stored Procedure queries.
+
| link:https://camel.apache.org/components/latest/timer-component.html[Timer] (camel-quarkus-timer) +
`timer:timerName` | 0.2.0 | The timer component is used for generating message exchanges when a timer fires.
diff --git a/extensions/sql/deployment/pom.xml b/extensions/sql/deployment/pom.xml
new file mode 100644
index 0000000..9349ac6
--- /dev/null
+++ b/extensions/sql/deployment/pom.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-sql-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-sql-deployment</artifactId>
+ <name>Camel Quarkus :: SQL :: Deployment</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-agroal-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-narayana-jta-deployment</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-sql</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/extensions/sql/deployment/src/main/java/org/apache/camel/quarkus/component/sql/deployment/SqlProcessor.java b/extensions/sql/deployment/src/main/java/org/apache/camel/quarkus/component/sql/deployment/SqlProcessor.java
new file mode 100644
index 0000000..f5f4232
--- /dev/null
+++ b/extensions/sql/deployment/src/main/java/org/apache/camel/quarkus/component/sql/deployment/SqlProcessor.java
@@ -0,0 +1,68 @@
+/*
+ * 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.quarkus.component.sql.deployment;
+
+import io.quarkus.deployment.GizmoAdaptor;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.GeneratedClassBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.pkg.steps.NativeBuild;
+import io.quarkus.gizmo.ClassCreator;
+import io.quarkus.gizmo.ClassOutput;
+
+import java.sql.Types;
+
+import org.apache.camel.quarkus.component.sql.CamelSqlConfig;
+
+class SqlProcessor {
+
+ private static final String FEATURE = "camel-sql";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
+ reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, Types.class));
+ }
+
+ @BuildStep
+ void sqlNativeImageResources(BuildProducer<NativeImageResourceBuildItem> nativeImage, CamelSqlConfig config) {
+ config.scriptFiles
+ .stream()
+ .map(scriptFile -> new NativeImageResourceBuildItem(scriptFile.replace("classpath:", "")))
+ .forEach(nativeImage::produce);
+ }
+
+ @BuildStep(onlyIf = NativeBuild.class)
+ void generateKParameterClass(BuildProducer<GeneratedClassBuildItem> generatedClass) {
+ // TODO: The native image build fails with a NoClassDefFoundError without this. Possibly similar to https://github.com/oracle/graal/issues/656.
+ ClassOutput classOutput = new GizmoAdaptor(generatedClass, false);
+ ClassCreator.builder()
+ .className("kotlin.reflect.KParameter")
+ .classOutput(classOutput)
+ .setFinal(true)
+ .superClass(Object.class)
+ .build()
+ .close();
+ }
+}
diff --git a/extensions/sql/pom.xml b/extensions/sql/pom.xml
new file mode 100644
index 0000000..88cb91b
--- /dev/null
+++ b/extensions/sql/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-sql-parent</artifactId>
+ <name>Camel Quarkus :: SQL</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions/sql/runtime/pom.xml b/extensions/sql/runtime/pom.xml
new file mode 100644
index 0000000..fe01ab2
--- /dev/null
+++ b/extensions/sql/runtime/pom.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-sql-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-sql</artifactId>
+ <name>Camel Quarkus :: SQL :: Runtime</name>
+
+ <properties>
+ <firstVersion>1.1.0</firstVersion>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-sql</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-agroal</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-narayana-jta</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.security.jacc</groupId>
+ <artifactId>jakarta.security.jacc-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>commons-logging-jboss-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.oracle.substratevm</groupId>
+ <artifactId>svm</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-bootstrap-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/extensions/sql/runtime/src/main/java/org/apache/camel/quarkus/component/sql/CamelSqlConfig.java b/extensions/sql/runtime/src/main/java/org/apache/camel/quarkus/component/sql/CamelSqlConfig.java
new file mode 100644
index 0000000..521581b
--- /dev/null
+++ b/extensions/sql/runtime/src/main/java/org/apache/camel/quarkus/component/sql/CamelSqlConfig.java
@@ -0,0 +1,33 @@
+/*
+ * 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.quarkus.component.sql;
+
+import io.quarkus.runtime.annotations.ConfigItem;
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
+
+import java.util.List;
+
+@ConfigRoot(name = "camel.sql", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
+public class CamelSqlConfig {
+
+ /**
+ * A comma separated list of paths to script files referenced by SQL endpoints.
+ */
+ @ConfigItem
+ public List<String> scriptFiles;
+}
diff --git a/extensions/sql/runtime/src/main/java/org/apache/camel/quarkus/component/sql/graal/SpringSubstitutions.java b/extensions/sql/runtime/src/main/java/org/apache/camel/quarkus/component/sql/graal/SpringSubstitutions.java
new file mode 100644
index 0000000..98df1b0
--- /dev/null
+++ b/extensions/sql/runtime/src/main/java/org/apache/camel/quarkus/component/sql/graal/SpringSubstitutions.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.quarkus.component.sql.graal;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.net.URI;
+import java.net.URL;
+import java.util.Set;
+
+import com.oracle.svm.core.annotate.Alias;
+import com.oracle.svm.core.annotate.Delete;
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+
+import org.springframework.core.MethodParameter;
+import org.springframework.core.io.Resource;
+import org.springframework.util.PathMatcher;
+
+final class SpringSubstitutions {
+}
+
+@TargetClass(className = "org.springframework.core.DefaultParameterNameDiscoverer")
+final class SubstituteDefaultParameterNameDiscoverer {
+
+ @Alias
+ public SubstituteDefaultParameterNameDiscoverer() {
+ // Discoverers are not meant to be registered on graal
+ }
+}
+
+@TargetClass(className = "org.springframework.core.KotlinReflectionParameterNameDiscoverer")
+@Delete
+final class SubstituteKotlinReflectionParameterNameDiscoverer {
+
+}
+
+@TargetClass(className = "org.springframework.core.StandardReflectionParameterNameDiscoverer")
+@Delete
+final class SubstituteStandardReflectionParameterNameDiscoverer {
+
+}
+
+@TargetClass(className = "org.springframework.core.LocalVariableTableParameterNameDiscoverer")
+@Delete
+final class SubstituteLocalVariableTableParameterNameDiscoverer {
+
+}
+
+@TargetClass(className = "org.springframework.beans.BeanUtils$KotlinDelegate")
+final class SubstituteBeanUtilsKotlinDelegate {
+
+ @Substitute
+ public static <T> Constructor<T> findPrimaryConstructor(Class<T> clazz) {
+ throw new UnsupportedOperationException("Kotlin is not supported");
+ }
+
+ @Substitute
+ public static <T> T instantiateClass(Constructor<T> ctor, Object... args)
+ throws IllegalAccessException, InvocationTargetException, InstantiationException {
+ throw new UnsupportedOperationException("Kotlin is not supported");
+ }
+}
+
+@TargetClass(className = "org.springframework.core.MethodParameter$KotlinDelegate")
+final class SubstituteMethodParameterKotlinDelegate {
+
+ @Substitute
+ public static boolean isOptional(MethodParameter param) {
+ throw new UnsupportedOperationException("Kotlin is not supported");
+ }
+
+ @Substitute
+ static private Type getGenericReturnType(Method method) {
+ throw new UnsupportedOperationException("Kotlin is not supported");
+ }
+
+ @Substitute
+ private static Class<?> getReturnType(Method method) {
+ throw new UnsupportedOperationException("Kotlin is not supported");
+ }
+}
+
+@TargetClass(className = "org.springframework.core.io.VfsUtils")
+@Delete
+final class SubstituteVfsUtils {
+
+}
+
+@TargetClass(className = "org.springframework.core.io.AbstractFileResolvingResource$VfsResourceDelegate")
+final class SubstituteVfsResourceDelegate {
+
+ @Substitute
+ public static Resource getResource(URL url) throws IOException {
+ throw new UnsupportedOperationException("VFS resources are not supported");
+ }
+
+ @Substitute
+ public static Resource getResource(URI uri) throws IOException {
+ throw new UnsupportedOperationException("VFS resources are not supported");
+ }
+}
+
+@TargetClass(className = "org.springframework.core.io.support.PathMatchingResourcePatternResolver$VfsResourceMatchingDelegate")
+final class SubstituteVfsResourceMatchingDelegate {
+
+ @Substitute
+ public static Set<Resource> findMatchingResources(
+ URL rootDirURL, String locationPattern, PathMatcher pathMatcher) throws IOException {
+ throw new UnsupportedOperationException("VFS resources are not supported");
+ }
+}
diff --git a/extensions/sql/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/sql/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 0000000..62119cf
--- /dev/null
+++ b/extensions/sql/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+
+---
+name: "Camel Quarkus SQL"
+description: "Camel SQL support"
+metadata:
+ keywords:
+ - "camel"
+ - "sql"
+ - "database"
+ guide: "https://quarkus.io/guides/camel"
+ categories:
+ - "integration"
\ No newline at end of file
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 7d71a17..8439491 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -179,6 +179,7 @@
<module>sjms</module>
<module>slack</module>
<module>snakeyaml</module>
+ <module>sql</module>
<module>tagsoup</module>
<module>tarfile</module>
<module>twitter</module>
diff --git a/integration-tests/sql/pom.xml b/integration-tests/sql/pom.xml
new file mode 100644
index 0000000..047a53a
--- /dev/null
+++ b/integration-tests/sql/pom.xml
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-sql</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: SQL</name>
+ <description>Integration tests for Camel Quarkus SQL extension</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-sql</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jdbc-h2</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-test-h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+ <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>native-image</id>
+ <goals>
+ <goal>native-image</goal>
+ </goals>
+ <configuration>
+ <reportErrorsAtRuntime>false</reportErrorsAtRuntime>
+ <cleanupServer>true</cleanupServer>
+ <enableHttpsUrlHandler>true</enableHttpsUrlHandler>
+ <enableServer>false</enableServer>
+ <dumpProxies>false</dumpProxies>
+ <graalvmHome>${graalvmHome}</graalvmHome>
+ <enableJni>true</enableJni>
+ <enableAllSecurityServices>true</enableAllSecurityServices>
+ <disableReports>true</disableReports>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/SqlResource.java b/integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/SqlResource.java
new file mode 100644
index 0000000..fc0c164
--- /dev/null
+++ b/integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/SqlResource.java
@@ -0,0 +1,112 @@
+/*
+ * 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.quarkus.component.sql.it;
+
+import io.agroal.api.AgroalDataSource;
+import io.quarkus.agroal.DataSource;
+
+import java.net.URI;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ProducerTemplate;
+import org.springframework.util.LinkedCaseInsensitiveMap;
+
+@Path("/sql")
+@ApplicationScoped
+public class SqlResource {
+
+ @Inject
+ @DataSource("camel-sql")
+ AgroalDataSource dataSource;
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @PostConstruct
+ public void postConstruct() throws SQLException {
+ try (Connection conn = dataSource.getConnection()) {
+ try (Statement statement = conn.createStatement()) {
+ statement.execute("DROP TABLE IF EXISTS camel");
+ statement.execute("CREATE TABLE camel (id int AUTO_INCREMENT, species VARCHAR(255))");
+ statement.execute(
+ "CREATE ALIAS ADD_NUMS FOR \"org.apache.camel.quarkus.component.sql.it.storedproc.NumberAddStoredProcedure.addNumbers\"");
+ }
+ }
+ }
+
+ @Path("/get/{species}")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String getCamel(@PathParam("species") String species) throws Exception {
+ Map<String, Object> params = new HashMap<>();
+ params.put("species", species);
+
+ return producerTemplate.requestBodyAndHeaders("sql:classpath:sql/get-camels.sql",
+ null, params,
+ String.class);
+ }
+
+ @Path("/post")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response createCamel(String species) throws Exception {
+ Map<String, Object> params = new HashMap<>();
+ params.put("species", species);
+
+ producerTemplate.requestBodyAndHeaders(
+ "sql:INSERT INTO camel (species) VALUES (:#species)", null,
+ params);
+
+ return Response
+ .created(new URI("https://camel.apache.org/"))
+ .build();
+ }
+
+ @Path("/storedproc")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String callStoredProcedure(@QueryParam("numA") int numA, @QueryParam("numB") int numB) {
+ Map<String, Object> args = new HashMap<>();
+ args.put("num1", numA);
+ args.put("num2", numB);
+
+ Map<String, List<LinkedCaseInsensitiveMap>> results = producerTemplate
+ .requestBodyAndHeaders("sql-stored:ADD_NUMS(INTEGER ${headers.num1},INTEGER ${headers.num2})", null, args,
+ Map.class);
+
+ return results.get("#result-set-1").get(0).get("PUBLIC.ADD_NUMS(?1, ?2)").toString();
+ }
+}
diff --git a/integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/storedproc/NumberAddStoredProcedure.java b/integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/storedproc/NumberAddStoredProcedure.java
new file mode 100644
index 0000000..bb22c85
--- /dev/null
+++ b/integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/storedproc/NumberAddStoredProcedure.java
@@ -0,0 +1,24 @@
+/*
+ * 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.quarkus.component.sql.it.storedproc;
+
+public class NumberAddStoredProcedure {
+
+ public static int addNumbers(int numA, int numB) {
+ return numA + numB;
+ }
+}
diff --git a/integration-tests/sql/src/main/resources/application.properties b/integration-tests/sql/src/main/resources/application.properties
new file mode 100644
index 0000000..39dc876
--- /dev/null
+++ b/integration-tests/sql/src/main/resources/application.properties
@@ -0,0 +1,34 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# Quarkus
+#
+quarkus.log.file.enable = false
+
+#
+# Quarkus Datasource
+#
+quarkus.datasource.camel-sql.url=jdbc:h2:tcp://localhost/mem:test
+quarkus.datasource.camel-sql.driver=org.h2.Driver
+quarkus.datasource.camel-sql.max-size=8
+quarkus.datasource.camel-sql.min-size=2
+
+#
+# Camel Quarkus SQL
+#
+quarkus.camel.sql.script-files=sql/get-camels.sql
diff --git a/integration-tests/sql/src/main/resources/sql/get-camels.sql b/integration-tests/sql/src/main/resources/sql/get-camels.sql
new file mode 100644
index 0000000..361a464
--- /dev/null
+++ b/integration-tests/sql/src/main/resources/sql/get-camels.sql
@@ -0,0 +1,18 @@
+--
+-- 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.
+--
+
+SELECT * FROM camel WHERE species=:#species
diff --git a/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlIT.java b/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlIT.java
new file mode 100644
index 0000000..edec056
--- /dev/null
+++ b/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlIT.java
@@ -0,0 +1,24 @@
+/*
+ * 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.quarkus.component.sql.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+class SqlIT extends SqlTest {
+
+}
diff --git a/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlTest.java b/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlTest.java
new file mode 100644
index 0000000..5346a0f
--- /dev/null
+++ b/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.quarkus.component.sql.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.h2.H2DatabaseTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+
+import org.junit.jupiter.api.Test;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(H2DatabaseTestResource.class)
+class SqlTest {
+
+ @Test
+ public void testSqlComponent() {
+ // Create Camel species
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body("Dromedarius")
+ .post("/sql/post")
+ .then()
+ .statusCode(201);
+
+ // Retrieve camel species
+ RestAssured.get("/sql/get/Dromedarius")
+ .then()
+ .statusCode(200)
+ .body(is("[{ID=1, SPECIES=Dromedarius}]"));
+ }
+
+ @Test
+ public void testSqlStoredComponent() {
+ // Invoke ADD_NUMS stored procedure
+ RestAssured.given()
+ .queryParam("numA", 10)
+ .queryParam("numB", 5)
+ .get("/sql/storedproc")
+ .then()
+ .statusCode(200)
+ .body(is("15"));
+ }
+}
diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml
index d6f94f4..1af509d 100644
--- a/poms/bom-deployment/pom.xml
+++ b/poms/bom-deployment/pom.xml
@@ -315,6 +315,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-sql-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-common-deployment</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 909c0db..97cc227 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -362,6 +362,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-sql</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-support</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -664,6 +669,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-sql</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-common</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>