Search in sources :

Example 1 with ApiResource

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;
}
Also used : SwaggerResource(com.baremaps.server.ogcapi.SwaggerResource) RootResource(com.baremaps.server.ogcapi.RootResource) CorsFilter(com.baremaps.server.common.CorsFilter) Jdbi(org.jdbi.v3.core.Jdbi) ApiResource(com.baremaps.server.ogcapi.ApiResource) ConformanceResource(com.baremaps.server.ogcapi.ConformanceResource) StylesResource(com.baremaps.server.ogcapi.StylesResource) AbstractBinder(org.glassfish.hk2.utilities.binding.AbstractBinder) Jackson2Plugin(org.jdbi.v3.jackson2.Jackson2Plugin) PostgresPlugin(org.jdbi.v3.postgres.PostgresPlugin) DataSource(javax.sql.DataSource) HttpJerseyRouterBuilder(io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder) BlockingStreamingHttpService(io.servicetalk.http.api.BlockingStreamingHttpService) ServerContext(io.servicetalk.transport.api.ServerContext) ImportResource(com.baremaps.server.studio.ImportResource) MultiPartFeature(org.glassfish.jersey.media.multipart.MultiPartFeature) CollectionsResource(com.baremaps.server.ogcapi.CollectionsResource) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) StudioResource(com.baremaps.server.studio.StudioResource) TilesetsResource(com.baremaps.server.ogcapi.TilesetsResource) DefaultObjectMapper.defaultObjectMapper(com.baremaps.server.common.DefaultObjectMapper.defaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

CorsFilter (com.baremaps.server.common.CorsFilter)1 DefaultObjectMapper.defaultObjectMapper (com.baremaps.server.common.DefaultObjectMapper.defaultObjectMapper)1 ApiResource (com.baremaps.server.ogcapi.ApiResource)1 CollectionsResource (com.baremaps.server.ogcapi.CollectionsResource)1 ConformanceResource (com.baremaps.server.ogcapi.ConformanceResource)1 RootResource (com.baremaps.server.ogcapi.RootResource)1 StylesResource (com.baremaps.server.ogcapi.StylesResource)1 SwaggerResource (com.baremaps.server.ogcapi.SwaggerResource)1 TilesetsResource (com.baremaps.server.ogcapi.TilesetsResource)1 ImportResource (com.baremaps.server.studio.ImportResource)1 StudioResource (com.baremaps.server.studio.StudioResource)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BlockingStreamingHttpService (io.servicetalk.http.api.BlockingStreamingHttpService)1 HttpJerseyRouterBuilder (io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder)1 ServerContext (io.servicetalk.transport.api.ServerContext)1 DataSource (javax.sql.DataSource)1 AbstractBinder (org.glassfish.hk2.utilities.binding.AbstractBinder)1 MultiPartFeature (org.glassfish.jersey.media.multipart.MultiPartFeature)1 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)1 Jdbi (org.jdbi.v3.core.Jdbi)1