This is an automated email from the ASF dual-hosted git repository. rec pushed a commit to branch feature/102-RutaResourceLoader-should-consider-TCCL in repository https://gitbox.apache.org/repos/asf/uima-ruta.git
commit 78dda35b853b15797c94c84a3db751b70b7d4b4f Author: Richard Eckart de Castilho <[email protected]> AuthorDate: Mon Aug 29 15:29:26 2022 +0200 #102 - RutaResourceLoader should consider TCCL - Add second fallback considering the TCCL --- .../uima/ruta/resource/RutaResourceLoader.java | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ruta-core/src/main/java/org/apache/uima/ruta/resource/RutaResourceLoader.java b/ruta-core/src/main/java/org/apache/uima/ruta/resource/RutaResourceLoader.java index 23c25c1f..71356ff7 100644 --- a/ruta-core/src/main/java/org/apache/uima/ruta/resource/RutaResourceLoader.java +++ b/ruta-core/src/main/java/org/apache/uima/ruta/resource/RutaResourceLoader.java @@ -6,9 +6,9 @@ * 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 @@ -31,13 +31,15 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver; * found. */ public class RutaResourceLoader implements ResourceLoader { - + private final ResourceLoader wrapped; private final ResourceLoader fallback; + private final ResourceLoader fallback2; + private final ClassLoader classLoader; - + /** * @param paths * paths to search in priority. @@ -53,8 +55,9 @@ public class RutaResourceLoader implements ResourceLoader { this.classLoader = classLoader; } this.fallback = new DefaultResourceLoader(this.classLoader); + this.fallback2 = new DefaultResourceLoader(); } - + /** * @param paths * paths to search in priority. @@ -63,13 +66,19 @@ public class RutaResourceLoader implements ResourceLoader { this(paths, null); } - + @Override public Resource getResource(String location) { Resource resource = this.wrapped.getResource(location); + if (!resource.exists()) { resource = fallback.getResource(location); } + + if (!resource.exists()) { + resource = fallback2.getResource(location); + } + return resource; } @@ -77,7 +86,7 @@ public class RutaResourceLoader implements ResourceLoader { String path = location.replaceAll("[.]", "/") + extension; return getResource(path); } - + @Override public ClassLoader getClassLoader() { return classLoader;
