fixed registration of vendor extensions with BaseJsonModel

This commit is contained in:
Dmitry Toptygin
2020-08-27 14:59:38 -04:00
parent c601647ff7
commit 4868b631aa
3 changed files with 14 additions and 5 deletions

View File

@@ -126,8 +126,10 @@ public abstract class BaseJdbcTest {
urls.addAll(ClasspathHelper.forPackage("com.telecominfraproject.wlan"));
//add vendor packages
if(BaseJsonModel.vendorTopLevelPackages!=null) {
String[] vendorPkgs = BaseJsonModel.vendorTopLevelPackages.split(",");
String vendorTopLevelPackages = BaseJsonModel.getVendorTopLevelPackages();
if(vendorTopLevelPackages!=null) {
String[] vendorPkgs = vendorTopLevelPackages.split(",");
for(int i=0; i< vendorPkgs.length; i++) {
if(vendorPkgs[i].trim().isEmpty()) {
continue;

View File

@@ -224,7 +224,10 @@ public abstract class BaseJsonModel implements Cloneable, Serializable {
return ret;
}
public static final String vendorTopLevelPackages = System.getProperty("tip.wlan.vendorTopLevelPackages", "");
public static String getVendorTopLevelPackages() {
return System.getProperty("tip.wlan.vendorTopLevelPackages", "");
}
public static Reflections getReflections() {
//scan urls that contain 'com.telecominfraproject.wlan' and vendor-specific top level packages, use the default scanners
@@ -235,6 +238,8 @@ public abstract class BaseJsonModel implements Cloneable, Serializable {
pkgs.add("com.telecominfraproject.wlan");
//add vendor packages
String vendorTopLevelPackages = getVendorTopLevelPackages();
if(vendorTopLevelPackages!=null) {
String[] vendorPkgs = vendorTopLevelPackages.split(",");
for(int i=0; i< vendorPkgs.length; i++) {
@@ -249,8 +254,10 @@ public abstract class BaseJsonModel implements Cloneable, Serializable {
}
}
FilterBuilder filters = new FilterBuilder().includePackage(pkgs.toArray(new String[0]));
Reflections reflections = new Reflections(new ConfigurationBuilder()
.filterInputsBy(new FilterBuilder().includePackage(pkgs.toArray(new String[0])))
.filterInputsBy(filters)
.setUrls(urls)
.setScanners(new SubTypesScanner(), new TypeAnnotationsScanner() ));

View File

@@ -42,7 +42,7 @@ public class FilterBuilder implements Predicate<String> {
/** include packages of given prefixes */
public FilterBuilder includePackage(final String... prefixes) {
for (String prefix : prefixes) {
return add(new Include(prefix(prefix)));
add(new Include(prefix(prefix)));
}
return this;
}