Search in sources :

Example 1 with HttpJerseyRouterBuilder

use of io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder 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 HttpJerseyRouterBuilder

use of io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder 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 HttpJerseyRouterBuilder

use of io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder in project servicetalk by apple.

the class AbstractBasicAuthSecurityContextFilterTest method setUp.

void setUp(final boolean withUserInfo) throws Exception {
    final Builder<BasicUserInfo> builder = new Builder<>(CREDENTIALS_VERIFIER, "test-realm");
    if (withUserInfo) {
        builder.userInfoAsyncContextKey(TEST_USER_INFO_AC_KEY);
    }
    serverContext = HttpServers.forAddress(localAddress(0)).appendServiceFilter(builder.buildServer()).listenStreamingAndAwait(new HttpJerseyRouterBuilder().buildStreaming(application(withUserInfo ? TEST_USER_INFO_AC_KEY : null)));
    httpClient = HttpClients.forSingleAddress(serverHostAndPort(serverContext)).buildBlocking();
}
Also used : HttpJerseyRouterBuilder(io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder) Builder(io.servicetalk.http.utils.auth.BasicAuthHttpServiceFilter.Builder) HttpJerseyRouterBuilder(io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder)

Example 4 with HttpJerseyRouterBuilder

use of io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder in project servicetalk by apple.

the class HelloWorldJaxRsServer method main.

/**
 * Starts this server.
 *
 * @param args Program arguments, none supported yet.
 * @throws Exception If the server could not be started.
 */
public static void main(String[] args) throws Exception {
    // Create configurable starter for HTTP server.
    ServerContext serverContext = HttpServers.forPort(8080).listenStreamingAndAwait(new HttpJerseyRouterBuilder().buildStreaming(new HelloWorldJaxRsApplication()));
    LOGGER.info("Listening on {}", serverContext.listenAddress());
    // Blocks and awaits shutdown of the server this ServerContext represents.
    serverContext.awaitShutdown();
}
Also used : ServerContext(io.servicetalk.transport.api.ServerContext) HttpJerseyRouterBuilder(io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder)

Example 5 with HttpJerseyRouterBuilder

use of io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder 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

HttpJerseyRouterBuilder (io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder)5 ServerContext (io.servicetalk.transport.api.ServerContext)4 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 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