MARMOTTA-442: Enhanced the Service loading of the DefautlConfiguration to 
fail-over services that do throw a ServiceConfigurationError.


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/630b4ae2
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/630b4ae2
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/630b4ae2

Branch: refs/heads/ldp
Commit: 630b4ae21e7fed1056d1ff2b9a0830fe56fa4ab7
Parents: b243490
Author: Rupert Westenthaler <[email protected]>
Authored: Fri Feb 28 09:56:55 2014 +0100
Committer: Rupert Westenthaler <[email protected]>
Committed: Fri Feb 28 09:56:55 2014 +0100

----------------------------------------------------------------------
 .../ldpath/parser/DefaultConfiguration.java     | 31 +++++++++++++++-----
 1 file changed, 24 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/630b4ae2/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/parser/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/parser/DefaultConfiguration.java
 
b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/parser/DefaultConfiguration.java
index 2238c5e..74471cf 100644
--- 
a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/parser/DefaultConfiguration.java
+++ 
b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/parser/DefaultConfiguration.java
@@ -32,7 +32,9 @@ import org.slf4j.LoggerFactory;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Map;
+import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
 import java.util.Set;
 
@@ -113,9 +115,16 @@ public class DefaultConfiguration<Node> extends 
Configuration<Node> {
     }
 
     private void addDefaultFunctions() {
-        for (SelectorFunction<Node> f : functionLoader) {
-            log.info("registering LDPath function: {}",f.getSignature());
-            addFunction(f);
+        Iterator<SelectorFunction> functions = functionLoader.iterator();
+        while (functions.hasNext()) {
+            try {
+                SelectorFunction<Node> f = functions.next();
+                log.info("registering LDPath function: {}", f.getSignature());
+                addFunction(f);
+            } catch (ServiceConfigurationError e) {
+                log.warn("Unable to load function because of an "
+                        + e.getClass().getSimpleName(), e);
+            }
         }
     }
 
@@ -124,10 +133,18 @@ public class DefaultConfiguration<Node> extends 
Configuration<Node> {
     }
 
     private void addDefaultTestFunctions() {
-        for (TestFunction<Node> t : testLoader) {
-            log.info("registering LDPath test function: {}", t.getSignature());
-            addTestFunction(t);
-        }
+       Iterator<TestFunction> testFunctions = testLoader.iterator();
+       while(testFunctions.hasNext()){
+            try {
+                       TestFunction testFunction = testFunctions.next();
+                log.info("registering LDPath test function: {}", 
+                        testFunction.getSignature());
+                addTestFunction(testFunction);
+            } catch (ServiceConfigurationError e) {
+                log.warn("Unable to load function because of an "
+                        + e.getClass().getSimpleName(), e);
+            }
+       }
     }
 
     private void addTestFunction(TestFunction<Node> test) {

Reply via email to