Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created a camel-jsonpath extension #426 #609

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Number of Camel data formats: 10 in 9 JAR artifacts (0 deprecated)
== Camel Languages

// languages: START
Number of Camel languages: 8 in 2 JAR artifacts (0 deprecated)
Number of Camel languages: 9 in 3 JAR artifacts (0 deprecated)

[width="100%",cols="4,1,5",options="header"]
|===
Expand All @@ -230,6 +230,8 @@ Number of Camel languages: 8 in 2 JAR artifacts (0 deprecated)

| link:https://camel.apache.org/components/latest/header-language.html[Header] (camel-quarkus-core) | 0.2.0 | To use a Camel Message header in expressions or predicates.

| link:https://camel.apache.org/components/latest/jsonpath-language.html[JsonPath] (camel-quarkus-jsonpath) | 1.0.0 | To use JsonPath in Camel expressions or predicates.

| link:https://camel.apache.org/components/latest/ref-language.html[Ref] (camel-quarkus-core) | 0.2.0 | Reference to an existing Camel expression or predicate, which is looked up from the Camel registry.

| link:https://camel.apache.org/components/latest/simple-language.html[Simple] (camel-quarkus-core) | 0.2.0 | To use Camels built-in Simple language in Camel expressions or predicates.
Expand Down
75 changes: 75 additions & 0 deletions extensions/jsonpath/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?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-jsonpath-parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-jsonpath-deployment</artifactId>
<name>Camel Quarkus :: JSON Path :: 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>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jsonpath</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,46 @@
/*
* 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.json.path.deployment;

import java.util.ArrayList;
import java.util.List;

import org.apache.camel.jsonpath.JsonPath;
import org.apache.camel.jsonpath.JsonPathAnnotationExpressionFactory;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;

class JsonPathProcessor {

private static final String FEATURE = "camel-jsonpath";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
List<ReflectiveClassBuildItem> registerReflectiveClassBuildItems() {
List<ReflectiveClassBuildItem> reflectiveClassBuildItems = new ArrayList<>();
reflectiveClassBuildItems.add(new ReflectiveClassBuildItem(false, false, JsonPathAnnotationExpressionFactory.class));
reflectiveClassBuildItems.add(new ReflectiveClassBuildItem(true, false, JsonPath.class));
return reflectiveClassBuildItems;
}

}
39 changes: 39 additions & 0 deletions extensions/jsonpath/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.1.0-SNAPSHOT</version>
<relativePath>../../poms/build-parent/pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-jsonpath-parent</artifactId>
<name>Camel Quarkus :: JSON Path</name>
<packaging>pom</packaging>

<modules>
<module>deployment</module>
<module>runtime</module>
</modules>
</project>
87 changes: 87 additions & 0 deletions extensions/jsonpath/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?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-jsonpath-parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-jsonpath</artifactId>
<name>Camel Quarkus :: JSON Path :: Runtime</name>
<description>Camel JSON Path language</description>

<properties>
<firstVersion>1.0.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-jsonpath</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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.json.path;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

import org.apache.camel.support.ObjectHelper;
import org.apache.camel.support.language.DefaultAnnotationExpressionFactory;

/**
* This alias works around an issue with the JsonPath annotation from camel. In
* camel, DefaultAnnotationExpressionFactory.getAnnotationObjectValue() uses the
* underlying annotation class proxy which is a JVM implementation detail. So,
* this alias makes it possible to get the JsonPath annotation value in native
* mode.
*/
@TargetClass(DefaultAnnotationExpressionFactory.class)
public final class Target_DefaultAnnotationExpressionFactory {

@Substitute
protected Object getAnnotationObjectValue(Annotation annotation, String methodName) {
try {
// Gets the method reference from the annotation itself, not from
// the underlying proxy
Method method = annotation.annotationType().getDeclaredMethod(methodName);
Object value = ObjectHelper.invokeMethod(method, annotation);
return value;
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException("Cannot determine the Object value of the annotation: " + annotation
+ " as it does not have the method: " + methodName
+ "() method", e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# 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 JSON Path"
description: "Camel JSON Path language"
metadata:
keywords:
- "camel"
- "json"
guide: "https://quarkus.io/guides/camel"
categories:
- "integration"
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<module>infinispan</module>
<module>jackson</module>
<module>jdbc</module>
<module>jsonpath</module>
<module>kafka</module>
<module>kotlin</module>
<module>log</module>
Expand Down
4 changes: 3 additions & 1 deletion extensions/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Number of Camel data formats: 10 in 9 JAR artifacts (0 deprecated)
== Camel Languages

// languages: START
Number of Camel languages: 8 in 2 JAR artifacts (0 deprecated)
Number of Camel languages: 9 in 3 JAR artifacts (0 deprecated)

[width="100%",cols="4,1,5",options="header"]
|===
Expand All @@ -231,6 +231,8 @@ Number of Camel languages: 8 in 2 JAR artifacts (0 deprecated)

| link:https://camel.apache.org/components/latest/header-language.html[Header] (camel-quarkus-core) | 0.2.0 | To use a Camel Message header in expressions or predicates.

| link:https://camel.apache.org/components/latest/jsonpath-language.html[JsonPath] (camel-quarkus-jsonpath) | 1.0.0 | To use JsonPath in Camel expressions or predicates.

| link:https://camel.apache.org/components/latest/ref-language.html[Ref] (camel-quarkus-core) | 0.2.0 | Reference to an existing Camel expression or predicate, which is looked up from the Camel registry.

| link:https://camel.apache.org/components/latest/simple-language.html[Simple] (camel-quarkus-core) | 0.2.0 | To use Camels built-in Simple language in Camel expressions or predicates.
Expand Down