This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.14.x by this push:
new 4fa3432 CAMEL-17524: camel-schematron - Problem loading resource in
OSGi
4fa3432 is described below
commit 4fa343262848ae3cbd98f621ceee892383a0adac
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jan 21 10:24:39 2022 +0100
CAMEL-17524: camel-schematron - Problem loading resource in OSGi
---
components/camel-schematron/pom.xml | 7 ++-----
.../component/schematron/processor/TemplatesFactory.java | 13 ++++---------
2 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/components/camel-schematron/pom.xml
b/components/camel-schematron/pom.xml
index 9439c9c..560908a 100644
--- a/components/camel-schematron/pom.xml
+++ b/components/camel-schematron/pom.xml
@@ -19,22 +19,19 @@
-->
<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">
+ <modelVersion>4.0.0</modelVersion>
+
<parent>
<groupId>org.apache.camel</groupId>
<artifactId>components</artifactId>
<version>3.14.1-SNAPSHOT</version>
</parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.camel</groupId>
<artifactId>camel-schematron</artifactId>
<packaging>jar</packaging>
<name>Camel :: Schematron</name>
<description>Camel Schematron support</description>
- <properties>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
diff --git
a/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/processor/TemplatesFactory.java
b/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/processor/TemplatesFactory.java
index 949e59e..4af50b0 100644
---
a/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/processor/TemplatesFactory.java
+++
b/components/camel-schematron/src/main/java/org/apache/camel/component/schematron/processor/TemplatesFactory.java
@@ -30,8 +30,6 @@ import org.w3c.dom.Node;
import org.apache.camel.component.schematron.constant.Constants;
import
org.apache.camel.component.schematron.exception.SchematronConfigException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Class generating Templates for a given schematron rules
@@ -41,15 +39,11 @@ public final class TemplatesFactory {
private static final TemplatesFactory INSTANCE = new TemplatesFactory();
private static final String[] PIPELINE
= new String[] { "iso_dsdl_include.xsl",
"iso_abstract_expand.xsl", "iso_svrl_for_xslt2.xsl" };
- private Logger logger = LoggerFactory.getLogger(TemplatesFactory.class);
/**
- * Singleton constructor;
- *
- * @return
+ * Singleton constructor
*/
public static TemplatesFactory newInstance() {
-
return INSTANCE;
}
@@ -61,7 +55,6 @@ public final class TemplatesFactory {
* @return schematron template.
*/
public Templates getTemplates(final InputStream rules, final
TransformerFactory fac) {
-
Node node = null;
Source source = new StreamSource(rules);
try {
@@ -69,6 +62,9 @@ public final class TemplatesFactory {
String path = Constants.SCHEMATRON_TEMPLATES_ROOT_DIR
.concat("/").concat(template);
InputStream xsl =
org.apache.camel.util.ObjectHelper.loadResourceAsStream(path);
+ if (xsl == null) {
+ xsl =
this.getClass().getClassLoader().getResourceAsStream(path);
+ }
Transformer t = fac.newTransformer(new StreamSource(xsl));
DOMResult result = new DOMResult();
t.transform(source, result);
@@ -76,7 +72,6 @@ public final class TemplatesFactory {
}
return fac.newTemplates(new DOMSource(node));
} catch (Exception e) {
- logger.error(e.getMessage(), e);
throw new SchematronConfigException(e);
}
}