Search in sources :

Example 1 with BlockingStreamingHttpService

use of io.servicetalk.http.api.BlockingStreamingHttpService 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)

Example 2 with BlockingStreamingHttpService

use of io.servicetalk.http.api.BlockingStreamingHttpService in project baremaps by baremaps.

the class View method call.

@Override
public Integer call() throws Exception {
    ObjectMapper objectMapper = defaultObjectMapper();
    BlobStore blobStore = options.blobStore();
    TileJSON tileJSON = objectMapper.readValue(blobStore.get(this.tileset).getInputStream(), TileJSON.class);
    CaffeineSpec caffeineSpec = CaffeineSpec.parse(cache);
    DataSource datasource = PostgresUtils.datasource(database);
    List<PostgresQuery> queries = asPostgresQuery(tileJSON);
    TileStore tileStore = new PostgresTileStore(datasource, queries);
    TileStore tileCache = new TileCache(tileStore, caffeineSpec);
    // Configure the application
    ResourceConfig application = new ResourceConfig().register(CorsFilter.class).register(ViewerResources.class).register(contextResolverFor(objectMapper)).register(new AbstractBinder() {

        @Override
        protected void configure() {
            bind(tileset).to(URI.class).named("tileset");
            bind(style).to(URI.class).named("style");
            bind(blobStore).to(BlobStore.class);
            bind(tileCache).to(TileStore.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 : CorsFilter(com.baremaps.server.common.CorsFilter) TileStore(com.baremaps.tile.TileStore) PostgresTileStore(com.baremaps.tile.postgres.PostgresTileStore) Conversions.asPostgresQuery(com.baremaps.server.ogcapi.Conversions.asPostgresQuery) PostgresQuery(com.baremaps.tile.postgres.PostgresQuery) AbstractBinder(org.glassfish.hk2.utilities.binding.AbstractBinder) CaffeineSpec(com.github.benmanes.caffeine.cache.CaffeineSpec) DataSource(javax.sql.DataSource) HttpJerseyRouterBuilder(io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder) BlockingStreamingHttpService(io.servicetalk.http.api.BlockingStreamingHttpService) ServerContext(io.servicetalk.transport.api.ServerContext) TileJSON(com.baremaps.model.TileJSON) PostgresTileStore(com.baremaps.tile.postgres.PostgresTileStore) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) TileCache(com.baremaps.tile.TileCache) DefaultObjectMapper.defaultObjectMapper(com.baremaps.server.common.DefaultObjectMapper.defaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BlobStore(com.baremaps.blob.BlobStore)

Example 3 with BlockingStreamingHttpService

use of io.servicetalk.http.api.BlockingStreamingHttpService in project baremaps by baremaps.

the class Edit method call.

@Override
public Integer call() throws Exception {
    BlobStore blobStore = options.blobStore();
    DataSource dataSource = PostgresUtils.datasource(database);
    // Configure serialization
    ObjectMapper objectMapper = defaultObjectMapper();
    // Configure the application
    ResourceConfig application = new ResourceConfig().register(CorsFilter.class).register(EditorResources.class).register(contextResolverFor(objectMapper)).register(new AbstractBinder() {

        @Override
        protected void configure() {
            bind(tileset).to(URI.class).named("tileset");
            bind(style).to(URI.class).named("style");
            bind(blobStore).to(BlobStore.class);
            bind(dataSource).to(DataSource.class);
            bind(objectMapper).to(ObjectMapper.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 : CorsFilter(com.baremaps.server.common.CorsFilter) BlockingStreamingHttpService(io.servicetalk.http.api.BlockingStreamingHttpService) ServerContext(io.servicetalk.transport.api.ServerContext) AbstractBinder(org.glassfish.hk2.utilities.binding.AbstractBinder) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) BlobStore(com.baremaps.blob.BlobStore) DefaultObjectMapper.defaultObjectMapper(com.baremaps.server.common.DefaultObjectMapper.defaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DataSource(javax.sql.DataSource) HttpJerseyRouterBuilder(io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder)

Aggregations

CorsFilter (com.baremaps.server.common.CorsFilter)3 DefaultObjectMapper.defaultObjectMapper (com.baremaps.server.common.DefaultObjectMapper.defaultObjectMapper)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 BlockingStreamingHttpService (io.servicetalk.http.api.BlockingStreamingHttpService)3 HttpJerseyRouterBuilder (io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder)3 ServerContext (io.servicetalk.transport.api.ServerContext)3 DataSource (javax.sql.DataSource)3 AbstractBinder (org.glassfish.hk2.utilities.binding.AbstractBinder)3 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)3 BlobStore (com.baremaps.blob.BlobStore)2 TileJSON (com.baremaps.model.TileJSON)1 ApiResource (com.baremaps.server.ogcapi.ApiResource)1 CollectionsResource (com.baremaps.server.ogcapi.CollectionsResource)1 ConformanceResource (com.baremaps.server.ogcapi.ConformanceResource)1 Conversions.asPostgresQuery (com.baremaps.server.ogcapi.Conversions.asPostgresQuery)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