Skip to content

Sharing clients

Ahmad K. Bawaneh edited this page May 9, 2021 · 3 revisions

Sharing clients

Domino-rest works in both the browser and in a pure JVM, and the same generated rest-client can be used on both sides, so there is no need to generate different clients for the browser and JVM, this also includes Android applications - for android applications please checkout domino-rest-android.

Now assuming you have a GWT application that is split into 3 modules, client, shared, and server, then you can use domino-rest in 3 modes, switching between the different mode is a matter of what/where dependencies are defined and where the service definition interface is defined :

  1. Client only mode -browser-

To define the interface and use the generated rest-client from client code only use the following dependencies in the client module pom.xml

<!-- Lib dependency-->
<dependency>
  <groupId>org.dominokit</groupId>
  <artifactId>domino-rest-client</artifactId>
  <version>1.0.0-RC3</version>
</dependency>

<!-- Annotation processor dependency-->
<dependency>
    <groupId>org.dominokit</groupId>
    <artifactId>domino-rest-processor</artifactId>
    <version>1.0.0-RC3</version>
    <scope>provided</scope>
</dependency>

also, define the service interface in the client module.

  1. Server only mode -JVM-

To define the interface and use the generated rest-client from server code only use the following dependencies in the server module pom.xml

<!-- Lib dependency-->
<dependency>
  <groupId>org.dominokit</groupId>
  <artifactId>domino-rest-jvm</artifactId>
  <version>1.0.0-RC3</version>
</dependency>

<!-- Annotation processor dependency-->
<dependency>
    <groupId>org.dominokit</groupId>
    <artifactId>domino-rest-processor</artifactId>
    <version>1.0.0-RC3</version>
    <scope>provided</scope>
</dependency>

also, define the service interface in the server module.

  1. Same rest client is shared between client and server

To define the interface and use the same generated rest-client from both client module -browser- and server module distribute the dependencies as the following :

  • in the client module pom.xml
<!-- Lib dependency-->
<dependency>
  <groupId>org.dominokit</groupId>
  <artifactId>domino-rest-client</artifactId>
  <version>1.0.0-RC3</version>
</dependency>
  • in the server module pom.xml
<!-- Lib dependency-->
<dependency>
  <groupId>org.dominokit</groupId>
  <artifactId>domino-rest-jvm</artifactId>
  <version>1.0.0-RC3</version>
</dependency>
  • in the shared module pom.xml
<!-- Lib dependency-->
<dependency>
  <groupId>org.dominokit</groupId>
  <artifactId>domino-rest-shared</artifactId>
  <version>1.0.0-RC3</version>
</dependency>

<!-- Annotation processor dependency-->
<dependency>
    <groupId>org.dominokit</groupId>
    <artifactId>domino-rest-processor</artifactId>
    <version>1.0.0-RC3</version>
    <scope>provided</scope>
</dependency>

also, define the service interface in the shared module, and since both client and server depending on the shared module, you can use the same generated client on both modules.

Clone this wiki locally