Prerequisites
- API already defined using gradle-conjure (see getting started)
- Server implemented and working (e.g. using Dropwizard)
dependencies {
+ compile project('your-project-api:your-project-api-jersey')
}
You should now be able to compile against generated interfaces and objects, e.g. RecipeBookService
.
conjure-java just generates client/server interfaces, so to actually make network calls you need to provide a client. conjure-java-runtime uses reflection to read annotations from your generated interfaces and provides a client based on Java 8 dynamic proxies.
dependencies {
compile project('your-project-api:your-project-api-jersey')
+ compile 'com.palantir.conjure.java.runtime:conjure-java-jaxrs-client:latest.release'
}
Check palantir/conjure-java-runtime for the latest release
Pass your interface as the first argument to have a client created:
RecipeBookService recipeBookService = JaxRsClient.create(
RecipeBookService.class,
UserAgent.of(Agent.of("your-server", "0.0.0")),
NoOpHostEventsSink.INSTANCE,
ClientConfigurations.of(ServiceConfiguration.builder()
.addUris("http://localhost:8080/examples/api/")
.security(SslConfiguration.of(Paths.get(TRUSTSTORE_PATH)))
.build()));
The JVM contains a JKS truststore at $JAVA_HOME/lib/security/cacerts
, but for production usage you should make sure your truststore is minimal.
Recipe recipe = recipeBookService.getRecipe("Recipe name");