REST Client

Java Proxy client for REST services.

License

License

The Apache License, Version 2.0
Categories

Categories

JavaScript Languages CLI User Interface
GroupId

GroupId

com.js-lib
ArtifactId

ArtifactId

js-rest-client
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

REST Client
Java Proxy client for REST services.
Project URL

Project URL

https://github.com/js-lib-com/rest-client.git
Source Code Management

Source Code Management

https://github.com/js-lib-com/rest-client

Download js-rest-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.js-lib/js-rest-client/ -->
<dependency>
    <groupId>com.js-lib</groupId>
    <artifactId>js-rest-client</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.js-lib/js-rest-client/
implementation 'com.js-lib:js-rest-client:1.0.0'
// https://jarcasting.com/artifacts/com.js-lib/js-rest-client/
implementation ("com.js-lib:js-rest-client:1.0.0")
'com.js-lib:js-rest-client:jar:1.0.0'
<dependency org="com.js-lib" name="js-rest-client" rev="1.0.0">
  <artifact name="js-rest-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.js-lib', module='js-rest-client', version='1.0.0')
)
libraryDependencies += "com.js-lib" % "js-rest-client" % "1.0.0"
[com.js-lib/js-rest-client "1.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
com.js-lib : js-commons jar 1.2.0
com.js-lib : js-json jar 1.0.2
javax.ws.rs : jsr311-api jar 1.1.1

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.hamcrest : hamcrest-all jar 1.3

Project Modules

There are no modules declared in this project.

rest-client

Java Proxy client for REST services.

Here is a functional example for Wikipedia API. First need to create DTO (Data Transport Object) compatible with returned JSON from API. Next define Java interface for Wikipedia API; need to define only methods of interest not all existing on API interface.

Create REST client factory and use it to create Wikipedia client instance. Need to provide Wikipedia API base URL. Once client instance created use it as regular Java instance and call methods. Client instance is a Java Proxy that convert method invocation into REST call.

  public class WikipediaPageSummary {
    String title;
    String displaytitle;
    String extract;
  }

  public interface Wikipedia {
    @Path("page/summary/{title}")
    WikipediaPageSummary getPageSummary(@PathParam("title") String title);
  }

  RestClientFactory factory = new RestClientFactory();
  Wikipedia wikipedia = factory.getRemoteInstance("https://en.wikipedia.org/api/rest_v1/", Wikipedia.class);
  
  WikipediaPageSummary summary = wikipedia.getPageSummary("Lion");
  // summary instance with fields initialized from JSON response
com.js-lib

java(script) libraries

Set of APIs and libraries for Java and JavaScript.

Versions

Version
1.0.0