Browse code

BM-15041 Fix: load sanitizer and validor with priority

Anthony Prades authored on 10/07/2019 09:35:23
Showing 3 changed files
... ...
@@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.core.runtime,
16 16
  net.bluemind.mailshare.api;bundle-version="1.0.0",
17 17
  net.bluemind.todolist.api;bundle-version="1.0.0",
18 18
  net.bluemind.mailbox.identity.api;bundle-version="1.0.0",
19
- net.bluemind.core.rest
19
+ net.bluemind.core.rest,
20
+ slf4j.api
20 21
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
21 22
 Bundle-ActivationPolicy: lazy
22 23
 Export-Package: net.bluemind.core.sanitizer
... ...
@@ -22,19 +22,26 @@ import java.util.Collections;
22 22
 import java.util.List;
23 23
 import java.util.Map;
24 24
 
25
+import org.slf4j.Logger;
26
+import org.slf4j.LoggerFactory;
27
+
25 28
 import net.bluemind.core.api.fault.ServerFault;
26 29
 import net.bluemind.core.rest.BmContext;
27 30
 import net.bluemind.eclipse.common.RunnableExtensionLoader;
28 31
 
29 32
 public class Sanitizer {
33
+	private static final Logger logger = LoggerFactory.getLogger(Sanitizer.class);
30 34
 
31 35
 	private static final List<ISanitizerFactory<Object>> sanitizers = loadSanitizer();
32 36
 
33 37
 	private static List<ISanitizerFactory<Object>> loadSanitizer() {
34 38
 		RunnableExtensionLoader<ISanitizerFactory<Object>> rel = new RunnableExtensionLoader<ISanitizerFactory<Object>>();
35
-		List<ISanitizerFactory<Object>> stores = rel.loadExtensions("net.bluemind.core", "sanitizerfactory",
39
+		List<ISanitizerFactory<Object>> stores = rel.loadExtensionsWithPriority("net.bluemind.core", "sanitizerfactory",
36 40
 				"sanitizerfactory", "implementation");
37 41
 
42
+		stores.stream().forEach(store -> logger.info("sanitizer factory class: {} for: {}", store.getClass().getName(),
43
+				store.support()));
44
+
38 45
 		return stores;
39 46
 	}
40 47
 
... ...
@@ -29,19 +29,17 @@ import net.bluemind.core.rest.BmContext;
29 29
 import net.bluemind.eclipse.common.RunnableExtensionLoader;
30 30
 
31 31
 public class Validator {
32
-
33 32
 	private static final Logger logger = LoggerFactory.getLogger(Validator.class);
34 33
 
35 34
 	private static final List<IValidatorFactory<Object>> validators = loadValidator();
36 35
 
37 36
 	private static List<IValidatorFactory<Object>> loadValidator() {
38 37
 		RunnableExtensionLoader<IValidatorFactory<Object>> rel = new RunnableExtensionLoader<IValidatorFactory<Object>>();
39
-		List<IValidatorFactory<Object>> stores = rel.loadExtensions("net.bluemind.core", "validatorfactory",
38
+		List<IValidatorFactory<Object>> stores = rel.loadExtensionsWithPriority("net.bluemind.core", "validatorfactory",
40 39
 				"validatorfactory", "implementation");
41 40
 
42
-		for (IValidatorFactory<Object> j : stores) {
43
-			logger.info("validator factory class: {} for: {}", j.getClass().getName(), j.support());
44
-		}
41
+		stores.stream().forEach(store -> logger.info("validator factory class: {} for: {}", store.getClass().getName(),
42
+				store.support()));
45 43
 
46 44
 		return stores;
47 45
 	}