10Duke Scale SDK for Java
Loading...
Searching...
No Matches
Client concepts

This article provides a high-level overview of the 10Duke SDK for Java and introduces some fundamental concepts.

APIs and implementations

The central contracts have been defined as interfaces. A default implementation is provided for each Java API. The SDK user can choose to replace default implementations by supplying their own implementations as needed.

CDI - Contexts and Dependency Injection

The interfaces and default implementations support use via dependency injection. Some implementation classes require construction other than using a no-argument constructor. In those cases, the SDK user must implement a producer pattern (for example, a method annotated with @Produces in a managed bean). See more about the producer pattern for example in the WELD documentation: (https://docs.jboss.org/weld/reference/latest/en-US/html_single/#_producer_methods) or in the Quarkus docs: (https://quarkus.io/guides/cdi-reference).

TendukeScaleConfig is used as an example of the producer pattern. The task is to satisfy injection points that require an instance of TendukeScaleConfig. This can be achieved by e.g.:

@ApplicationScoped
public class TendukeConfigProvider {
private final TendukeScaleConfig config;
public TendukeConfigProvider() {
TendukeScaleConfigLoader configLoader = new TendukeScaleConfigLoader();
config = configLoader.loadFrom("tenduke.conf");
}
@Produces
public TendukeScaleConfig provideConfig() {
return config;
}
}

Save and restore the client state

Client state is defined by the user's authentication status and the consumed licenses. We recommend that storage for this state is persistent. This allows the application to continue operating after a restart with fewer expensive network calls.

Use 10Duke Scale REST APIs

The 10Duke Scale SDK for Java covers implementation for calling the license checkout API. We recommend reusing an HTTP client instance and an existing authorization provider instance when making calls to other 10Duke Scale API endpoints from the application code.

Errors

API errors and SDK (application) related errors are communicated using exceptions. The 10Duke Scale SDK for Java uses and extends exceptions provided by the JDK and by the 10Duke Java Core project.

See more details in the tenduke.scale.api.exception package.

Dependencies

The 10Duke Scale SDK for Java depends on an HTTP client, JSON processing, Private and Public key use, ability to parse and validate JSON Web Tokens, and user authentication / authorization using OpenID Connect.

The 10Duke Java Core project provides most of these basics.

The main 3rd party dependencies used are:

  1. OkHttp as the HTTP client implementation.
  1. Jackson as the JSON implementation.
  1. Vert.x as an internal HTTP server implementation for OpenID connect callback use cases.
  1. jose4j used for parsing and validating JSON Web Tokens.
  1. SLF4J as the logging API