jus
Jus is a flexible and easy HTTP/REST client library for Java and Android.
- it is like Volley but much easier
- it is like Retrofit but infinitely more flexible
Jus is inspired by the flexibility, modularity and transparency of Google's Volley Library and the extreme simplicity of declarative API mapping of Retrofit.
Like Volley the main thing where Requests are executed is the RequestQueue.
RequestQueue queue = Jus.newRequestQueue();
and then Requests can be added to the Queue:
queue.add(new Request<String>(
Request.Method.GET,
HttpUrl.parse(BeerService.fullUrl),
new Converters.StringResponseConverter())
.addResponseListener((r) -> out.println("RESPONSE: " + r))
.addErrorListener((e) -> out.println("ERROR: " + e))
);
Anther option similarly to Retrofit is to map Java Interface to an API.
public interface BeerService {
@GET("locquery/{user}/{q}")
Request<String> getBeer(
@Path("user") String user,
@Path("q") String q);
}
Then create the Service Instance:
RetroProxy retroJus = new RetroProxy.Builder()
.baseUrl(BeerService.baseUrl)
.requestQueue(queue)
.addConverterFactory(new BasicConverterFactory())
.build();
BeerService beerService = retroJus.create(BeerService.class);
And execute a request:
beerService.getBeer(BeerService.userString, "777")
.addResponseListener((r) -> out.println("RESPONSE: " + r))
.addErrorListener((e) -> out.println("ERROR: " + e.networkResponse));
Download
Find the latest JARs or grab via Maven:
<dependency>
<groupId>io.apptik.comm</groupId>
<artifactId>jus-XXX</artifactId>
<version>0.6.9</version>
</dependency>
or Gradle:
compile 'io.apptik.comm:jus-XXX:0.6.9'
Downloads of the released versions are available in Sonatype's releases
repository.
Snapshots of the development versions are available in Sonatype's snapshots
repository.
Jus requires at minimum Java 7 or Android SDK 15.
Examples
Questions
StackOverflow with tag 'jus' or 'apptik'
Modules
- jus for Java - main jus library for java
- Reactive jus - RxJava support for jus
HTTP Stacks
- OkHttp = OkHttp Client Stack for jus
- OkHttp3 = OkHttp3 Client Stack for jus
- ApacheHttp = ApacheHttp Client Stack for jus
- Netty = Netty Client Stack for jus
Jus for Android
- Android jus - jus optimized for Android
- Data serializers support and custom requests for jus
Licence
Copyright (C) 2016 AppTik Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.