Adapter adapter = null;
Reloader r = new Reloader();
ResourceConfig rc = new DefaultResourceConfig(classes);
rc.getMediaTypeMappings().put("xml", MediaType.APPLICATION_XML_TYPE);
rc.getMediaTypeMappings().put("json", MediaType.APPLICATION_JSON_TYPE);
rc.getMediaTypeMappings().put("html", MediaType.TEXT_HTML_TYPE);
rc.getMediaTypeMappings().put("js", new MediaType("application", "x-javascript"));
RestConfig restConf = getRestConfig(habitat);
if (restConf != null) {
if (restConf.getLogOutput().equalsIgnoreCase("true")) { //enable output logging
rc.getContainerResponseFilters().add(LoggingFilter.class);
}
if (restConf.getLogInput().equalsIgnoreCase("true")) { //enable input logging
rc.getContainerRequestFilters().add(LoggingFilter.class);
}
if (restConf.getWadlGeneration().equalsIgnoreCase("false")) { //disable WADL
rc.getFeatures().put(ResourceConfig.FEATURE_DISABLE_WADL, Boolean.TRUE);
}
}
rc.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_NOTIFIER, r);
rc.getClasses().add(ReloadResource.class);
//We can only inject these 4 extra classes in Jersey resources...
rc.getSingletons().add(new SingletonTypeInjectableProvider<Context, Reloader>(Reloader.class, r) {});
rc.getSingletons().add(new SingletonTypeInjectableProvider<Context, ServerContext>(ServerContext.class, sc) {});
rc.getSingletons().add(new SingletonTypeInjectableProvider<Context, Habitat>(Habitat.class, habitat) {});
rc.getSingletons().add(new SingletonTypeInjectableProvider<Context, SessionManager>(SessionManager.class, habitat.getComponent(SessionManager.class)) {});
rc.getSingletons().add(new SingletonTypeInjectableProvider<Context, SessionManager>(SessionManager.class, habitat.getComponent(SessionManager.class)) {});
//Use common classloader. Jersey artifacts are not visible through
//module classloader
ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
try {