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

This documentation gives high level overview of the 10Duke SDK for Java and introduces some fundamental concepts.

APIs and implementations

Central contracts have been defined as interfaces. A default implementation is provided for each such Java API. The SDK user can choose to replace default implementations by suppling own implementations per case.

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 what is called a producer pattern (e.g. method annotated @Produces in a managed bean). See more about the producer pattern in e.g. 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;
}
}

Saving and restoring the client state

State is defined of user authentication status and by licenses that have been consumed. Storage for such state is recommended to be persistent. That way the application can continue operating after restarting with less need to make expensive network calls.

Using 10Duke Scale REST APIs

The 10Duke Scale SDK for Java covers implementation for calling the license checkout API. Reusing an HTTP client instance and an existing authorization provider instance is recommended when (if) making calls to other 10Duke Scale API endpoints from 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 detail in package tenduke.scale.api.exception.

Dependencies

The 10Duke Scale SDK for Java code depends on a HTTP client, JSON processing, Private and Public key use, ability to parse and validate JSON Web Tokens and to run 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 jose4j is used for parsing and validation JSON Web Tokens.
  1. SLF4J as the logging API