Skip to main content

juneau-petstore-client

The juneau-petstore-client module contains a single Main class used to instantiate the proxy against our remote REST interface using the Java interface described above.

Main.java

public class Main {

public static void main(String[] args) {

// Create a RestClient with JSON serialization support.
RestClient restClient = RestClient.create().json5().build();

// Instantiate our proxy.
PetStore petStore = restClient.getRemote(PetStore.class, "http://localhost:5000");

// Print out the pets in the store.
Collection<Pet> pets = petStore.getPets();

// Pretty-print them to STDOUT.
Json5.DEFAULT_READABLE.println(pets);
}
}

Notice how little code is necessary to construct a remote proxy.