hugo-book-theme/exampleSite/content/docs/dropwizard-configuration.md
2018-09-30 01:31:24 +02:00

1.2 KiB

Dropwizard configuration

Use provided RxJerseyBundle

@Override
public void initialize(Bootstrap<RxJerseyConfiguration> bootstrap) {
    bootstrap.addBundle(new RxJerseyBundle<RxJerseyConfiguration>()
            .setClientConfigurationProvider(config -> config.client)
            .register(HeaderInterceptor.class)
    );
}

Alternatively you can directly configure and register Jersey feature

public void run(RxJerseyConfiguration configuration, Environment environment) throws Exception {
    JerseyEnvironment jersey = environment.jersey();

    Client client = new JerseyClientBuilder(environment)
            .using(configuration.client)
            .using(new GrizzlyConnectorProvider())
            .buildRx("Client", RxObservableInvoker.class);

    RxJerseyServerFeature rxJerseyServerFeature = new RxJerseyServerFeature()
            .register(HeaderInterceptor.class);

    RxJerseyClientFeature rxJerseyClientFeature = new RxJerseyClientFeature()
            .register(client);

    jersey.register(rxJerseyServerFeature);
    jersey.register(rxJerseyClientFeature);
}

See example for more information