Skip to content

Commit eb7b45b

Browse files
authored
Remove all mentions of rx-java in our docs (#22515)
1 parent b9a5892 commit eb7b45b

File tree

14 files changed

+186
-228
lines changed

14 files changed

+186
-228
lines changed

sdk/docs/manually-written/sdk/component-howtos/application-development/client-libraries/java-client-libraries.rst

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,27 @@ guidance on how to use them. Read below to learn about their code architecture,
1010
Overview
1111
--------
1212

13-
The Java client libraries are organized in two layers:
14-
1513
.. _component-howtos-application-development-java-client-libraries-bindings-java:
1614

17-
- The data layer (``bindings-java``):
18-
A Java-idiomatic layer based on the Ledger API generated classes. This layer simplifies the code required to work
19-
with the Ledger API. It contains the toProto and fromProto methods to interact with the generated classes for the
20-
gRPC Ledger API.
21-
Additionally, it provides a set of classes that represent the basic Daml data types in Java
22-
and are utilized by the :ref:`Daml Codegen for Java <component-howtos-application-development-daml-codegen-java>`
23-
to generate user-defined Daml code equivalent in Java.
24-
25-
This layer is implemented in the Java package ``com.daml.ledger.javaapi.data``.
26-
27-
.. _component-howtos-application-development-java-client-libraries-bindings-rxjava:
28-
29-
- The reactive layer (``bindings-rxjava``):
30-
A thin layer built on top of the Ledger API services generated classes. It offers a client implementation of the
31-
gRPC Ledger API based on `RxJava <https://github.com/ReactiveX/RxJava>`_, a library for composing asynchronous and
32-
event-based programs using observable sequences for the Java VM.
33-
34-
For each Ledger API service, there is a reactive counterpart with a matching name. For instance, the reactive
35-
counterpart of ``StateServiceGrpc`` is ``StateClient``.
15+
The Java client library (``bindings-java``) is a Java-idiomatic layer based on the Ledger API generated classes.
16+
This layer simplifies the code required to work with the Ledger API. It contains the ``toProto`` and ``fromProto``
17+
methods to interact with the generated classes for the gRPC Ledger API.
3618

37-
The reactive layer also exposes the main interface representing a client connecting via the gRPC Ledger API. This
38-
interface is called ``LedgerClient`` and the main implementation working against a Canton Ledger is the
39-
``DamlLedgerClient``.
19+
Additionally, it provides a set of classes that represent the basic Daml data types in Java and are utilized by the
20+
:ref:`Daml Codegen for Java <component-howtos-application-development-daml-codegen-java>` to generate user-defined Daml
21+
code equivalent in Java.
4022

41-
This layer is implemented in the Java package ``com.daml.ledger.rxjava``.
23+
This library is implemented in the Java package ``com.daml.ledger.javaapi.data``.
4224

4325
Install
4426
-------
4527

4628
Find the available versions of the Java client libraries in the Maven Central Repository:
4729

48-
- `bindings-java <https://search.maven.org/artifact/com.daml/bindings-java>`_
49-
- `bindings-rxjava <https://search.maven.org/artifact/com.daml/bindings-rxjava>`_
30+
`bindings-java <https://search.maven.org/artifact/com.daml/bindings-java>`_
5031

5132

5233
References
5334
-------------
5435

55-
See the `JavaDoc reference documentation </javadocs/3.3/index.html>`_.
36+
See the `JavaDoc reference documentation </javadocs/3.4/index.html>`_.

sdk/docs/manually-written/sdk/component-howtos/application-development/daml-codegen-java.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Specify the above settings in the ``codegen`` element of the Daml project file `
5050

5151
Here is an example::
5252

53-
sdk-version: 3.4.0-rc2
53+
sdk-version: 3.4.9
5454
name: quickstart
5555
source: daml
5656
init-script: Main:initialize
@@ -241,7 +241,6 @@ In particular, the codegen generates a file that defines six Java classes and on
241241
#. ``Bar.Contract``
242242
#. ``Bar.CreateAnd``
243243
#. ``Bar.JsonDecoder$``
244-
#. ``Bar.ByKey``
245244
#. ``Bar.Exercises``
246245

247246
.. code-block:: java
@@ -250,24 +249,30 @@ In particular, the codegen generates a file that defines six Java classes and on
250249
251250
package com.acme.templates;
252251
253-
public class Bar extends Template {
254-
255-
public static final Identifier TEMPLATE_ID = new Identifier("some-package-id", "Com.Acme.Templates", "Bar");
252+
public final class Bar extends Template {
253+
public static final Identifier TEMPLATE_ID = new Identifier("#some-package-name", "Templates", "Bar");
254+
public static final Identifier TEMPLATE_ID_WITH_PACKAGE_ID = new Identifier("some-package-id", "Templates", "Bar");
255+
public static final String PACKAGE_ID = "some-package-id";
256+
public static final String PACKAGE_NAME = "some-package-name";
257+
public static final PackageVersion PACKAGE_VERSION = new PackageVersion(new int[] {0, 0, 1});
256258
257259
public static final Choice<Bar, Archive, Unit> CHOICE_Archive =
258260
Choice.create(/* ... */);
259261
260-
public static final ContractCompanion.WithKey<Contract, ContractId, Bar, BarKey> COMPANION =
261-
new ContractCompanion.WithKey<>("com.acme.templates.Bar",
262-
TEMPLATE_ID, ContractId::new, Bar::fromValue, Contract::new, e -> BarKey.fromValue(e), List.of(CHOICE_Archive));
262+
public static final Choice<Bar, Bar_SomeChoice, Boolean> CHOICE_Bar_SomeChoice =
263+
Choice.create(/* ... */);
264+
265+
public static final ContractCompanion.WithoutKey<Contract, ContractId, Bar> COMPANION =
266+
new ContractCompanion.WithoutKey<>(new ContractTypeCompanion.Package(Bar.PACKAGE_ID, Bar.PACKAGE_NAME, Bar.PACKAGE_VERSION),
267+
"com.acme.templates.Bar", TEMPLATE_ID, ContractId::new,
268+
v -> Bar.templateValueDecoder().decode(v), Bar::fromJson, Contract::new,
269+
List.of(CHOICE_Archive, CHOICE_Bar_SomeChoice));
263270
264271
public final String owner;
265272
public final String name;
266273
267274
public CreateAnd createAnd() { /* ... */ }
268275
269-
public static ByKey byKey(BarKey key) { /* ... */ }
270-
271276
public static class ContractId extends com.daml.ledger.javaapi.data.codegen.ContractId<Bar>
272277
implements Exercises<ExerciseCommand> {
273278
// inherited:
@@ -282,7 +287,7 @@ In particular, the codegen generates a file that defines six Java classes and on
282287
default Cmd exerciseBar_SomeChoice(String aName) { /* ... */ }
283288
}
284289
285-
public static class Contract extends ContractWithKey<ContractId, Bar, BarKey> {
290+
public static class Contract extends com.daml.ledger.javaapi.data.codegen.Contract<ContractId, Bar> {
286291
// inherited:
287292
public final ContractId id;
288293
public final Bar data;
@@ -295,13 +300,8 @@ In particular, the codegen generates a file that defines six Java classes and on
295300
implements Exercises<CreateAndExerciseCommand> { /* ... */ }
296301
297302
public static class JsonDecoder$ { /* ... */ }
298-
299-
public static final class ByKey
300-
extends com.daml.ledger.javaapi.data.codegen.ByKey
301-
implements Exercises<ExerciseByKeyCommand> { /* ... */ }
302303
}
303304
304-
Note that ``byKey`` and ``ByKey`` will only be generated for templates that define a key.
305305
306306
Variants (a.k.a. sum types)
307307
~~~~~~~~~~~~~~~~~~~~~~~~~~~

sdk/docs/manually-written/sdk/component-howtos/application-development/daml-codegen-javascript.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Specify the above settings in the ``codegen`` element of the Daml project file `
4949

5050
Here is an example::
5151

52-
sdk-version: 3.4.0-rc2
52+
sdk-version: 3.4.9
5353
name: quickstart
5454
source: daml
5555
init-script: Main:initialize

sdk/docs/manually-written/sdk/component-howtos/smart-contracts/assistant.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ For Linux and MacOS, run
2424

2525
.. code:: bash
2626
27-
curl -sSL https://get.daml.com/ | sh -s 3.4.0-rc2
27+
curl -sSL https://get.daml.com/ | sh -s 3.4.9
2828
2929
For Windows 10/11, download and run the installer from the `GitHub releases page <https://github.com/digital-asset/daml/releases>`__.
3030

sdk/docs/manually-written/sdk/sdlc-howtos/applications/develop/contracts-and-transactions-in-java.rst

Lines changed: 66 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -43,48 +43,38 @@ Find the available versions in the `Maven Central Repository <https://search.mav
4343
Access the gRPC Ledger API using Java bindings
4444
----------------------------------------------
4545

46-
The :ref:`Java bindings reactive library <component-howtos-application-development-java-client-libraries-bindings-rxjava>` provides a set of classes that allow you to access the gRPC Ledger API.
46+
The ``bindings-java`` library comes pre-packaged with the generated gRPC stubs allowing you to access the Ledger API.
4747

48-
For each Ledger API service, there is a reactive counterpart with a matching name. For instance, the reactive
49-
counterpart of ``UpdateServiceGrpc`` is ``UpdateClient``.
50-
51-
The library also exposes the main interface representing a client connecting via the gRPC Ledger API. This interface is
52-
called ``LedgerClient`` and the main implementation working against a Daml ledger is the ``DamlLedgerClient``.
53-
54-
55-
Set up dependencies in your project
56-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57-
58-
To use the aforementioned classes, add the following dependencies to your project:
59-
60-
.. literalinclude:: ./code-snippets/pom.xml
61-
:language: XML
62-
:start-after: <!-- start snippet: dependency bindings rxjava -->
63-
:end-before: <!-- end snippet: dependency bindings rxjava -->
64-
:dedent: 8
65-
66-
.. note::
67-
68-
Replace ``YOUR_SDK_VERSION`` with the version of your SDK.
69-
70-
Find the available versions in the `Maven Central Repository <https://search.maven.org/artifact/com.daml/bindings-rxjava>`__.
48+
For each Ledger API service, there is a dedicated Java class with a matching name. For instance, the gRPC
49+
counterpart of ``CommandSubmissionService`` is ``CommandSubmissionServiceGrpc``.
7150

7251
.. _howto-applications-work-with-contracts-java-connect:
7352

7453
Connect to the ledger
7554
^^^^^^^^^^^^^^^^^^^^^
7655

77-
Create an instance of a ``DamlLedgerClient`` to establish a connection to the ledger and access the Ledger API services.
78-
To create an instance of a ledger client, use the static ``newBuilder(..)`` method to create a ``DamlLedgerClient.Builder``.
79-
Then use the builder instance to create the ``DamlLedgerClient``. Finally, call the ``connect()`` method on the client.
56+
To establish a connection to the ledger and access the Ledger API services create an instance of a ``ManagedChannel``
57+
using the static ``NettyChannelBuilder.forAddress(..)`` method. Then, call the factory method on the respective service
58+
to create a stub e.g. ``CommandSubmissionServiceGrpc.newFutureStub``. Use one of the helper classes provided by the
59+
``bindings-java`` to create an object representing the request service request arguments, convert them to a proto message.
60+
Finally, call the desired method offered by the service.
8061

8162
.. code-block:: java
8263
83-
// Create a client object to access services on the ledger.
84-
DamlLedgerClient client = DamlLedgerClient.newBuilder(ledgerhost, ledgerport).build();
64+
// Create a managed channel object pointing to the Ledger API address.
65+
ManagedChannel channel = NettyChannelBuilder.forAddress(host, port).usePlaintext().build();
66+
67+
// Create a stub connecting to the desired service on the ledger.
68+
CommandSubmissionServiceFutureStub submissionService = CommandSubmissionServiceGrpc.newFutureStub(channel);
69+
70+
// Create an object representing the service call arguments
71+
CommandsSubmission commandsSubmission = CommandsSubmission.create(...);
72+
73+
// Convert the command submission to a proto data structure
74+
final var request = SubmitRequest.toProto(commandsSubmission);
8575
86-
// Connects to the ledger and runs initial validation.
87-
client.connect();
76+
// Issue the service call
77+
final var response = submissionService.submit(request)
8878
8979
.. _howto-applications-work-with-contracts-java-authorization:
9080

@@ -94,16 +84,35 @@ Perform authorization
9484
Some ledgers enforce authorization and require to send an access token along with each request. For more details on
9585
authorization, read the :ref:`Authorization <authorization>` overview.
9686

97-
To use the same token for all Ledger API requests, use the ``withAccessToken`` method of the ``DamlLedgerClient`` builder.
98-
This allows you to not pass a token explicitly for every call.
99-
100-
If your application is long-lived and your tokens are bound to expire, reload the necessary token when needed and pass
101-
it explicitly for every call. Every client method has an overload that allows a token to be passed, as in the following example:
87+
To use the same token for all Ledger API requests, use the ``withCallCredentials`` method of the service stub class.
88+
As an argument, this method takes a class that derives from ``CallCredentials``. Implement your own derivation that
89+
provides the token in the header.
10290

10391
.. code-block:: java
10492
105-
stateClient.getLedgerEnd(); // Uses the token specified when constructing the client
106-
stateClient.getLedgerEnd(accessToken); // Override the token for this call exclusively
93+
public final class LedgerCallCredentials extends CallCredentials {
94+
95+
private static Metadata.Key<String> header =
96+
Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER);
97+
98+
private final String token;
99+
100+
public LedgerCallCredentials(String token) {
101+
super();
102+
this.token = token;
103+
}
104+
105+
@Override
106+
public void applyRequestMetadata(
107+
RequestInfo requestInfo, Executor appExecutor, MetadataApplier applier) {
108+
Metadata metadata = new Metadata();
109+
metadata.put(LedgerCallCredentials.header, token.startsWith("Bearer ") ? token : "Bearer " + token);
110+
applier.apply(metadata);
111+
}
112+
}
113+
114+
If your application is long-lived and your tokens are bound to expire, reload the necessary token when needed and pass
115+
it explicitly for every call.
107116

