Skip to content

Instantly share code, notes, and snippets.

@maggandalf
Created July 5, 2014 16:09
Show Gist options
  • Save maggandalf/1ecd5fcdf310b802c749 to your computer and use it in GitHub Desktop.
Save maggandalf/1ecd5fcdf310b802c749 to your computer and use it in GitHub Desktop.
@Singleton
@Path("book")
public class BookService {
private static final String BOOKSERVICE = "http://localhost:8080/bookservice";
private static final String COMMENTSERVICE = "http://localhost:8080/bookcomments";
@Resource(name = "DefaultManagedExecutorService")
ManagedExecutorService executor;
Client bookServiceClient;
WebTarget bookServiceTarget;
Client commentServiceClient;
WebTarget commentServiceTarget;
@PostConstruct
void initializeRestClients() {
bookServiceClient = ClientBuilder.newClient();
bookServiceTarget = bookServiceClient.target(BOOKSERVICE + "/rest/bookinfo");
commentServiceClient = ClientBuilder.newClient();
commentServiceTarget = commentServiceClient.target(COMMENTSERVICE + "/rest/comments");
}
@GET
@Path("{isbn}")
@Produces(MediaType.APPLICATION_JSON)
public void bookAndComment(@Suspended final AsyncResponse asyncResponse, @PathParam("isbn") String isbn) {
//RxJava code shown below
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment