private void reload() {
System.out.println("ApplicationContext started, setting up REST API info");
WebApplicationContext webContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
Configuration env = webContext.getBean(Configuration.class);
final DefaultJaxrsScanner jaxrsScanner = new DefaultJaxrsScanner(){
@Override
public List<Class<?>> classesFromContext(Application app, ServletConfig sc) {
final List<Class<?>> classes = super.classesFromContext(app, sc);
return filterClasses(classes);
}
private List<Class<?>> filterClasses(final List<Class<?>> classes) {
final Iterator<Class<?>> eachClass = classes.iterator();
final ArrayList<Class<?>> filteredClasses = new ArrayList<Class<?>>();
while(eachClass.hasNext()) {
Class clazz = eachClass.next();
// if (clazz.getName().indexOf("fluxtream")!=-1)
// continue;
filteredClasses.add(clazz);
}
return JavaConversions.asScalaBuffer(filteredClasses).toList();
}
@Override
public List<Class<?>> classes() {
final List<Class<?>> classes = super.classes();
return filterClasses(classes);
}
};
ScannerFactory.setScanner(jaxrsScanner);
ClassReaders.setReader(new JerseyApiReader());
String docsBaseURL = env.get("docsHomeBaseUrl")!=null
? env.get("docsHomeBaseUrl")
: env.get("homeBaseUrl");
ApiInfo apiInfo = new ApiInfo(
"Fluxtream Public REST API",
"",
String.format("%shtml/privacyPolicy.html", docsBaseURL),
"info@fluxtream.org",
"Apache 2.0",
"http://www.apache.org/licences/LICENSE-2.0.html"
);
ConfigFactory.config().setBasePath(docsBaseURL+"api");
ConfigFactory.config().setApiInfo(apiInfo);
ConfigFactory.config().setApiVersion("v1");
env.reload();
}