diff --git a/.github/workflows/automerge-bot.yml b/.github/workflows/automerge-bot.yml
index 70e3c8814..f296eef7f 100644
--- a/.github/workflows/automerge-bot.yml
+++ b/.github/workflows/automerge-bot.yml
@@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Install dependencies
run: pip install PyGithub
- name: Automerge and update
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 37f0f0899..b6bd1b413 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -31,9 +31,9 @@ jobs:
DAPR_CLI_REF:
DAPR_REF:
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Set up OpenJDK ${{ env.JDK_VER }}
- uses: actions/setup-java@v2.5.0
+ uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: ${{ env.JDK_VER }}
@@ -45,14 +45,14 @@ jobs:
with:
go-version: ${{ env.GOVER }}
- name: Checkout Dapr CLI repo to override dapr command.
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
if: env.DAPR_CLI_REF != ''
with:
repository: dapr/cli
ref: ${{ env.DAPR_CLI_REF }}
path: cli
- name: Checkout Dapr repo to override daprd.
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
if: env.DAPR_REF != ''
with:
repository: dapr/dapr
@@ -123,9 +123,9 @@ jobs:
GPG_KEY: ${{ secrets.GPG_KEY }}
GPG_PWD: ${{ secrets.GPG_PWD }}
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Set up OpenJDK ${{ env.JDK_VER }}
- uses: actions/setup-java@v2.5.0
+ uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: ${{ env.JDK_VER }}
diff --git a/.github/workflows/dapr_bot.yml b/.github/workflows/dapr_bot.yml
index c1cb92306..4d3130736 100644
--- a/.github/workflows/dapr_bot.yml
+++ b/.github/workflows/dapr_bot.yml
@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Comment analyzer
- uses: actions/github-script@v5
+ uses: actions/github-script@v6
with:
github-token: ${{secrets.DAPR_BOT_TOKEN}}
script: |
@@ -20,7 +20,8 @@ jobs:
if (!isFromPulls && commentBody && commentBody.indexOf("/assign") == 0) {
if (!issue.assignees || issue.assignees.length === 0) {
- await github.issues.addAssignees({
+ // See https://github.com/actions/github-script#breaking-changes-in-v5
+ await github.rest.issues.addAssignees({
owner: issue.owner,
repo: issue.repo,
issue_number: issue.number,
diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml
new file mode 100644
index 000000000..e1fc57a0b
--- /dev/null
+++ b/.github/workflows/fossa.yml
@@ -0,0 +1,46 @@
+#
+# Copyright 2021 The Dapr Authors
+# 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.
+#
+
+name: fossa
+on:
+ push:
+ branches:
+ - master
+ - release-*
+ tags:
+ - v*
+ pull_request:
+ branches:
+ - master
+ - release-*
+ workflow_dispatch: {}
+jobs:
+ fossa-scan:
+ if: github.repository_owner == 'dapr' # FOSSA is not intended to run on forks.
+ runs-on: ubuntu-latest
+ env:
+ FOSSA_API_KEY: b88e1f4287c3108c8751bf106fb46db6 # This is a push-only token that is safe to be exposed.
+ steps:
+ - name: "Checkout code"
+ uses: actions/checkout@v2
+
+ - name: "Run FOSSA Scan"
+ uses: fossas/fossa-action@main # Use a specific version if locking is preferred
+ with:
+ api-key: ${{ env.FOSSA_API_KEY }}
+
+ - name: "Run FOSSA Test"
+ uses: fossas/fossa-action@main # Use a specific version if locking is preferred
+ with:
+ api-key: ${{ env.FOSSA_API_KEY }}
+ run-tests: true
diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml
index 4254b1097..a11ac3565 100644
--- a/.github/workflows/validate.yml
+++ b/.github/workflows/validate.yml
@@ -42,9 +42,9 @@ jobs:
DAPR_CLI_REF:
DAPR_REF:
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Set up OpenJDK ${{ env.JDK_VER }}
- uses: actions/setup-java@v2.5.0
+ uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: ${{ env.JDK_VER }}
@@ -56,14 +56,14 @@ jobs:
with:
go-version: ${{ env.GOVER }}
- name: Checkout Dapr CLI repo to override dapr command.
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
if: env.DAPR_CLI_REF != ''
with:
repository: dapr/cli
ref: ${{ env.DAPR_CLI_REF }}
path: cli
- name: Checkout Dapr repo to override daprd.
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
if: env.DAPR_REF != ''
with:
repository: dapr/dapr
diff --git a/README.md b/README.md
index 2479f730e..d85f0dfd2 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,8 @@
[](https://github.com/dapr/java-sdk/actions?workflow=Build)
[](https://discord.com/channels/778680217417809931/778749797242765342)
[](https://codecov.io/gh/dapr/java-sdk)
-[](https://opensource.org/licenses/MIT)
+[](https://opensource.org/licenses/Apache-2.0)
+[](https://app.fossa.com/projects/custom%2B162%2Fgithub.com%2Fdapr%2Fjava-sdk?ref=badge_shield)
[](https://search.maven.org/search?q=g:%22io.dapr%22%20AND%20a:%22dapr-sdk%22)
This is the Dapr SDK for Java, including the following features:
@@ -18,8 +19,8 @@ This is the Dapr SDK for Java, including the following features:
#### Pre-Requisites
* JDK 11 or above - the published jars are compatible with Java 8:
+ * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
* [AdoptOpenJDK 11 - LTS](https://adoptopenjdk.net/)
- * [Oracle's JDK 15](https://www.oracle.com/java/technologies/javase-jdk15-downloads.html)
* [Oracle's JDK 11 - LTS](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html)
* [OpenJDK](https://openjdk.java.net/)
* Java IDE installed:
@@ -161,6 +162,19 @@ This SDK provides a basic serialization for request/response objects but also fo
```
+#### How to extend DaprClientBuilder
+
+This gives a way to provide a managed grpc channel to your DaprClient.
+
+ ```java
+
+ DaprExtensibleClientBuilder daprClientBuilder = new DaprExtensibleClientBuilder();
+ ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder("localhost:8000", TlsChannelCredentials.create())
+ .executor(Executors.newFixedThreadPool(20));
+ DaprClient client = daprClientBuilder.withManagedGrpcChannel(managedChannelBuilder.build()).build();
+ ```
+
+
#### Debug Java application or Dapr's Java SDK
**In IntelliJ Community Edition, consider [debugging in IntelliJ](https://docs.dapr.io/developing-applications/ides/intellij/).**
diff --git a/examples/src/main/java/io/dapr/examples/actors/README.md b/examples/src/main/java/io/dapr/examples/actors/README.md
index ed5d93745..3f9100ff5 100644
--- a/examples/src/main/java/io/dapr/examples/actors/README.md
+++ b/examples/src/main/java/io/dapr/examples/actors/README.md
@@ -14,7 +14,10 @@ This example contains the follow classes:
## Pre-requisites
* [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/).
-* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
+* Java JDK 11 (or greater):
+ * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
+ * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11)
+ * [OpenJDK 11](https://jdk.java.net/11/)
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
### Checking out the code
diff --git a/examples/src/main/java/io/dapr/examples/bindings/http/README.md b/examples/src/main/java/io/dapr/examples/bindings/http/README.md
index dcbe5e6ca..b042e3ba8 100644
--- a/examples/src/main/java/io/dapr/examples/bindings/http/README.md
+++ b/examples/src/main/java/io/dapr/examples/bindings/http/README.md
@@ -18,7 +18,10 @@ Visit [this](https://github.com/dapr/components-contrib/tree/master/bindings) li
## Pre-requisites
* [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/).
-* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
+* Java JDK 11 (or greater):
+ * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
+ * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11)
+ * [OpenJDK 11](https://jdk.java.net/11/)
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
### Checking out the code
diff --git a/examples/src/main/java/io/dapr/examples/configuration/grpc/README.md b/examples/src/main/java/io/dapr/examples/configuration/grpc/README.md
index b78491204..3785e9f5f 100644
--- a/examples/src/main/java/io/dapr/examples/configuration/grpc/README.md
+++ b/examples/src/main/java/io/dapr/examples/configuration/grpc/README.md
@@ -12,7 +12,10 @@ The java SDK exposes several methods for this -
## Pre-requisites
* [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/).
-* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
+* Java JDK 11 (or greater):
+ * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
+ * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11)
+ * [OpenJDK 11](https://jdk.java.net/11/)
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
### Checking out the code
diff --git a/examples/src/main/java/io/dapr/examples/exception/README.md b/examples/src/main/java/io/dapr/examples/exception/README.md
index 50549f613..da6d6d356 100644
--- a/examples/src/main/java/io/dapr/examples/exception/README.md
+++ b/examples/src/main/java/io/dapr/examples/exception/README.md
@@ -5,7 +5,10 @@ This sample illustrates how to handle exceptions in Dapr.
## Pre-requisites
* [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/).
-* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
+* Java JDK 11 (or greater):
+ * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
+ * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11)
+ * [OpenJDK 11](https://jdk.java.net/11/)
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
### Checking out the code
diff --git a/examples/src/main/java/io/dapr/examples/invoke/grpc/README.md b/examples/src/main/java/io/dapr/examples/invoke/grpc/README.md
index f1b6ded84..16e632222 100644
--- a/examples/src/main/java/io/dapr/examples/invoke/grpc/README.md
+++ b/examples/src/main/java/io/dapr/examples/invoke/grpc/README.md
@@ -5,7 +5,10 @@ In this example, you will run a Grpc service and client using Dapr's invoke feat
## Pre-requisites
* [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/).
-* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
+* Java JDK 11 (or greater):
+ * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
+ * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11)
+ * [OpenJDK 11](https://jdk.java.net/11/)
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
### Checking out the code
diff --git a/examples/src/main/java/io/dapr/examples/invoke/http/README.md b/examples/src/main/java/io/dapr/examples/invoke/http/README.md
index 05df6af21..37af2068f 100644
--- a/examples/src/main/java/io/dapr/examples/invoke/http/README.md
+++ b/examples/src/main/java/io/dapr/examples/invoke/http/README.md
@@ -15,7 +15,10 @@ This sample uses the Client provided in Dapr Java SDK invoking a remote method.
## Pre-requisites
* [Dapr and Dapr CLI](https://docs.dapr.io/getting-started/install-dapr/).
-* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
+* Java JDK 11 (or greater):
+ * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
+ * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11)
+ * [OpenJDK 11](https://jdk.java.net/11/)
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
### Checking out the code
diff --git a/examples/src/main/java/io/dapr/examples/pubsub/http/CloudEventPublisher.java b/examples/src/main/java/io/dapr/examples/pubsub/http/CloudEventPublisher.java
index c5dbf56ef..e75afa0ec 100644
--- a/examples/src/main/java/io/dapr/examples/pubsub/http/CloudEventPublisher.java
+++ b/examples/src/main/java/io/dapr/examples/pubsub/http/CloudEventPublisher.java
@@ -18,7 +18,6 @@
import io.dapr.client.domain.CloudEvent;
import io.dapr.client.domain.Metadata;
import io.dapr.client.domain.PublishEventRequest;
-import io.dapr.client.domain.PublishEventRequestBuilder;
import java.util.UUID;
diff --git a/examples/src/main/java/io/dapr/examples/pubsub/http/README.md b/examples/src/main/java/io/dapr/examples/pubsub/http/README.md
index 90c6e4885..0d25dee86 100644
--- a/examples/src/main/java/io/dapr/examples/pubsub/http/README.md
+++ b/examples/src/main/java/io/dapr/examples/pubsub/http/README.md
@@ -10,7 +10,10 @@ This sample uses the HTTP Client provided in Dapr Java SDK for subscribing, and
## Pre-requisites
* [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/).
-* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
+* Java JDK 11 (or greater):
+ * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
+ * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11)
+ * [OpenJDK 11](https://jdk.java.net/11/)
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
### Checking out the code
diff --git a/examples/src/main/java/io/dapr/examples/secrets/README.md b/examples/src/main/java/io/dapr/examples/secrets/README.md
index 24a1ddb38..ecc07169e 100644
--- a/examples/src/main/java/io/dapr/examples/secrets/README.md
+++ b/examples/src/main/java/io/dapr/examples/secrets/README.md
@@ -20,7 +20,10 @@ Visit [this](https://github.com/dapr/components-contrib/tree/master/secretstores
## Pre-requisites
* [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/).
-* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
+* Java JDK 11 (or greater):
+ * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
+ * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11)
+ * [OpenJDK 11](https://jdk.java.net/11/)
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
* Hashicorp's vault client [installed](https://www.vaultproject.io/docs/install/).
diff --git a/examples/src/main/java/io/dapr/examples/state/README.md b/examples/src/main/java/io/dapr/examples/state/README.md
index 9af078b75..a002c41a6 100644
--- a/examples/src/main/java/io/dapr/examples/state/README.md
+++ b/examples/src/main/java/io/dapr/examples/state/README.md
@@ -5,7 +5,10 @@ This sample illustrates the capabilities provided by Dapr Java SDK for state man
## Pre-requisites
* [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/).
-* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
+* Java JDK 11 (or greater):
+ * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
+ * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11)
+ * [OpenJDK 11](https://jdk.java.net/11/)
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
### Checking out the code
diff --git a/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java b/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java
index 9a3c9f115..9078fb0d5 100644
--- a/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java
+++ b/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java
@@ -17,7 +17,6 @@
import io.dapr.client.DaprClientBuilder;
import io.dapr.client.domain.HttpExtension;
import io.dapr.client.domain.InvokeMethodRequest;
-import io.dapr.client.domain.InvokeMethodRequestBuilder;
import io.dapr.examples.OpenTelemetryConfig;
import io.dapr.utils.TypeRef;
import io.opentelemetry.api.OpenTelemetry;
diff --git a/examples/src/main/java/io/dapr/examples/tracing/README.md b/examples/src/main/java/io/dapr/examples/tracing/README.md
index 847e45d62..4294a795a 100644
--- a/examples/src/main/java/io/dapr/examples/tracing/README.md
+++ b/examples/src/main/java/io/dapr/examples/tracing/README.md
@@ -17,7 +17,10 @@ This sample uses the Client provided in Dapr Java SDK invoking a remote method a
## Pre-requisites
* [Dapr and Dapr CLI](https://docs.dapr.io/getting-started/install-dapr/).
-* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
+* Java JDK 11 (or greater):
+ * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
+ * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11)
+ * [OpenJDK 11](https://jdk.java.net/11/)
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
* [Configure Redis](https://docs.dapr.io/getting-started/configure-redis/) as a state store for Dapr.
diff --git a/examples/src/main/java/io/dapr/examples/tracing/TracingDemoMiddleServiceController.java b/examples/src/main/java/io/dapr/examples/tracing/TracingDemoMiddleServiceController.java
index d2d4c03cc..9a3111e85 100644
--- a/examples/src/main/java/io/dapr/examples/tracing/TracingDemoMiddleServiceController.java
+++ b/examples/src/main/java/io/dapr/examples/tracing/TracingDemoMiddleServiceController.java
@@ -16,7 +16,6 @@
import io.dapr.client.DaprClient;
import io.dapr.client.domain.HttpExtension;
import io.dapr.client.domain.InvokeMethodRequest;
-import io.dapr.client.domain.InvokeMethodRequestBuilder;
import io.dapr.examples.OpenTelemetryInterceptor;
import io.dapr.utils.TypeRef;
import io.opentelemetry.context.Context;
diff --git a/examples/src/main/java/io/dapr/examples/unittesting/README.md b/examples/src/main/java/io/dapr/examples/unittesting/README.md
index 5dc89c4d9..cc1073a38 100644
--- a/examples/src/main/java/io/dapr/examples/unittesting/README.md
+++ b/examples/src/main/java/io/dapr/examples/unittesting/README.md
@@ -5,7 +5,10 @@ This sample illustrates how applications can write unit testing with Dapr's Java
## Pre-requisites
* [Dapr and Dapr Cli](https://docs.dapr.io/getting-started/install-dapr/).
-* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
+* Java JDK 11 (or greater):
+ * [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
+ * [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11)
+ * [OpenJDK 11](https://jdk.java.net/11/)
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
### Checking out the code
diff --git a/sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java b/sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java
index c4e393972..35e77ce5e 100644
--- a/sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java
+++ b/sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java
@@ -20,7 +20,7 @@
import io.dapr.client.domain.CloudEvent;
import io.dapr.client.domain.HttpExtension;
import io.dapr.client.domain.Metadata;
-import io.dapr.client.domain.PublishEventRequestBuilder;
+import io.dapr.client.domain.PublishEventRequest;
import io.dapr.it.BaseIT;
import io.dapr.it.DaprRun;
import io.dapr.serializer.DaprObjectSerializer;
@@ -195,9 +195,8 @@ public String getContentType() {
cloudEvent.setDatacontenttype("text/plain");
//Publishing a cloud event.
- client.publishEvent(new PublishEventRequestBuilder(PUBSUB_NAME, TOPIC_NAME, cloudEvent)
- .withContentType("application/cloudevents+json")
- .build()).block();
+ client.publishEvent(new PublishEventRequest(PUBSUB_NAME, TOPIC_NAME, cloudEvent)
+ .setContentType("application/cloudevents+json")).block();
System.out.println("Published one cloud event.");
Thread.sleep(3000);
diff --git a/sdk/pom.xml b/sdk/pom.xml
index 1244351ee..08a9027b3 100644
--- a/sdk/pom.xml
+++ b/sdk/pom.xml
@@ -167,8 +167,7 @@
LINE
COVEREDRATIO
-
- 79%
+ 80%
diff --git a/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java b/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java
index 855c6013e..750aeedae 100644
--- a/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java
+++ b/sdk/src/main/java/io/dapr/client/DaprClientBuilder.java
@@ -53,6 +53,11 @@ public class DaprClientBuilder {
*/
private DaprObjectSerializer stateSerializer;
+ /**
+ * Managed gRPC channel
+ */
+ protected ManagedChannel channel;
+
/**
* Creates a constructor for DaprClient.
*
@@ -157,8 +162,10 @@ private DaprClient buildDaprClientGrpc() {
if (port <= 0) {
throw new IllegalArgumentException("Invalid port.");
}
- ManagedChannel channel = ManagedChannelBuilder.forAddress(
- Properties.SIDECAR_IP.get(), port).usePlaintext().build();
+ if(channel == null) {
+ channel = ManagedChannelBuilder.forAddress(
+ Properties.SIDECAR_IP.get(), port).usePlaintext().build();
+ }
Closeable closeableChannel = () -> {
if (channel != null && !channel.isShutdown()) {
channel.shutdown();
@@ -173,7 +180,7 @@ private DaprClient buildDaprClientGrpc() {
*
* @return DaprClient over HTTP.
*/
- private DaprClient buildDaprClientHttp() {
+ protected DaprClient buildDaprClientHttp() {
return new DaprClientHttp(this.daprHttpBuilder.build(), this.objectSerializer, this.stateSerializer);
}
}
diff --git a/sdk/src/main/java/io/dapr/client/DaprExtensibleClientBuilder.java b/sdk/src/main/java/io/dapr/client/DaprExtensibleClientBuilder.java
new file mode 100644
index 000000000..f460e2df0
--- /dev/null
+++ b/sdk/src/main/java/io/dapr/client/DaprExtensibleClientBuilder.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2021 The Dapr Authors
+ * 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.
+*/
+
+package io.dapr.client;
+
+import io.grpc.ManagedChannel;
+
+/**
+ * A builder for the DaprClient.
+ */
+public class DaprExtensibleClientBuilder extends DaprClientBuilder{
+
+ public DaprClientBuilder withManagedGrpcChannel(ManagedChannel channel){
+ this.channel = channel;
+ return this;
+ }
+
+ @Override
+ protected DaprClient buildDaprClientHttp() {
+ throw new UnsupportedOperationException("Http protocol is not supported in this builder.");
+ }
+
+ }
diff --git a/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequest.java b/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequest.java
index ffdacde29..ec623a3e6 100644
--- a/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequest.java
+++ b/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequest.java
@@ -31,6 +31,12 @@ public class DeleteStateRequest {
private StateOptions stateOptions;
+ /**
+ * Constructor for DeleteStateRequest.
+ *
+ * @param storeName Name of the state store
+ * @param key Key present in the state store
+ */
public DeleteStateRequest(String storeName, String key) {
this.stateStoreName = storeName;
this.key = key;
diff --git a/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequestBuilder.java
deleted file mode 100644
index 0ad17d8d6..000000000
--- a/sdk/src/main/java/io/dapr/client/domain/DeleteStateRequestBuilder.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2021 The Dapr Authors
- * 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.
-*/
-
-package io.dapr.client.domain;
-
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * Builds a request to delete a state by key.
- * Deprecated in favor of @see{@link DeleteStateRequest}.
- * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0.
- */
-@Deprecated
-public class DeleteStateRequestBuilder {
-
- private final String stateStoreName;
-
- private final String key;
-
- private Map metadata;
-
- private String etag;
-
- private StateOptions stateOptions;
-
- public DeleteStateRequestBuilder(String stateStoreName, String key) {
- this.stateStoreName = stateStoreName;
- this.key = key;
- }
-
- public DeleteStateRequestBuilder withMetadata(Map metadata) {
- this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata);
- return this;
- }
-
- public DeleteStateRequestBuilder withEtag(String etag) {
- this.etag = etag;
- return this;
- }
-
- public DeleteStateRequestBuilder withStateOptions(StateOptions stateOptions) {
- this.stateOptions = stateOptions;
- return this;
- }
-
- /**
- * Builds a request object.
- *
- * @return Request object.
- */
- public DeleteStateRequest build() {
- DeleteStateRequest request = new DeleteStateRequest(this.stateStoreName, this.key);
- request.setMetadata(metadata);
- request.setEtag(this.etag);
- request.setStateOptions(this.stateOptions);
- return request;
- }
-
-}
diff --git a/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequest.java b/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequest.java
index 988f1d988..91615b26e 100644
--- a/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequest.java
+++ b/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequest.java
@@ -17,6 +17,9 @@
import java.util.List;
import java.util.Map;
+/**
+ * A request for executing state transaction operations.
+ */
public class ExecuteStateTransactionRequest {
/**
@@ -34,6 +37,11 @@ public class ExecuteStateTransactionRequest {
*/
private Map metadata;
+ /**
+ * Constructor for ExecuteStateTransactionRequest.
+ *
+ * @param stateStoreName Name of the state store
+ */
public ExecuteStateTransactionRequest(String stateStoreName) {
this.stateStoreName = stateStoreName;
}
diff --git a/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequestBuilder.java
deleted file mode 100644
index 6eb04dd7b..000000000
--- a/sdk/src/main/java/io/dapr/client/domain/ExecuteStateTransactionRequestBuilder.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2021 The Dapr Authors
- * 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.
-*/
-
-package io.dapr.client.domain;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Deprecated in favor of @see{@link ExecuteStateTransactionRequest}.
- * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0.
- */
-@Deprecated
-public final class ExecuteStateTransactionRequestBuilder {
- private final String storeName;
- private List> transactionalStates;
- private Map metadata;
-
- public ExecuteStateTransactionRequestBuilder(String storeName) {
- this.storeName = storeName;
- }
-
- public ExecuteStateTransactionRequestBuilder withTransactionalStates(
- TransactionalStateOperation>... transactionalStates) {
- this.transactionalStates = Collections.unmodifiableList(Arrays.asList(transactionalStates));
- return this;
- }
-
- public ExecuteStateTransactionRequestBuilder withTransactionalStates(
- List> transactionalStates) {
- this.transactionalStates = transactionalStates == null ? null : Collections.unmodifiableList(transactionalStates);
- return this;
- }
-
- public ExecuteStateTransactionRequestBuilder withMetadata(Map metadata) {
- this.metadata = Collections.unmodifiableMap(metadata);
- return this;
- }
-
- public ExecuteStateTransactionRequest build() {
- return new ExecuteStateTransactionRequest(storeName)
- .setMetadata(metadata).setOperations(transactionalStates);
- }
-}
diff --git a/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequest.java
index f950eb559..45289ff56 100644
--- a/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequest.java
+++ b/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequest.java
@@ -25,6 +25,11 @@ public class GetBulkSecretRequest {
private Map metadata;
+ /**
+ * Constructor for GetBulkSecretRequest.
+ *
+ * @param storeName Name of the secret store
+ */
public GetBulkSecretRequest(String storeName) {
this.storeName = storeName;
}
diff --git a/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequestBuilder.java
deleted file mode 100644
index 46325dafe..000000000
--- a/sdk/src/main/java/io/dapr/client/domain/GetBulkSecretRequestBuilder.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2021 The Dapr Authors
- * 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.
-*/
-
-package io.dapr.client.domain;
-
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * Builds a request to fetch all secrets of a secret store.
- * Deprecated in favor of @see{@link GetBulkSecretRequest}.
- * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0.
- */
-@Deprecated
-public class GetBulkSecretRequestBuilder {
-
- private final String storeName;
-
- private Map metadata;
-
- public GetBulkSecretRequestBuilder(String storeName) {
- this.storeName = storeName;
- }
-
- public GetBulkSecretRequestBuilder withMetadata(Map metadata) {
- this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata);
- return this;
- }
-
- /**
- * Builds a request object.
- *
- * @return Request object.
- */
- public GetBulkSecretRequest build() {
- GetBulkSecretRequest request = new GetBulkSecretRequest(storeName);
- return request.setMetadata(this.metadata);
- }
-
-}
diff --git a/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequest.java
index fa65eaf4a..47a20e2e0 100644
--- a/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequest.java
+++ b/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequest.java
@@ -31,6 +31,12 @@ public class GetBulkStateRequest {
private int parallelism = 1;
+ /**
+ * Constructor for GetBulkStateRequest.
+ *
+ * @param storeName Name of the state store
+ * @param keys keys for the state objects
+ */
public GetBulkStateRequest(String storeName, List keys) {
this.storeName = storeName;
this.keys = keys == null ? null : Collections.unmodifiableList(keys);
diff --git a/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequestBuilder.java
deleted file mode 100644
index 2a9de3811..000000000
--- a/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequestBuilder.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2021 The Dapr Authors
- * 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.
-*/
-
-package io.dapr.client.domain;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Builds a request to request states.
- * Deprecated in favor of @see{@link GetBulkStateRequest}.
- * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0.
- */
-@Deprecated
-public class GetBulkStateRequestBuilder {
-
- private final String storeName;
-
- private final List keys;
-
- private Map metadata;
-
- private int parallelism = 1;
-
- public GetBulkStateRequestBuilder(String storeName, List keys) {
- this.storeName = storeName;
- this.keys = keys == null ? null : Collections.unmodifiableList(keys);
- }
-
- public GetBulkStateRequestBuilder(String storeName, String... keys) {
- this.storeName = storeName;
- this.keys = keys == null ? null : Collections.unmodifiableList(Arrays.asList(keys));
- }
-
- public GetBulkStateRequestBuilder withMetadata(Map metadata) {
- this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata);
- return this;
- }
-
- public GetBulkStateRequestBuilder withParallelism(int parallelism) {
- this.parallelism = parallelism;
- return this;
- }
-
- /**
- * Builds a request object.
- *
- * @return Request object.
- */
- public GetBulkStateRequest build() {
- GetBulkStateRequest request = new GetBulkStateRequest(storeName, keys);
- return request.setMetadata(this.metadata)
- .setParallelism(this.parallelism);
- }
-
-}
diff --git a/sdk/src/main/java/io/dapr/client/domain/GetConfigurationRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetConfigurationRequest.java
index 7e0d13c54..a8de2bd61 100644
--- a/sdk/src/main/java/io/dapr/client/domain/GetConfigurationRequest.java
+++ b/sdk/src/main/java/io/dapr/client/domain/GetConfigurationRequest.java
@@ -25,6 +25,12 @@ public class GetConfigurationRequest {
private final List keys;
private Map metadata;
+ /**
+ * Constructor for GetConfigurationRequest.
+ *
+ * @param storeName Name of the configuration store
+ * @param keys Keys for the configuration objects
+ */
public GetConfigurationRequest(String storeName, List keys) {
this.storeName = storeName;
this.keys = keys == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(keys);
diff --git a/sdk/src/main/java/io/dapr/client/domain/GetSecretRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetSecretRequest.java
index fa1a22b10..d0e9629ea 100644
--- a/sdk/src/main/java/io/dapr/client/domain/GetSecretRequest.java
+++ b/sdk/src/main/java/io/dapr/client/domain/GetSecretRequest.java
@@ -25,6 +25,12 @@ public class GetSecretRequest {
private final String key;
+ /**
+ * Constructor for GetSecretRequest.
+ *
+ * @param storeName Name of the Secret Store
+ * @param key Key for retrieving the secret
+ */
public GetSecretRequest(String storeName, String key) {
this.storeName = storeName;
this.key = key;
diff --git a/sdk/src/main/java/io/dapr/client/domain/GetSecretRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/GetSecretRequestBuilder.java
deleted file mode 100644
index f4aec7fe0..000000000
--- a/sdk/src/main/java/io/dapr/client/domain/GetSecretRequestBuilder.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2021 The Dapr Authors
- * 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.
-*/
-
-package io.dapr.client.domain;
-
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * Builds a request to publish an event.
- * Deprecated in favor of @see{@link GetSecretRequest}.
- * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0
- */
-@Deprecated
-public class GetSecretRequestBuilder {
-
- private final String storeName;
-
- private final String key;
-
- private Map metadata;
-
- public GetSecretRequestBuilder(String storeName, String key) {
- this.storeName = storeName;
- this.key = key;
- }
-
- public GetSecretRequestBuilder withMetadata(Map metadata) {
- this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata);
- return this;
- }
-
- /**
- * Builds a request object.
- *
- * @return Request object.
- */
- public GetSecretRequest build() {
- GetSecretRequest request = new GetSecretRequest(storeName, key);
- return request.setMetadata(this.metadata);
- }
-
-}
diff --git a/sdk/src/main/java/io/dapr/client/domain/GetStateRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetStateRequest.java
index f80034539..fdd5797ef 100644
--- a/sdk/src/main/java/io/dapr/client/domain/GetStateRequest.java
+++ b/sdk/src/main/java/io/dapr/client/domain/GetStateRequest.java
@@ -29,6 +29,12 @@ public class GetStateRequest {
private StateOptions stateOptions;
+ /**
+ * Constructor for GetStateRequest.
+ *
+ * @param storeName Name of the state store
+ * @param key Key of the state object
+ */
public GetStateRequest(String storeName, String key) {
this.storeName = storeName;
this.key = key;
diff --git a/sdk/src/main/java/io/dapr/client/domain/GetStateRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/GetStateRequestBuilder.java
deleted file mode 100644
index 07b017656..000000000
--- a/sdk/src/main/java/io/dapr/client/domain/GetStateRequestBuilder.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2021 The Dapr Authors
- * 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.
-*/
-
-package io.dapr.client.domain;
-
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * Builds a request to request state.
- * Deprecated in favor of @see{@link GetStateRequest}.
- * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0
- */
-@Deprecated
-public class GetStateRequestBuilder {
-
- private final String storeName;
-
- private final String key;
-
- private Map metadata;
-
- private StateOptions stateOptions;
-
- public GetStateRequestBuilder(String storeName, String key) {
- this.storeName = storeName;
- this.key = key;
- }
-
- public GetStateRequestBuilder withMetadata(Map metadata) {
- this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata);
- return this;
- }
-
- public GetStateRequestBuilder withStateOptions(StateOptions stateOptions) {
- this.stateOptions = stateOptions;
- return this;
- }
-
- /**
- * Builds a request object.
- *
- * @return Request object.
- */
- public GetStateRequest build() {
- GetStateRequest request = new GetStateRequest(storeName, key);
- return request.setMetadata(this.metadata)
- .setStateOptions(this.stateOptions);
- }
-
-}
diff --git a/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequest.java b/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequest.java
index c45e31264..33bc72eba 100644
--- a/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequest.java
+++ b/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequest.java
@@ -29,6 +29,12 @@ public class InvokeBindingRequest {
private Map metadata;
+ /**
+ * Constructor for InvokeBindingRequest.
+ *
+ * @param bindingName Name of the binding
+ * @param operation Name of the binding operation
+ */
public InvokeBindingRequest(String bindingName, String operation) {
this.name = bindingName;
this.operation = operation;
diff --git a/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequestBuilder.java
deleted file mode 100644
index 7b2b5d8cb..000000000
--- a/sdk/src/main/java/io/dapr/client/domain/InvokeBindingRequestBuilder.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2021 The Dapr Authors
- * 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.
-*/
-
-package io.dapr.client.domain;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Builds a request to publish an event.
- * Deprecated in favor of @see{@link InvokeBindingRequest}.
- * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0
- */
-@Deprecated
-public class InvokeBindingRequestBuilder {
-
- private final String name;
-
- private final String operation;
-
- private Object data;
-
- private Map metadata = new HashMap<>();
-
- public InvokeBindingRequestBuilder(String name, String operation) {
- this.name = name;
- this.operation = operation;
- }
-
- public InvokeBindingRequestBuilder withData(Object data) {
- this.data = data;
- return this;
- }
-
- public InvokeBindingRequestBuilder withMetadata(Map metadata) {
- this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata);
- return this;
- }
-
- /**
- * Builds a request object.
- *
- * @return Request object.
- */
- public InvokeBindingRequest build() {
- InvokeBindingRequest request = new InvokeBindingRequest(name, operation);
- return request.setData(this.data)
- .setMetadata(this.metadata);
- }
-
-}
diff --git a/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequest.java b/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequest.java
index c6391a23a..6058363bb 100644
--- a/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequest.java
+++ b/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequest.java
@@ -28,6 +28,12 @@ public class InvokeMethodRequest {
private String contentType;
+ /**
+ * Constructor for InvokeMethodRequest.
+ *
+ * @param appId ID of the Dapr application
+ * @param method Name of the method to be invoked
+ */
public InvokeMethodRequest(String appId, String method) {
this.appId = appId;
this.method = method;
diff --git a/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequestBuilder.java
deleted file mode 100644
index 4586ca93b..000000000
--- a/sdk/src/main/java/io/dapr/client/domain/InvokeMethodRequestBuilder.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2021 The Dapr Authors
- * 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.
-*/
-
-package io.dapr.client.domain;
-
-/**
- * Builds a request to invoke a service.
- * Deprecated in favor of @see{@link InvokeMethodRequest}.
- * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0
- */
-@Deprecated
-public class InvokeMethodRequestBuilder {
-
- private final String appId;
-
- private final String method;
-
- private String contentType;
-
- private Object body;
-
- private HttpExtension httpExtension = HttpExtension.NONE;
-
- public InvokeMethodRequestBuilder(String appId, String method) {
- this.appId = appId;
- this.method = method;
- }
-
- public InvokeMethodRequestBuilder withContentType(String contentType) {
- this.contentType = contentType;
- return this;
- }
-
- public InvokeMethodRequestBuilder withBody(Object body) {
- this.body = body;
- return this;
- }
-
- public InvokeMethodRequestBuilder withHttpExtension(HttpExtension httpExtension) {
- this.httpExtension = httpExtension;
- return this;
- }
-
- /**
- * Builds a request object.
- *
- * @return Request object.
- */
- public InvokeMethodRequest build() {
- InvokeMethodRequest request = new InvokeMethodRequest(appId, method);
- return request.setBody(this.body)
- .setContentType(contentType)
- .setHttpExtension(this.httpExtension);
- }
-
-}
diff --git a/sdk/src/main/java/io/dapr/client/domain/PublishEventRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/PublishEventRequestBuilder.java
deleted file mode 100644
index 8de53f179..000000000
--- a/sdk/src/main/java/io/dapr/client/domain/PublishEventRequestBuilder.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2021 The Dapr Authors
- * 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.
-*/
-
-package io.dapr.client.domain;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Builds a request to publish an event.
- * Deprecated in favor of @see{@link PublishEventRequest}.
- * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0
- */
-@Deprecated
-public class PublishEventRequestBuilder {
-
- private final String pubsubName;
-
- private final String topic;
-
- private final Object data;
-
- private String contentType;
-
- private Map metadata = new HashMap<>();
-
- /**
- * Instantiates a builder for a publish request.
- *
- * @param pubsubName Name of the Dapr PubSub.
- * @param topic Topic name.
- * @param data Data to be published.
- */
- public PublishEventRequestBuilder(String pubsubName, String topic, Object data) {
- this.pubsubName = pubsubName;
- this.topic = topic;
- this.data = data;
- }
-
- public PublishEventRequestBuilder withContentType(String contentType) {
- this.contentType = contentType;
- return this;
- }
-
- public PublishEventRequestBuilder withMetadata(Map metadata) {
- this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata);
- return this;
- }
-
- /**
- * Builds a request object.
- *
- * @return Request object.
- */
- public PublishEventRequest build() {
- PublishEventRequest request = new PublishEventRequest(pubsubName, topic, data);
- return request.setContentType(this.contentType)
- .setMetadata(this.metadata);
- }
-
-}
diff --git a/sdk/src/main/java/io/dapr/client/domain/SaveStateRequest.java b/sdk/src/main/java/io/dapr/client/domain/SaveStateRequest.java
index 67bcd7ee5..39c0da1a3 100644
--- a/sdk/src/main/java/io/dapr/client/domain/SaveStateRequest.java
+++ b/sdk/src/main/java/io/dapr/client/domain/SaveStateRequest.java
@@ -26,6 +26,11 @@ public class SaveStateRequest {
private List> states;
+ /**
+ * Constructor for SaveStateRequest.
+ *
+ * @param storeName Name of the state store
+ */
public SaveStateRequest(String storeName) {
this.storeName = storeName;
}
diff --git a/sdk/src/main/java/io/dapr/client/domain/SaveStateRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/SaveStateRequestBuilder.java
deleted file mode 100644
index 26cc79960..000000000
--- a/sdk/src/main/java/io/dapr/client/domain/SaveStateRequestBuilder.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2021 The Dapr Authors
- * 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.
-*/
-
-package io.dapr.client.domain;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * A request to save states to state store.
- * Deprecated in favor of @see{@link SaveStateRequest}.
- * Deprecated since SDK version 1.3.0, slated for removal in SDK version 1.5.0
- */
-@Deprecated
-public class SaveStateRequestBuilder {
-
- private final String storeName;
-
- private List> states = new ArrayList<>();
-
- public SaveStateRequestBuilder(String storeName) {
- this.storeName = storeName;
- }
-
- public SaveStateRequestBuilder withStates(State>... states) {
- this.states = Collections.unmodifiableList(Arrays.asList(states));
- return this;
- }
-
- public SaveStateRequestBuilder withStates(List> states) {
- this.states = states == null ? null : Collections.unmodifiableList(states);
- return this;
- }
-
- /**
- * Builds a request object.
- *
- * @return Request object.
- */
- public SaveStateRequest build() {
- SaveStateRequest request = new SaveStateRequest(storeName);
- return request.setStates(this.states);
- }
-}
diff --git a/sdk/src/main/java/io/dapr/client/domain/StateOptions.java b/sdk/src/main/java/io/dapr/client/domain/StateOptions.java
index 356eb0899..136e47f7e 100644
--- a/sdk/src/main/java/io/dapr/client/domain/StateOptions.java
+++ b/sdk/src/main/java/io/dapr/client/domain/StateOptions.java
@@ -32,6 +32,9 @@
import java.util.Map;
import java.util.Optional;
+/**
+ * A class representing the state options for Dapr state API.
+ */
public class StateOptions {
private final Consistency consistency;
private final Concurrency concurrency;
@@ -70,6 +73,9 @@ public Map getStateOptionsAsMap() {
return Collections.unmodifiableMap(Optional.ofNullable(mapOptions).orElse(Collections.EMPTY_MAP));
}
+ /**
+ * Options for Consistency.
+ */
public enum Consistency {
EVENTUAL("eventual"),
STRONG("strong");
@@ -91,6 +97,9 @@ public static Consistency fromValue(String value) {
}
}
+ /**
+ * Options for Concurrency.
+ */
public enum Concurrency {
FIRST_WRITE("first-write"),
LAST_WRITE("last-write");
diff --git a/sdk/src/main/java/io/dapr/client/domain/SubscribeConfigurationRequest.java b/sdk/src/main/java/io/dapr/client/domain/SubscribeConfigurationRequest.java
index 0684dce5e..25118c400 100644
--- a/sdk/src/main/java/io/dapr/client/domain/SubscribeConfigurationRequest.java
+++ b/sdk/src/main/java/io/dapr/client/domain/SubscribeConfigurationRequest.java
@@ -25,6 +25,12 @@ public class SubscribeConfigurationRequest {
private final List keys;
private Map metadata;
+ /**
+ * Constructor for SubscribeConfigurationRequest.
+ *
+ * @param storeName Name of the configuration store
+ * @param keys Keys of the configurations values to subscribe to
+ */
public SubscribeConfigurationRequest(String storeName, List keys) {
this.storeName = storeName;
this.keys = keys == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(keys);
diff --git a/sdk/src/main/java/io/dapr/client/domain/TransactionalStateOperation.java b/sdk/src/main/java/io/dapr/client/domain/TransactionalStateOperation.java
index 8ec6a992a..1e613c746 100644
--- a/sdk/src/main/java/io/dapr/client/domain/TransactionalStateOperation.java
+++ b/sdk/src/main/java/io/dapr/client/domain/TransactionalStateOperation.java
@@ -17,6 +17,10 @@
import java.util.Objects;
+/**
+ * Class to represent transactional state operations.
+ * @param Type of the state value
+ */
public class TransactionalStateOperation {
/**
@@ -73,6 +77,9 @@ public String toString() {
+ '}';
}
+ /**
+ * Options for type of operation.
+ */
public enum OperationType {
@JsonProperty("upsert") UPSERT,
@JsonProperty("delete") DELETE
diff --git a/sdk/src/main/java/io/dapr/client/domain/TransactionalStateRequest.java b/sdk/src/main/java/io/dapr/client/domain/TransactionalStateRequest.java
index a5fff1cf8..6eb5969fa 100644
--- a/sdk/src/main/java/io/dapr/client/domain/TransactionalStateRequest.java
+++ b/sdk/src/main/java/io/dapr/client/domain/TransactionalStateRequest.java
@@ -17,6 +17,10 @@
import java.util.List;
import java.util.Map;
+/**
+ * A class to represent request for transactional state.
+ * @param Type of state value in TransactionalStateOperation
+ */
public class TransactionalStateRequest {
/**
diff --git a/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java b/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java
index c543c1b93..0df67cbb7 100644
--- a/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java
+++ b/sdk/src/test/java/io/dapr/client/DaprClientBuilderTest.java
@@ -13,9 +13,15 @@
package io.dapr.client;
+import io.dapr.config.Properties;
import io.dapr.serializer.DaprObjectSerializer;
+import io.grpc.Grpc;
+import io.grpc.ManagedChannelBuilder;
+import io.grpc.TlsChannelCredentials;
import org.junit.Test;
+import java.util.concurrent.Executors;
+
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -34,6 +40,31 @@ public void build() {
assertNotNull(daprClient);
}
+ @Test
+ public void testBuilderWithManagedChannel(){
+
+ System.setProperty(Properties.API_METHOD_INVOCATION_PROTOCOL.getName(), DaprApiProtocol.GRPC.name());
+ System.setProperty(Properties.API_PROTOCOL.getName(),DaprApiProtocol.GRPC.name());
+ DaprExtensibleClientBuilder daprClientBuilder = new DaprExtensibleClientBuilder();
+ ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder(Properties.SIDECAR_IP.get(), TlsChannelCredentials.create())
+ .executor(Executors.newFixedThreadPool(20));
+ DaprClient client = daprClientBuilder.withManagedGrpcChannel(managedChannelBuilder.build()).build();
+ assertNotNull(client);
+ System.setProperty(Properties.API_PROTOCOL.getName(),"");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testBuilderWithManagedChannelErrorHandling(){
+ System.setProperty(Properties.API_METHOD_INVOCATION_PROTOCOL.getName(), DaprApiProtocol.HTTP.name());
+ System.setProperty(Properties.API_PROTOCOL.getName(),DaprApiProtocol.HTTP.name());
+ DaprExtensibleClientBuilder daprClientBuilder = new DaprExtensibleClientBuilder();
+ ManagedChannelBuilder managedChannelBuilder = Grpc.newChannelBuilder(Properties.SIDECAR_IP.get(), TlsChannelCredentials.create())
+ .executor(Executors.newFixedThreadPool(20));
+ DaprClient client = daprClientBuilder.withManagedGrpcChannel(managedChannelBuilder.build()).build();
+ assertNotNull(client);
+ System.setProperty(Properties.API_PROTOCOL.getName(),"");
+ }
+
@Test(expected = IllegalArgumentException.class)
public void noObjectSerializer() {
new DaprClientBuilder().withObjectSerializer(null);
diff --git a/sdk/src/test/java/io/dapr/client/DaprClientGrpcTelemetryTest.java b/sdk/src/test/java/io/dapr/client/DaprClientGrpcTelemetryTest.java
index 2894bea9c..e323d9b57 100644
--- a/sdk/src/test/java/io/dapr/client/DaprClientGrpcTelemetryTest.java
+++ b/sdk/src/test/java/io/dapr/client/DaprClientGrpcTelemetryTest.java
@@ -15,7 +15,6 @@
import io.dapr.client.domain.HttpExtension;
import io.dapr.client.domain.InvokeMethodRequest;
-import io.dapr.client.domain.InvokeMethodRequestBuilder;
import io.dapr.serializer.DefaultObjectSerializer;
import io.dapr.utils.TypeRef;
import io.dapr.v1.CommonProtos;
diff --git a/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java b/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java
index 7d3fb3d2b..09c7f159b 100644
--- a/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java
+++ b/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java
@@ -17,16 +17,11 @@
import com.google.protobuf.ByteString;
import com.google.protobuf.Empty;
import io.dapr.client.domain.DeleteStateRequest;
-import io.dapr.client.domain.DeleteStateRequestBuilder;
import io.dapr.client.domain.ExecuteStateTransactionRequest;
-import io.dapr.client.domain.ExecuteStateTransactionRequestBuilder;
import io.dapr.client.domain.GetBulkStateRequest;
-import io.dapr.client.domain.GetBulkStateRequestBuilder;
import io.dapr.client.domain.GetStateRequest;
-import io.dapr.client.domain.GetStateRequestBuilder;
import io.dapr.client.domain.HttpExtension;
import io.dapr.client.domain.PublishEventRequest;
-import io.dapr.client.domain.PublishEventRequestBuilder;
import io.dapr.client.domain.State;
import io.dapr.client.domain.StateOptions;
import io.dapr.client.domain.TransactionalStateOperation;
diff --git a/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java b/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java
index afa0a8f4e..0cdf2a82e 100644
--- a/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java
+++ b/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java
@@ -16,15 +16,11 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import io.dapr.client.domain.DeleteStateRequest;
-import io.dapr.client.domain.DeleteStateRequestBuilder;
import io.dapr.client.domain.GetBulkStateRequest;
-import io.dapr.client.domain.GetBulkStateRequestBuilder;
import io.dapr.client.domain.GetStateRequest;
-import io.dapr.client.domain.GetStateRequestBuilder;
import io.dapr.client.domain.HttpExtension;
import io.dapr.client.domain.InvokeMethodRequest;
import io.dapr.client.domain.PublishEventRequest;
-import io.dapr.client.domain.PublishEventRequestBuilder;
import io.dapr.client.domain.State;
import io.dapr.client.domain.StateOptions;
import io.dapr.client.domain.TransactionalStateOperation;
diff --git a/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java b/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java
index a5ce0a592..2252074e3 100644
--- a/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java
+++ b/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java
@@ -15,6 +15,8 @@
import io.dapr.client.domain.ConfigurationItem;
+import io.dapr.client.domain.GetConfigurationRequest;
+import io.dapr.client.domain.SubscribeConfigurationRequest;
import io.dapr.serializer.DefaultObjectSerializer;
import io.dapr.v1.CommonProtos;
import io.dapr.v1.DaprGrpc;
@@ -73,6 +75,10 @@ public void getConfigurationTestErrorScenario() {
assertThrows(IllegalArgumentException.class, () -> {
previewClient.getConfiguration("", "key").block();
});
+ GetConfigurationRequest req = new GetConfigurationRequest(CONFIG_STORE_NAME, null);
+ assertThrows(IllegalArgumentException.class, () -> {
+ previewClient.getConfiguration(req).block();
+ });
}
@Test
@@ -223,6 +229,11 @@ public void subscribeConfigurationWithErrorTest() {
assertThrows(IllegalArgumentException.class, () -> {
previewClient.subscribeToConfiguration("", "key").blockFirst();
});
+
+ SubscribeConfigurationRequest req = new SubscribeConfigurationRequest(CONFIG_STORE_NAME, null);
+ assertThrows(IllegalArgumentException.class, () -> {
+ previewClient.subscribeToConfiguration(req).blockFirst();
+ });
}
private DaprProtos.GetConfigurationResponse getSingleMockResponse() {