Search in sources :

Example 1 with JsonServiceFactory

use of jmri.spi.JsonServiceFactory in project JMRI by JMRI.

the class JsonServlet method init.

@Override
public void init() throws ServletException {
    super.init();
    this.mapper = new ObjectMapper();
    for (JsonServiceFactory factory : ServiceLoader.load(JsonServiceFactory.class)) {
        JsonHttpService service = factory.getHttpService(this.mapper);
        if (service != null) {
            for (String type : factory.getTypes()) {
                HashSet<JsonHttpService> set = this.services.get(type);
                if (set == null) {
                    this.services.put(type, new HashSet<>());
                    set = this.services.get(type);
                }
                set.add(factory.getHttpService(this.mapper));
            }
        }
    }
}
Also used : JsonHttpService(jmri.server.json.JsonHttpService) JsonServiceFactory(jmri.spi.JsonServiceFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JsonHttpService (jmri.server.json.JsonHttpService)1 JsonServiceFactory (jmri.spi.JsonServiceFactory)1