108117
If you are communicating with a ledger that verifies authorization it is very important to secure the communication
109118
channel to prevent your tokens to be exposed to man-in-the-middle attacks. The next chapter describes how to enable TLS.
@@ -113,39 +122,38 @@ channel to prevent your tokens to be exposed to man-in-the-middle attacks. The n
113122
Connect securely
114123
^^^^^^^^^^^^^^^^
115124

116-
The builders created by ``DamlLedgerClient.newBuilder`` default to a plaintext connection.
117-
The Java bindings library lets you connect to a ledger via a secure connection. To do so, invoke ``withSslContext`` and
118-
pass an ``SslContext``.
125+
The builders created by ``NettyChannelBuilder.forAddress`` default to a tls connection, where the keys are taken from
126+
the configured Java Keystore. You can override this behavior by providing your own cryptographic settings. To do so,
127+
invoke ``sslContext`` and pass an ``SslContext``.
128+
129+
.. code-block:: java
130+
131+
NettyChannelBuilder.forAddress(host, port)
132+
.useTransportSecurity()
133+
.sslContext(sslContext)
134+
.build();
119135
120136
.. warning::
121137

122-
Use the default plaintext connection only when connecting to a locally running ledger for development purposes.
138+
You can also configure a plaintext connection invoking ``usePlaintext()``. Use it only when connecting to a locally
139+
running ledger for development purposes.
123140

