String[] resourceArr = new String[resources.size()];
for (int i = 0; i < resources.size(); i++) {
resourceArr[i] = String.valueOf(resources.get(i));
}
ResourceConfig rc = new ResourceConfig();
rc.packages(resourceArr);
ClassLoader cl = Thread.currentThread().getContextClassLoader();
JsonArray features = config.getArray(CONFIG_FEATURES, null);
if (features != null && features.size() > 0) {
for (int i = 0; i < features.size(); i++) {
try {
Class<?> clazz = cl.loadClass(String.valueOf(features.get(i)));
rc.register(clazz);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
}
// Always register the InternalVertxJerseyBinder
rc.register(new InternalVertxJerseyBinder(vertx, container));
// Register configured binders
JsonArray binders = config.getArray(CONFIG_BINDERS, null);
if (binders != null && binders.size() > 0) {
for (int i = 0; i < binders.size(); i++) {
try {
Class<?> clazz = cl.loadClass(String.valueOf(binders.get(i)));
rc.register(clazz.newInstance());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}