Skip to content

Commit

Permalink
Add SQL component extension
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Dec 10, 2019
1 parent 951b347 commit ee45752
Show file tree
Hide file tree
Showing 21 changed files with 958 additions and 2 deletions.
29 changes: 29 additions & 0 deletions docs/modules/ROOT/pages/extensions/sql.adoc
Original file line number Diff line number Diff line change
@@ -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
----
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
|===
Expand Down Expand Up @@ -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 | The slack component allows you to send messages to Slack.

| xref:extensions/sql.adoc[SQL] (camel-quarkus-sql) +
`sql:query` | 1.1 | 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 | 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 | The timer component is used for generating message exchanges when a timer fires.

Expand Down
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
8 changes: 7 additions & 1 deletion extensions/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
|===
Expand Down Expand Up @@ -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 | The slack component allows you to send messages to Slack.

| xref:extensions/sql.adoc[SQL] (camel-quarkus-sql) +
`sql:query` | 1.1 | 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 | 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 | The timer component is used for generating message exchanges when a timer fires.

Expand Down
84 changes: 84 additions & 0 deletions extensions/sql/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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();
}
}
39 changes: 39 additions & 0 deletions extensions/sql/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
108 changes: 108 additions & 0 deletions extensions/sql/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit ee45752

Please sign in to comment.