124141
Secure connections to a ledger must be configured to use client authentication certificates, which can be provided by a ledger operator.
125142

126143
For information on how to set up an ``SslContext`` with the provided certificates for client authentication, please consult the gRPC documentation on
127144
`TLS with OpenSSL <https://github.com/grpc/grpc-java/blob/master/SECURITY.md#tls-with-openssl>`_ as well as the
128145
`HelloWorldClientTls <https://github.com/grpc/grpc-java/blob/70b1b1696a258ffe042c7124217e3a7894821444/examples/src/main/java/io/grpc/examples/helloworldtls/HelloWorldClientTls.java#L46-L57>`_ example of the ``grpc-java`` project.
129146

130-
Advanced connection settings
131-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
132-
133-
Sometimes the default settings for gRPC connections or channels are not suitable. For such situations, create a custom
134-
`NettyChannelBuilder <https://grpc.github.io/grpc-java/javadoc/io/grpc/netty/NettyChannelBuilder.html>`_ object and
135-
pass the it to the ``newBuilder`` static method defined over `DamlLedgerClient </javadocs/3.3/com/daml/ledger/rxjava/DamlLedgerClient.html>`_.
136-
137-
Alternative ways to access the Ledger API
138-
-----------------------------------------
139-
140-
The Java bindings client library is not the only way to access the Ledger API. You can also use the gRPC bindings or OpenAPI
141-
bindings directly.
147+
Use asynchronous stubs
148+
----------------------
142149

