-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed native issue and completed test/documentation #1710
- Loading branch information
1 parent
89342a6
commit f1d88a5
Showing
27 changed files
with
492 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
...ent/src/main/java/org/apache/camel/quarkus/component/saxon/deployment/SaxonProcessor.java
This file was deleted.
Oops, something went wrong.
64 changes: 0 additions & 64 deletions
64
...gration-test/src/main/java/org/apache/camel/quarkus/component/saxon/it/SaxonResource.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
66 changes: 66 additions & 0 deletions
66
...ent/src/main/java/org/apache/camel/quarkus/component/saxon/deployment/SaxonProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* 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.saxon.deployment; | ||
|
||
import java.util.Collection; | ||
|
||
import org.w3c.dom.Document; | ||
|
||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.builditem.CombinedIndexBuildItem; | ||
import io.quarkus.deployment.builditem.FeatureBuildItem; | ||
import io.quarkus.deployment.builditem.IndexDependencyBuildItem; | ||
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; | ||
import net.sf.saxon.functions.SystemFunction; | ||
import org.jboss.jandex.ClassInfo; | ||
import org.jboss.jandex.DotName; | ||
import org.jboss.logging.Logger; | ||
|
||
class SaxonProcessor { | ||
|
||
private static final Logger LOG = Logger.getLogger(SaxonProcessor.class); | ||
private static final String FEATURE = "camel-saxon"; | ||
|
||
@BuildStep | ||
FeatureBuildItem feature() { | ||
return new FeatureBuildItem(FEATURE); | ||
} | ||
|
||
@BuildStep | ||
void registerReflectiveClasses(BuildProducer<ReflectiveClassBuildItem> reflectiveClasses, | ||
CombinedIndexBuildItem index) { | ||
|
||
// Needed to register default object models when initializing the net.sf.saxon.java.JavaPlatform | ||
reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false, Document.class)); | ||
|
||
// Register saxon functions as reflective | ||
Collection<ClassInfo> cis = index.getIndex() | ||
.getAllKnownSubclasses(DotName.createSimple(SystemFunction.class.getName())); | ||
cis.stream().forEach(ci -> { | ||
String clazzName = ci.asClass().name().toString(); | ||
ReflectiveClassBuildItem clazz = new ReflectiveClassBuildItem(false, false, clazzName); | ||
LOG.debugf("Registering saxon function '%s' as reflective", clazzName); | ||
reflectiveClasses.produce(clazz); | ||
}); | ||
} | ||
|
||
@BuildStep | ||
void indexSaxonHe(BuildProducer<IndexDependencyBuildItem> deps) { | ||
deps.produce(new IndexDependencyBuildItem("net.sf.saxon", "Saxon-HE")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Beyond standard usages described above, a trick is needed when using the xquery language and component with classpath resources in native mode. In such a situation, one needs to explicitly embed the resources in the native executable by specifying the `include-patterns` option. | ||
|
||
For instance, the 2 routes below would load a xquery script from 2 classpath resources respectively named _myxquery.txt_ and _another-xquery.txt_: | ||
[source,java] | ||
---- | ||
from("direct:start").transform().xquery("resource:classpath:myxquery.txt", String.class); | ||
from("direct:start").to("xquery:another-xquery.txt"); | ||
---- | ||
|
||
In order to work in native mode the `include-patterns` configuration should be set. For instance, in the `application.properties` file as below : | ||
[source,properties] | ||
---- | ||
quarkus.camel.native.resources.include-patterns = *.txt | ||
---- | ||
More information about selecting resources for inclusion in the native executable could be found at xref:user-guide/native-mode.adoc#embedding-resource-in-native-executable[Embedding resource in native executable]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.