use of com.baremaps.server.ogcapi.ApiResource in project baremaps by baremaps.
the class Studio method call.
@Override
public Integer call() throws Exception {
// Configure serialization
ObjectMapper mapper = defaultObjectMapper();
// Configure jdbi and set the ObjectMapper
DataSource datasource = PostgresUtils.datasource(this.database);
Jdbi jdbi = Jdbi.create(datasource).installPlugin(new PostgresPlugin()).installPlugin(new Jackson2Plugin()).configure(Jackson2Config.class, config -> config.setMapper(mapper));
// Initialize the application
ResourceConfig application = new ResourceConfig().registerClasses(SwaggerResource.class, RootResource.class, CorsFilter.class, ConformanceResource.class, CollectionsResource.class, StylesResource.class, TilesetsResource.class, StudioResource.class, ImportResource.class, MultiPartFeature.class).register(new ApiResource("studio-openapi.yaml")).register(contextResolverFor(mapper)).register(new AbstractBinder() {
@Override
protected void configure() {
bind(datasource).to(DataSource.class);
bind(jdbi).to(Jdbi.class);
}
});
BlockingStreamingHttpService httpService = new HttpJerseyRouterBuilder().buildBlockingStreaming(application);
ServerContext serverContext = HttpServers.forPort(port).listenBlockingStreamingAndAwait(httpService);
logger.info("Listening on {}", serverContext.listenAddress());
serverContext.awaitShutdown();
return 0;
}
Aggregations