143-
Use gRPC bindings
144-
^^^^^^^^^^^^^^^^^
150+
The classes generated for the Ledger API gRPC services come in several flavors: blocking, future-based and asynchronous.
151+
The latter is the recommended way of interacting with the gRPC layer. In the example of the ``CommandService`` utilized
152+
above they are called ``CommandServiceBlockingStub``, ``CommandServiceFutureStub`` and ``CommandServiceStub`` respectively.
145153

146154
For each gRPC endpoint that you want to call from your Java application, create a gRPC `StreamObserver <https://grpc.github.io/grpc-java/javadoc/io/grpc/stub/StreamObserver.html>`_ providing
147-
implementations of the onNext, onError and onComplete observer methods.
148-
To decode and encode the gRPC messages, use the fromProto and toProto methods of the generated classes of the :ref:`Java
155+
implementations of the ``onNext``, ``onError`` and ``onComplete`` observer methods.
156+
To decode and encode the gRPC messages, use the ``fromProto`` and ``toProto`` methods of the generated classes of the :ref:`Java
149157
bindings library <component-howtos-application-development-java-client-libraries-bindings-java>`.
150158

151159

sdk/docs/sharable/sdk/component-howtos/application-development/client-libraries/java-client-libraries.rst

Lines changed: 9 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/docs/sharable/sdk/component-howtos/application-development/code-snippets/Com/Acme/Templates.daml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)