summaryrefslogtreecommitdiff
path: root/exampleSite/content/docs/dropwizard-configuration.md
blob: 9bfdb70162db9a24785ef427a3a04fb5cb1b90fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## Dropwizard configuration 

Use provided `RxJerseyBundle`
```java
@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
```java
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](https://github.com/alex-shpak/rx-jersey/tree/master/example) for more information