- // getResources method returns objects of type "Resource"
- // 1. We are getting all the objects from the classpath which has
- // "DbEdgeRules" in the name.
- // 2. We run them through a filter and return only the objects which match
- // the supplied pattern "p"
- // 3. We then collect the objects in a list. At this point we have a list
- // of the kind of files we require.
- rulesFiles = Arrays.stream(rulesResolver.getResources("classpath*:/dbedgerules/DbEdgeRules*" + fileExt))
- .filter(r -> !myMatcher(rulesPattern, r.getFilename()).isEmpty()).collect(Collectors.toList());
-
+ // Allow additional DBEdgeRule files to be dropped in manually (in addition to those found on the classpath)
+ File[] edgeRuleFileList = new File(rulesDir).listFiles((d, name) -> rulesPattern.matcher(name).matches());
+ for (File file : edgeRuleFileList) {
+ rulesFiles.add(file);
+ existingFiles.add(filename(file));
+ }
+
+ // Get DBEdgeRules from the jar on the classpath. Don't include any that conflict with files which
+ // were dropped manually.
+ Resource[] rawResourceList = rulesResolver.getResources("classpath*:/dbedgerules/DbEdgeRules*" + fileExt);
+ List<Resource> prunedResourceList = new ArrayList<Resource>();
+ for (Resource resource : rawResourceList) {
+ if (!existingFiles.contains(filename(resource))) {
+ prunedResourceList.add(resource);
+ }
+ }
+
+ rulesFiles.addAll(Arrays.stream(prunedResourceList.toArray(new Resource[prunedResourceList.size()]))
+ .filter(r -> !myMatcher(rulesPattern, r.getFilename()).isEmpty()).collect(Collectors.toList()));
+