You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/01/21 09:25:29 UTC
[camel] branch main updated: CAMEL-17524: camel-schematron - Problem loading resource in OSGi
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new b463d28 CAMEL-17524: camel-schematron - Problem loading resource in OSGi
b463d28 is described below
commit b463d283d598ec542a7859b4315fdb4e2564862d
Author: Claus Ibsen <cl...@gmail.com>
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 fa2fd5f..4203ef5 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.15.0-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);
}
}