From 3a70a21464f45d740d42f67dccddf1614ef5897d Mon Sep 17 00:00:00 2001 From: slinkydeveloper Date: Mon, 18 Aug 2025 10:50:53 +0200 Subject: [PATCH] Remove deprecations --- .../kotlin/dev/restate/sdk/kotlin/KtSerdes.kt | 175 --------------- .../main/kotlin/dev/restate/sdk/kotlin/api.kt | 8 - .../java/dev/restate/sdk/DurablePromise.java | 8 - .../main/java/dev/restate/sdk/JsonSerdes.java | 209 ------------------ .../dev/restate/sdk/annotation/Service.java | 10 +- .../restate/sdk/annotation/VirtualObject.java | 10 +- .../dev/restate/sdk/annotation/Workflow.java | 10 +- .../sdk/core/EndpointRequestHandler.java | 6 +- .../vertx/RestateHttpEndpointBuilder.java | 121 ---------- .../sdk/serde/jackson/JacksonSerdes.java | 188 ---------------- 10 files changed, 6 insertions(+), 739 deletions(-) delete mode 100644 sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/KtSerdes.kt delete mode 100644 sdk-api/src/main/java/dev/restate/sdk/JsonSerdes.java delete mode 100644 sdk-http-vertx/src/main/java/dev/restate/sdk/http/vertx/RestateHttpEndpointBuilder.java delete mode 100644 sdk-serde-jackson/src/main/java/dev/restate/sdk/serde/jackson/JacksonSerdes.java diff --git a/sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/KtSerdes.kt b/sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/KtSerdes.kt deleted file mode 100644 index 8e12cc7e..00000000 --- a/sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/KtSerdes.kt +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH -// -// This file is part of the Restate Java SDK, -// which is released under the MIT license. -// -// You can find a copy of the license in file LICENSE in the root -// directory of this repository or package, or at -// https://github.com/restatedev/sdk-java/blob/main/LICENSE -package dev.restate.sdk.kotlin - -import dev.restate.common.Slice -import dev.restate.sdk.common.DurablePromiseKey -import dev.restate.sdk.common.StateKey -import dev.restate.serde.Serde -import dev.restate.serde.Serde.Schema -import java.nio.charset.StandardCharsets -import kotlin.reflect.typeOf -import kotlinx.serialization.ExperimentalSerializationApi -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.builtins.ListSerializer -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.descriptors.StructureKind -import kotlinx.serialization.encodeToString -import kotlinx.serialization.json.Json -import kotlinx.serialization.json.JsonArray -import kotlinx.serialization.json.JsonElement -import kotlinx.serialization.json.JsonNull -import kotlinx.serialization.json.JsonTransformingSerializer -import kotlinx.serialization.serializer - -@Deprecated("Use stateKey() instead") -object KtStateKey { - - /** Creates a json [StateKey]. */ - @Deprecated("Use stateKey() instead", replaceWith = ReplaceWith(expression = "stateKey()")) - inline fun json(name: String): StateKey { - return StateKey.of(name, KtSerdes.json()) - } -} - -@Deprecated("Use durablePromiseKey() instead") -object KtDurablePromiseKey { - - /** Creates a json [StateKey]. */ - @Deprecated( - "Use durablePromiseKey() instead", - replaceWith = ReplaceWith(expression = "durablePromiseKey()")) - inline fun json(name: String): DurablePromiseKey { - return DurablePromiseKey.of(name, KtSerdes.json()) - } -} - -@Deprecated("Moved to dev.restate.serde.kotlinx") -object KtSerdes { - - @Deprecated("Moved to dev.restate.serde.kotlinx") - inline fun json(): Serde { - @Suppress("UNCHECKED_CAST") - return when (typeOf()) { - typeOf() -> UNIT as Serde - else -> json(serializer()) - } - } - - @Deprecated("Moved to dev.restate.serde.kotlinx") - val UNIT: Serde = - object : Serde { - override fun serialize(value: Unit?): Slice { - return Slice.EMPTY - } - - override fun deserialize(value: Slice) { - return - } - - override fun contentType(): String? { - return null - } - } - - @Deprecated("Moved to dev.restate.serde.kotlinx") - inline fun json(serializer: KSerializer): Serde { - return object : Serde { - override fun serialize(value: T?): Slice { - if (value == null) { - return Slice.wrap( - Json.encodeToString(JsonNull.serializer(), JsonNull).encodeToByteArray()) - } - - return Slice.wrap(Json.encodeToString(serializer, value).encodeToByteArray()) - } - - override fun deserialize(value: Slice): T { - return Json.decodeFromString( - serializer, String(value.toByteArray(), StandardCharsets.UTF_8)) - } - - override fun contentType(): String { - return "application/json" - } - - override fun jsonSchema(): Schema { - val schema: JsonSchema = serializer.descriptor.jsonSchema() - return Serde.StringifiedJsonSchema(Json.encodeToString(schema)) - } - } - } - - @Deprecated("Moved to dev.restate.serde.kotlinx") - @Serializable - @PublishedApi - internal data class JsonSchema( - @Serializable(with = StringListSerializer::class) val type: List? = null, - val format: String? = null, - ) { - companion object { - val INT = JsonSchema(type = listOf("number"), format = "int32") - - val LONG = JsonSchema(type = listOf("number"), format = "int64") - - val DOUBLE = JsonSchema(type = listOf("number"), format = "double") - - val FLOAT = JsonSchema(type = listOf("number"), format = "float") - - val STRING = JsonSchema(type = listOf("string")) - - val BOOLEAN = JsonSchema(type = listOf("boolean")) - - val OBJECT = JsonSchema(type = listOf("object")) - - val LIST = JsonSchema(type = listOf("array")) - - val ANY = JsonSchema() - } - } - - object StringListSerializer : - JsonTransformingSerializer>(ListSerializer(String.Companion.serializer())) { - override fun transformSerialize(element: JsonElement): JsonElement { - require(element is JsonArray) - return element.singleOrNull() ?: element - } - } - - @Deprecated("Moved to dev.restate.serde.kotlinx") - @OptIn(ExperimentalSerializationApi::class) - @PublishedApi - internal fun SerialDescriptor.jsonSchema(): JsonSchema { - var schema = - when (this.kind) { - PrimitiveKind.BOOLEAN -> JsonSchema.BOOLEAN - PrimitiveKind.BYTE -> JsonSchema.INT - PrimitiveKind.CHAR -> JsonSchema.STRING - PrimitiveKind.DOUBLE -> JsonSchema.DOUBLE - PrimitiveKind.FLOAT -> JsonSchema.FLOAT - PrimitiveKind.INT -> JsonSchema.INT - PrimitiveKind.LONG -> JsonSchema.LONG - PrimitiveKind.SHORT -> JsonSchema.INT - PrimitiveKind.STRING -> JsonSchema.STRING - StructureKind.LIST -> JsonSchema.LIST - StructureKind.MAP -> JsonSchema.OBJECT - else -> JsonSchema.ANY - } - - // Add nullability constraint - if (this.isNullable && schema.type != null) { - schema = schema.copy(type = schema.type.plus("null")) - } - - return schema - } -} diff --git a/sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/api.kt b/sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/api.kt index e47739bd..b25a1652 100644 --- a/sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/api.kt +++ b/sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/api.kt @@ -670,14 +670,6 @@ sealed interface DurablePromise { /** @return the future to await the promise result on. */ suspend fun future(): DurableFuture - @Deprecated( - message = "Use future() instead", - level = DeprecationLevel.WARNING, - replaceWith = ReplaceWith(expression = "future()")) - suspend fun awaitable(): DurableFuture { - return future() - } - /** @return the value, if already present, otherwise returns an empty optional. */ suspend fun peek(): Output } diff --git a/sdk-api/src/main/java/dev/restate/sdk/DurablePromise.java b/sdk-api/src/main/java/dev/restate/sdk/DurablePromise.java index b367f9a3..56cc3a64 100644 --- a/sdk-api/src/main/java/dev/restate/sdk/DurablePromise.java +++ b/sdk-api/src/main/java/dev/restate/sdk/DurablePromise.java @@ -36,14 +36,6 @@ public interface DurablePromise { */ DurableFuture future(); - /** - * @deprecated Use {@link #future()} instead. - */ - @Deprecated(forRemoval = true, since = "2.0") - default DurableFuture awaitable() { - return future(); - } - /** * @return the value, if already present, otherwise returns an empty optional. */ diff --git a/sdk-api/src/main/java/dev/restate/sdk/JsonSerdes.java b/sdk-api/src/main/java/dev/restate/sdk/JsonSerdes.java deleted file mode 100644 index 0d948646..00000000 --- a/sdk-api/src/main/java/dev/restate/sdk/JsonSerdes.java +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH -// -// This file is part of the Restate Java SDK, -// which is released under the MIT license. -// -// You can find a copy of the license in file LICENSE in the root -// directory of this repository or package, or at -// https://github.com/restatedev/sdk-java/blob/main/LICENSE -package dev.restate.sdk; - -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; -import dev.restate.common.Slice; -import dev.restate.common.function.ThrowingBiConsumer; -import dev.restate.common.function.ThrowingFunction; -import dev.restate.serde.Serde; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.Map; -import org.jspecify.annotations.NonNull; - -/** - * @deprecated For primitive types, simply use the overloads of the {@link Context}/{@link - * dev.restate.sdk.common.StateKey}/{@link dev.restate.sdk.common.DurablePromiseKey} methods - * accepting {@link Class}, for example {@code ctx.run(String.class, myClosure)} or {@code - * ctx.awakeable(Integer.TYPE)} or {@code StateKey.of("key", String.class)} - */ -@Deprecated(since = "2.0", forRemoval = true) -public abstract class JsonSerdes { - - private JsonSerdes() {} - - /** - * @deprecated For primitive types, simply use the overloads of the {@link Context}/{@link - * dev.restate.sdk.common.StateKey}/{@link dev.restate.sdk.common.DurablePromiseKey} methods - * accepting {@link Class}, for example {@code ctx.run(String.class, myClosure)} or {@code - * ctx.awakeable(Integer.TYPE)} or {@code StateKey.of("key", String.class)} - */ - @Deprecated(since = "2.0", forRemoval = true) - public static final Serde<@NonNull String> STRING = - usingJackson( - "string", - JsonGenerator::writeString, - p -> { - if (p.nextToken() != JsonToken.VALUE_STRING) { - throw new IllegalStateException( - "Expecting token " + JsonToken.VALUE_STRING + ", got " + p.getCurrentToken()); - } - return p.getText(); - }); - - /** - * @deprecated For primitive types, simply use the overloads of the {@link Context}/{@link - * dev.restate.sdk.common.StateKey}/{@link dev.restate.sdk.common.DurablePromiseKey} methods - * accepting {@link Class}, for example {@code ctx.run(String.class, myClosure)} or {@code - * ctx.awakeable(Integer.TYPE)} or {@code StateKey.of("key", String.class)} - */ - @Deprecated(since = "2.0", forRemoval = true) - public static final Serde<@NonNull Boolean> BOOLEAN = - usingJackson( - "boolean", - JsonGenerator::writeBoolean, - p -> { - p.nextToken(); - return p.getBooleanValue(); - }); - - /** - * @deprecated For primitive types, simply use the overloads of the {@link Context}/{@link - * dev.restate.sdk.common.StateKey}/{@link dev.restate.sdk.common.DurablePromiseKey} methods - * accepting {@link Class}, for example {@code ctx.run(String.class, myClosure)} or {@code - * ctx.awakeable(Integer.TYPE)} or {@code StateKey.of("key", String.class)} - */ - @Deprecated(since = "2.0", forRemoval = true) - public static final Serde<@NonNull Byte> BYTE = - usingJackson( - "number", - JsonGenerator::writeNumber, - p -> { - p.nextToken(); - return p.getByteValue(); - }); - - /** - * @deprecated For primitive types, simply use the overloads of the {@link Context}/{@link - * dev.restate.sdk.common.StateKey}/{@link dev.restate.sdk.common.DurablePromiseKey} methods - * accepting {@link Class}, for example {@code ctx.run(String.class, myClosure)} or {@code - * ctx.awakeable(Integer.TYPE)} or {@code StateKey.of("key", String.class)} - */ - @Deprecated(since = "2.0", forRemoval = true) - public static final Serde<@NonNull Short> SHORT = - usingJackson( - "number", - JsonGenerator::writeNumber, - p -> { - p.nextToken(); - return p.getShortValue(); - }); - - /** - * @deprecated For primitive types, simply use the overloads of the {@link Context}/{@link - * dev.restate.sdk.common.StateKey}/{@link dev.restate.sdk.common.DurablePromiseKey} methods - * accepting {@link Class}, for example {@code ctx.run(String.class, myClosure)} or {@code - * ctx.awakeable(Integer.TYPE)} or {@code StateKey.of("key", String.class)} - */ - @Deprecated(since = "2.0", forRemoval = true) - public static final Serde<@NonNull Integer> INT = - usingJackson( - "number", - JsonGenerator::writeNumber, - p -> { - p.nextToken(); - return p.getIntValue(); - }); - - /** - * @deprecated For primitive types, simply use the overloads of the {@link Context}/{@link - * dev.restate.sdk.common.StateKey}/{@link dev.restate.sdk.common.DurablePromiseKey} methods - * accepting {@link Class}, for example {@code ctx.run(String.class, myClosure)} or {@code - * ctx.awakeable(Integer.TYPE)} or {@code StateKey.of("key", String.class)} - */ - @Deprecated(since = "2.0", forRemoval = true) - public static final Serde<@NonNull Long> LONG = - usingJackson( - "number", - JsonGenerator::writeNumber, - p -> { - p.nextToken(); - return p.getLongValue(); - }); - - /** - * @deprecated For primitive types, simply use the overloads of the {@link Context}/{@link - * dev.restate.sdk.common.StateKey}/{@link dev.restate.sdk.common.DurablePromiseKey} methods - * accepting {@link Class}, for example {@code ctx.run(String.class, myClosure)} or {@code - * ctx.awakeable(Integer.TYPE)} or {@code StateKey.of("key", String.class)} - */ - @Deprecated(since = "2.0", forRemoval = true) - public static final Serde<@NonNull Float> FLOAT = - usingJackson( - "number", - JsonGenerator::writeNumber, - p -> { - p.nextToken(); - return p.getFloatValue(); - }); - - /** - * @deprecated For primitive types, simply use the overloads of the {@link Context}/{@link - * dev.restate.sdk.common.StateKey}/{@link dev.restate.sdk.common.DurablePromiseKey} methods - * accepting {@link Class}, for example {@code ctx.run(String.class, myClosure)} or {@code - * ctx.awakeable(Integer.TYPE)} or {@code StateKey.of("key", String.class)} - */ - @Deprecated(since = "2.0", forRemoval = true) - public static final Serde<@NonNull Double> DOUBLE = - usingJackson( - "number", - JsonGenerator::writeNumber, - p -> { - p.nextToken(); - return p.getDoubleValue(); - }); - - // --- Helpers for jackson-core - - private static final JsonFactory JSON_FACTORY = new JsonFactory(); - - private static Serde usingJackson( - String type, - ThrowingBiConsumer serializer, - ThrowingFunction deserializer) { - return new Serde<>() { - - @Override - public Schema jsonSchema() { - return new JsonSchema(Map.of("type", type)); - } - - @Override - public Slice serialize(T value) { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - try (JsonGenerator gen = JSON_FACTORY.createGenerator(outputStream)) { - serializer.asBiConsumer().accept(gen, value); - } catch (IOException e) { - throw new RuntimeException("Cannot create JsonGenerator", e); - } - return Slice.wrap(outputStream.toByteArray()); - } - - @Override - public T deserialize(@NonNull Slice value) { - ByteArrayInputStream inputStream = new ByteArrayInputStream(value.toByteArray()); - try (JsonParser parser = JSON_FACTORY.createParser(inputStream)) { - return deserializer.asFunction().apply(parser); - } catch (IOException e) { - throw new RuntimeException("Cannot create JsonGenerator", e); - } - } - - @Override - public String contentType() { - return "application/json"; - } - }; - } -} diff --git a/sdk-common/src/main/java/dev/restate/sdk/annotation/Service.java b/sdk-common/src/main/java/dev/restate/sdk/annotation/Service.java index 99f5c306..1003860a 100644 --- a/sdk-common/src/main/java/dev/restate/sdk/annotation/Service.java +++ b/sdk-common/src/main/java/dev/restate/sdk/annotation/Service.java @@ -18,12 +18,4 @@ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface Service { - - /** - * @deprecated use the {@link Name} annotation instead. Note: if you were using a name override, - * this won't influence anymore the prefix of the generated class. - */ - @Deprecated(since = "2.0", forRemoval = true) - String name() default ""; -} +public @interface Service {} diff --git a/sdk-common/src/main/java/dev/restate/sdk/annotation/VirtualObject.java b/sdk-common/src/main/java/dev/restate/sdk/annotation/VirtualObject.java index 23a6f32f..e4a0fd5e 100644 --- a/sdk-common/src/main/java/dev/restate/sdk/annotation/VirtualObject.java +++ b/sdk-common/src/main/java/dev/restate/sdk/annotation/VirtualObject.java @@ -18,12 +18,4 @@ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface VirtualObject { - - /** - * @deprecated use the {@link Name} annotation instead. Note: if you were using a name override, - * this won't influence anymore the prefix of the generated class. - */ - @Deprecated(since = "2.0", forRemoval = true) - String name() default ""; -} +public @interface VirtualObject {} diff --git a/sdk-common/src/main/java/dev/restate/sdk/annotation/Workflow.java b/sdk-common/src/main/java/dev/restate/sdk/annotation/Workflow.java index 841a6e08..b52e4858 100644 --- a/sdk-common/src/main/java/dev/restate/sdk/annotation/Workflow.java +++ b/sdk-common/src/main/java/dev/restate/sdk/annotation/Workflow.java @@ -19,12 +19,4 @@ @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface Workflow { - - /** - * @deprecated use the {@link Name} annotation instead. Note: if you were using a name override, - * this won't influence anymore the prefix of the generated class. - */ - @Deprecated(since = "2.0", forRemoval = true) - String name() default ""; -} +public @interface Workflow {} diff --git a/sdk-core/src/main/java/dev/restate/sdk/core/EndpointRequestHandler.java b/sdk-core/src/main/java/dev/restate/sdk/core/EndpointRequestHandler.java index 435dd241..2804fa7a 100644 --- a/sdk-core/src/main/java/dev/restate/sdk/core/EndpointRequestHandler.java +++ b/sdk-core/src/main/java/dev/restate/sdk/core/EndpointRequestHandler.java @@ -74,7 +74,7 @@ public static EndpointRequestHandler create(Endpoint endpoint) { * @deprecated The protocol mode is now established on request basis, use {@link * #create(Endpoint)} instead. */ - @Deprecated + @Deprecated(since = "2.3", forRemoval = true) public static EndpointRequestHandler forBidiStream(Endpoint endpoint) { return new EndpointRequestHandler(EndpointManifestSchema.ProtocolMode.BIDI_STREAM, endpoint); } @@ -83,7 +83,7 @@ public static EndpointRequestHandler forBidiStream(Endpoint endpoint) { * @deprecated The protocol mode is now established on request basis, use {@link * #create(Endpoint)} instead. */ - @Deprecated + @Deprecated(since = "2.3", forRemoval = true) public static EndpointRequestHandler forRequestResponse(Endpoint endpoint) { return new EndpointRequestHandler( EndpointManifestSchema.ProtocolMode.REQUEST_RESPONSE, endpoint); @@ -112,7 +112,7 @@ public interface LoggingContextSetter { * @deprecated Use {@link #processorForRequest(String, HeadersAccessor, LoggingContextSetter, * Executor, boolean)} instead. */ - @Deprecated + @Deprecated(since = "2.3", forRemoval = true) public RequestProcessor processorForRequest( String path, HeadersAccessor headersAccessor, diff --git a/sdk-http-vertx/src/main/java/dev/restate/sdk/http/vertx/RestateHttpEndpointBuilder.java b/sdk-http-vertx/src/main/java/dev/restate/sdk/http/vertx/RestateHttpEndpointBuilder.java deleted file mode 100644 index c43f518f..00000000 --- a/sdk-http-vertx/src/main/java/dev/restate/sdk/http/vertx/RestateHttpEndpointBuilder.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH -// -// This file is part of the Restate Java SDK, -// which is released under the MIT license. -// -// You can find a copy of the license in file LICENSE in the root -// directory of this repository or package, or at -// https://github.com/restatedev/sdk-java/blob/main/LICENSE -package dev.restate.sdk.http.vertx; - -import dev.restate.sdk.endpoint.Endpoint; -import dev.restate.sdk.endpoint.RequestIdentityVerifier; -import dev.restate.sdk.endpoint.definition.ServiceDefinition; -import io.opentelemetry.api.OpenTelemetry; -import io.vertx.core.Vertx; -import io.vertx.core.http.HttpServerOptions; -import java.util.*; - -/** - * @deprecated Use {@link RestateHttpServer} in combination with {@link Endpoint} instead. This will - * be removed in the next minor release. - */ -@Deprecated(since = "2.0", forRemoval = true) -public class RestateHttpEndpointBuilder { - - private HttpServerOptions options; - private final Endpoint.Builder endpointBuilder; - - private RestateHttpEndpointBuilder(Vertx vertx) { - this.options = null; - this.endpointBuilder = Endpoint.builder(); - } - - /** - * @deprecated Use {@link RestateHttpServer} in combination with {@link Endpoint} instead. This - * will be removed in the next minor release. - */ - @Deprecated(since = "2.0", forRemoval = true) - public static RestateHttpEndpointBuilder builder() { - return new RestateHttpEndpointBuilder(Vertx.vertx()); - } - - /** - * @deprecated Use {@link RestateHttpServer} in combination with {@link Endpoint} instead. This - * will be removed in the next minor release. - */ - @Deprecated(since = "2.0", forRemoval = true) - public RestateHttpEndpointBuilder withOptions(HttpServerOptions options) { - this.options = Objects.requireNonNull(options); - return this; - } - - /** - * @deprecated Use {@link RestateHttpServer} in combination with {@link Endpoint} instead. This - * will be removed in the next minor release. - */ - @Deprecated(since = "2.0", forRemoval = true) - public RestateHttpEndpointBuilder bind(Object service) { - this.endpointBuilder.bind(service); - return this; - } - - /** - * @deprecated Use {@link RestateHttpServer} in combination with {@link Endpoint} instead. This - * will be removed in the next minor release. - */ - @Deprecated(since = "2.0", forRemoval = true) - public RestateHttpEndpointBuilder bind(ServiceDefinition serviceDefinition) { - this.endpointBuilder.bind(serviceDefinition); - return this; - } - - /** - * @deprecated Use {@link RestateHttpServer} in combination with {@link Endpoint} instead. This - * will be removed in the next minor release. - */ - @Deprecated(since = "2.0", forRemoval = true) - public RestateHttpEndpointBuilder withOpenTelemetry(OpenTelemetry openTelemetry) { - this.endpointBuilder.withOpenTelemetry(openTelemetry); - return this; - } - - /** - * @deprecated Use {@link RestateHttpServer} in combination with {@link Endpoint} instead. This - * will be removed in the next minor release. - */ - @Deprecated(since = "2.0", forRemoval = true) - public RestateHttpEndpointBuilder withRequestIdentityVerifier( - RequestIdentityVerifier requestIdentityVerifier) { - this.endpointBuilder.withRequestIdentityVerifier(requestIdentityVerifier); - return this; - } - - /** - * @deprecated Use {@link RestateHttpServer} in combination with {@link Endpoint} instead. This - * will be removed in the next minor release. - */ - @Deprecated(since = "2.0", forRemoval = true) - public RestateHttpEndpointBuilder enablePreviewContext() { - this.endpointBuilder.enablePreviewContext(); - return this; - } - - /** - * @deprecated Use {@link RestateHttpServer} in combination with {@link Endpoint} instead. This - * will be removed in the next minor release. - */ - @Deprecated(since = "2.0", forRemoval = true) - public int buildAndListen(int port) { - return RestateHttpServer.listen(endpointBuilder, port); - } - - /** - * @deprecated Use {@link RestateHttpServer} in combination with {@link Endpoint} instead. This - * will be removed in the next minor release. - */ - @Deprecated(since = "2.0", forRemoval = true) - public int buildAndListen() { - return RestateHttpServer.listen(endpointBuilder); - } -} diff --git a/sdk-serde-jackson/src/main/java/dev/restate/sdk/serde/jackson/JacksonSerdes.java b/sdk-serde-jackson/src/main/java/dev/restate/sdk/serde/jackson/JacksonSerdes.java deleted file mode 100644 index b4a2caab..00000000 --- a/sdk-serde-jackson/src/main/java/dev/restate/sdk/serde/jackson/JacksonSerdes.java +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH -// -// This file is part of the Restate Java SDK, -// which is released under the MIT license. -// -// You can find a copy of the license in file LICENSE in the root -// directory of this repository or package, or at -// https://github.com/restatedev/sdk-java/blob/main/LICENSE -package dev.restate.sdk.serde.jackson; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.victools.jsonschema.generator.*; -import com.github.victools.jsonschema.module.jackson.JacksonModule; -import com.github.victools.jsonschema.module.jackson.JacksonOption; -import dev.restate.common.Slice; -import dev.restate.serde.Serde; -import dev.restate.serde.jackson.JacksonSerdeFactory; -import java.io.IOException; -import java.util.stream.StreamSupport; -import org.jspecify.annotations.NonNull; - -/** - * @deprecated This will be removed in the next release, please check the individual methods for - * more details. - */ -@Deprecated(forRemoval = true, since = "2.0") -public final class JacksonSerdes { - - private JacksonSerdes() {} - - private static final ObjectMapper defaultMapper; - private static final SchemaGenerator schemaGenerator; - - static { - defaultMapper = new ObjectMapper(); - // Find modules through SPI (e.g. jackson-datatype-jsr310) - defaultMapper.findAndRegisterModules(); - - JacksonModule module = - new JacksonModule( - JacksonOption.RESPECT_JSONPROPERTY_REQUIRED, JacksonOption.INLINE_TRANSFORMED_SUBTYPES); - SchemaGeneratorConfigBuilder configBuilder = - new SchemaGeneratorConfigBuilder( - defaultMapper, SchemaVersion.DRAFT_2020_12, OptionPreset.PLAIN_JSON) - .with(module); - - // Make sure we use `title` for types - configBuilder - .forTypesInGeneral() - .withTypeAttributeOverride( - (schema, scope, context) -> { - if (schema.isObject() - && !schema.hasNonNull( - SchemaKeyword.TAG_TITLE.forVersion( - context.getGeneratorConfig().getSchemaVersion()))) { - JsonNode typeKeyword = - schema.get( - SchemaKeyword.TAG_TYPE.forVersion( - context.getGeneratorConfig().getSchemaVersion())); - boolean isObjectSchema = - typeKeyword != null - && ((typeKeyword.isTextual() && "object".equals(typeKeyword.textValue())) - || (typeKeyword.isArray() - && StreamSupport.stream(typeKeyword.spliterator(), false) - .anyMatch( - el -> el.isTextual() && "object".equals(el.textValue())))); - if (isObjectSchema) { - schema.put( - SchemaKeyword.TAG_TITLE.forVersion( - context.getGeneratorConfig().getSchemaVersion()), - scope.getSimpleTypeDescription()); - } - } - }); - - schemaGenerator = new SchemaGenerator(configBuilder.build()); - } - - /** - * @deprecated Pass a {@link Class} to the context method requiring serialization/deserialization, - * instead of providing a serde using JacksonSerdes. This method will be removed in the next - * release. - */ - @Deprecated(forRemoval = true, since = "2.0") - public static Serde of(Class clazz) { - return of(defaultMapper, clazz); - } - - /** - * @deprecated Pass a {@link Class} to the context method requiring serialization/deserialization, - * instead of providing a serde using JacksonSerdes. If you need to customize the object - * mapper, look at {@link JacksonSerdeFactory} This method will be removed in the next - * release. - */ - @Deprecated(forRemoval = true, since = "2.0") - public static Serde of(ObjectMapper mapper, Class clazz) { - return new Serde<>() { - @Override - public Schema jsonSchema() { - return new JsonSchema(schemaGenerator.generateSchema(clazz)); - } - - @Override - public Slice serialize(T value) { - try { - return Slice.wrap(mapper.writeValueAsBytes(value)); - } catch (JsonProcessingException e) { - sneakyThrow(e); - return null; - } - } - - @Override - public T deserialize(@NonNull Slice value) { - try { - return mapper.readValue(value.toByteArray(), clazz); - } catch (IOException e) { - sneakyThrow(e); - return null; - } - } - - @Override - public String contentType() { - return "application/json"; - } - }; - } - - /** - * @deprecated Pass a {@link dev.restate.serde.TypeRef} to the context method requiring - * serialization/deserialization, instead of providing a serde using JacksonSerdes. This - * method will be removed in the next release. - */ - @Deprecated(forRemoval = true, since = "2.0") - public static Serde of(TypeReference typeReference) { - return of(defaultMapper, typeReference); - } - - /** - * @deprecated Pass a {@link dev.restate.serde.TypeRef} to the context method requiring - * serialization/deserialization, instead of providing a serde using JacksonSerdes. If you - * need to customize the object mapper, look at {@link JacksonSerdeFactory} This method will - * be removed in the next release. - */ - @Deprecated(forRemoval = true, since = "2.0") - public static Serde of(ObjectMapper mapper, TypeReference typeReference) { - return new Serde<>() { - @Override - public Schema jsonSchema() { - return new JsonSchema(typeReference.getType()); - } - - @Override - public Slice serialize(T value) { - try { - return Slice.wrap(mapper.writeValueAsBytes(value)); - } catch (JsonProcessingException e) { - sneakyThrow(e); - return null; - } - } - - @Override - public T deserialize(@NonNull Slice value) { - try { - return mapper.readValue(value.toByteArray(), typeReference); - } catch (IOException e) { - sneakyThrow(e); - return null; - } - } - - @Override - public String contentType() { - return "application/json"; - } - }; - } - - @SuppressWarnings("unchecked") - private static void sneakyThrow(Object exception) throws E { - throw (E) exception; - } -}