diff --git a/bom/application/pom.xml b/bom/application/pom.xml
index 97da575626183..9b095024cd695 100644
--- a/bom/application/pom.xml
+++ b/bom/application/pom.xml
@@ -142,7 +142,7 @@
2.2
5.10.2
15.0.0.CR1
- 5.0.0.CR2
+ 5.0.1.Final
3.1.5
4.1.107.Final
1.14.0
diff --git a/docs/src/main/asciidoc/infinispan-client-reference.adoc b/docs/src/main/asciidoc/infinispan-client-reference.adoc
index 95c905b4dc6a0..3cb98af6193b9 100644
--- a/docs/src/main/asciidoc/infinispan-client-reference.adoc
+++ b/docs/src/main/asciidoc/infinispan-client-reference.adoc
@@ -373,57 +373,43 @@ Here is an example of how the preceding classes should be changed:
.Author.java
[source,java]
----
- @ProtoFactory
- public Author(String name, String surname) {
- this.name = Objects.requireNonNull(name);
- this.surname = Objects.requireNonNull(surname);
- }
-
- @ProtoField(number = 1)
- public String getName() {
- return name;
- }
+@Proto //<1>
+public record Author(String name, String surname) { //<2>
+}
+----
+<1> Since Protostream 5.0, a single annotation is needed to generate a default mapping
+<2> Since Protostream 5.0, records are supported
- @ProtoField(number = 2)
- public String getSurname() {
- return surname;
- }
+.Type.java
+[source,java]
+----
+@Proto
+public enum Type { //<1>
+ FANTASY,
+ PROGRAMMING
+}
----
+<1> Enums are supported
.Book.java
[source,java]
----
- @ProtoFactory
- public Book(String title, String description, int publicationYear, Set authors) {
- this.title = Objects.requireNonNull(title);
- this.description = Objects.requireNonNull(description);
- this.publicationYear = publicationYear;
- this.authors = Objects.requireNonNull(authors);
- }
-
- @ProtoField(number = 1)
- public String getTitle() {
- return title;
- }
-
- @ProtoField(number = 2)
- public String getDescription() {
- return description;
- }
-
- @ProtoField(number = 3, defaultValue = "-1")
- public int getPublicationYear() {
- return publicationYear;
- }
-
- @ProtoField(number = 4)
- public Set getAuthors() {
- return authors;
- }
+@Proto
+@Indexed // <1>
+public record Book(@Text String title, //<2>
+ @Keyword(projectable = true, sortable = true, normalizer = "lowercase", indexNullAs = "unnamed", norms = false) //<3>
+ String description,
+ int publicationYear,
+ Set authors, // <4>
+ Type bookType,
+ BigDecimal price) { // <5>
+}
----
-
-If your classes have only mutable fields, then the `ProtoFactory` annotation
-is not required, assuming your class has a no arg constructor.
+<1> Indicates that the entity will be indexed. Necessary to perform distributed full-text query operations.
+<2> Indicates the `title` should be indexed as text
+<3> Indicates the `description` field field should be indexed as a Keyword.
+<4> Collections are supported
+<5> Protostream provides default Protobuf mappers for commonly used types as `BigDecimal`, included in the `org.infinispan.protostream.types` package.
Then all that is required is a very simple `GeneratedSchema` interface with an annotation
on it to specify configuration settings
@@ -432,23 +418,24 @@ on it to specify configuration settings
[source,java]
----
import org.infinispan.protostream.GeneratedSchema;
-import org.infinispan.protostream.annotations.AutoProtoSchemaBuilder;
+import org.infinispan.protostream.annotations.ProtoSchema;
import org.infinispan.protostream.types.java.math.BigDecimalAdapter;
-@AutoProtoSchemaBuilder(includeClasses = { Book.class, Author.class, BigDecimalAdapter.class }, schemaPackageName = "book_sample")
+@ProtoSchema(includeClasses = { Book.class, Author.class, BigDecimalAdapter.class }, schemaPackageName = "book_sample")
interface BookStoreSchema extends GeneratedSchema {
}
----
[TIP]
====
-Protostream provides default Protobuf mappers for commonly used types as `BigDecimal`, included in the `org.infinispan.protostream.types` package.
+You can use the `basePackages` property to scan a full package containing your classes.
+You can override the default marshalling by using the `@Protofield` annotation.
====
So in this case we will automatically generate the marshaller and schemas for the included classes and
place them in the schema package automatically. The package does not have to be provided, but if you use Infinispan search capabilities, you must know the generated package.
-NOTE: In Quarkus the `schemaFileName` and `schemaFilePath` attributes should NOT be set on the `AutoProtoSchemaBuilder` annotation. Setting either attributes causes native runtime errors.
+NOTE: In Quarkus the `schemaFileName` and `schemaFilePath` attributes should NOT be set on the `ProtoSchema` annotation. Setting either attributes causes native runtime errors.
=== Custom serialization
diff --git a/docs/src/main/asciidoc/infinispan-client.adoc b/docs/src/main/asciidoc/infinispan-client.adoc
index 0d696e677dcce..f09acc688c08d 100644
--- a/docs/src/main/asciidoc/infinispan-client.adoc
+++ b/docs/src/main/asciidoc/infinispan-client.adoc
@@ -75,21 +75,12 @@ Create the `src/main/java/org/acme/infinispan/client/Greeting.java` file, with t
----
package org.acme.infinispan.client;
-import org.infinispan.protostream.annotations.ProtoFactory;
-import org.infinispan.protostream.annotations.ProtoField;
+import org.infinispan.protostream.annotations.Proto;
-public class Greeting { // <1>
- @ProtoField(number = 1) // <2>
- public String name;
-
- @ProtoField(number = 2) // <3>
- public String message;
-}
+@Proto //<1>
+public record Greeting(String name, String message) {} //<2>
----
-<1> If your classes have only mutable fields, then the `ProtoFactory` annotation is not required
-is not required, assuming your class has a no arg constructor
-<2> `@ProtoField` annotation to add the name field as string in the generated Protobuf schema
-<3> `@ProtoField` annotation to add the message field as string in the generated Protobuf schema
+<1> You only need an annotation to tag the record to be marshalled by Protostream
Note that we are not going to use Java serialization. https://github.com/infinispan/protostream[Protostream] is
a serialization library based on Protobuf data format part of Infinispan. Using an annotation based API, we
@@ -104,13 +95,13 @@ Create the `src/main/java/org/acme/infinispan/client/GreetingSchema.java` file,
package org.acme.infinispan.client;
import org.infinispan.protostream.GeneratedSchema;
-import org.infinispan.protostream.annotations.AutoProtoSchemaBuilder;
+import org.infinispan.protostream.annotations.ProtoSchema;
-@AutoProtoSchemaBuilder(includeClasses = Greeting.class) // <1>
+@ProtoSchema(includeClasses = Greeting.class) // <1>
public interface GreetingSchema extends GeneratedSchema { // <2>
}
----
-<1> Includes the `Greeting` pojo with the `@AutoProtoSchemaBuilder` annotation
+<1> Includes the `Greeting` pojo with the `@ProtoSchema` annotation
<2> Extends `GeneratedSchema` Protostream API interface
The Protobuf Schema that will be generated and used both on client and Infinispan Server side, will have
@@ -121,7 +112,7 @@ the following content:
// File name: GreetingSchema.proto
// Generated from : org.acme.infinispan.client.GreetingSchema
-syntax = "proto2";
+syntax = "proto3";
message Greeting {
diff --git a/extensions/infinispan-client/runtime/pom.xml b/extensions/infinispan-client/runtime/pom.xml
index ad1a959e7ad57..7d2df20ffcdb3 100644
--- a/extensions/infinispan-client/runtime/pom.xml
+++ b/extensions/infinispan-client/runtime/pom.xml
@@ -41,6 +41,21 @@
io.quarkus
quarkus-elytron-security-common
+
+
+ org.infinispan.protostream
+ protostream-processor
+
+
+ javax.annotation
+ javax.annotation-api
+
+
+
+
+ org.infinispan.protostream
+ protostream-types
+
org.wildfly.security
wildfly-elytron-sasl-plain
@@ -111,21 +126,6 @@
org.infinispan
infinispan-query-dsl
-
-
- org.infinispan.protostream
- protostream-processor
-
-
- javax.annotation
- javax.annotation-api
-
-
-
-
- org.infinispan.protostream
- protostream-types
-
jakarta.annotation
jakarta.annotation-api
diff --git a/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/Author.java b/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/Author.java
index 905c18a380a5f..b07569b335414 100644
--- a/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/Author.java
+++ b/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/Author.java
@@ -1,46 +1,7 @@
package io.quarkus.it.infinispan.client;
-import java.util.Objects;
+import org.infinispan.protostream.annotations.Proto;
-import org.infinispan.protostream.annotations.ProtoFactory;
-import org.infinispan.protostream.annotations.ProtoField;
-
-/**
- * @author William Burns
- */
-public class Author {
- private final String name;
- private final String surname;
-
- @ProtoFactory
- public Author(String name, String surname) {
- this.name = Objects.requireNonNull(name);
- this.surname = Objects.requireNonNull(surname);
- }
-
- @ProtoField(number = 1)
- public String getName() {
- return name;
- }
-
- @ProtoField(number = 2)
- public String getSurname() {
- return surname;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
- Author author = (Author) o;
- return name.equals(author.name) &&
- surname.equals(author.surname);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name, surname);
- }
+@Proto
+public record Author(String name, String surname) {
}
diff --git a/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/Book.java b/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/Book.java
index 45dfc48c3a002..95e1a5802144b 100644
--- a/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/Book.java
+++ b/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/Book.java
@@ -1,86 +1,16 @@
package io.quarkus.it.infinispan.client;
import java.math.BigDecimal;
-import java.util.Objects;
import java.util.Set;
import org.infinispan.api.annotations.indexing.Indexed;
import org.infinispan.api.annotations.indexing.Keyword;
import org.infinispan.api.annotations.indexing.Text;
-import org.infinispan.protostream.annotations.ProtoFactory;
-import org.infinispan.protostream.annotations.ProtoField;
+import org.infinispan.protostream.annotations.Proto;
-/**
- * @author William Burns
- */
+@Proto
@Indexed
-public class Book {
- private final String title;
- private final String description;
- private final int publicationYear;
- private final Set authors;
- private final Type bookType;
- private final BigDecimal price;
-
- @ProtoFactory
- public Book(String title, String description, int publicationYear, Set authors, Type bookType, BigDecimal price) {
- this.title = Objects.requireNonNull(title);
- this.description = Objects.requireNonNull(description);
- this.publicationYear = publicationYear;
- this.authors = Objects.requireNonNull(authors);
- this.bookType = bookType;
- this.price = price;
- }
-
- @ProtoField(number = 1)
- @Text
- public String getTitle() {
- return title;
- }
-
- @ProtoField(number = 2)
- @Keyword(projectable = true, sortable = true, normalizer = "lowercase", indexNullAs = "unnamed", norms = false)
- public String getDescription() {
- return description;
- }
-
- @ProtoField(number = 3, defaultValue = "-1")
- public int getPublicationYear() {
- return publicationYear;
- }
-
- @ProtoField(number = 4)
- public Set getAuthors() {
- return authors;
- }
-
- @ProtoField(number = 5)
- public Type getBookType() {
- return bookType;
- }
-
- @ProtoField(number = 6)
- public BigDecimal getPrice() {
- return price;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
- Book book = (Book) o;
- return publicationYear == book.publicationYear &&
- title.equals(book.title) &&
- description.equals(book.description) &&
- authors.equals(book.authors) &&
- bookType.equals(book.bookType) &&
- price.equals(book.price);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(title, description, publicationYear, authors, bookType, price);
- }
+public record Book(@Text String title,
+ @Keyword(projectable = true, sortable = true, normalizer = "lowercase", indexNullAs = "unnamed", norms = false) String description,
+ int publicationYear, Set authors, Type bookType, BigDecimal price) {
}
diff --git a/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/BookStoreSchema.java b/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/BookStoreSchema.java
index eb118804a30b3..d7a7a94d34b5e 100644
--- a/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/BookStoreSchema.java
+++ b/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/BookStoreSchema.java
@@ -1,10 +1,10 @@
package io.quarkus.it.infinispan.client;
import org.infinispan.protostream.GeneratedSchema;
-import org.infinispan.protostream.annotations.AutoProtoSchemaBuilder;
+import org.infinispan.protostream.annotations.ProtoSchema;
import org.infinispan.protostream.types.java.math.BigDecimalAdapter;
-@AutoProtoSchemaBuilder(includeClasses = { Book.class, Type.class, Author.class,
+@ProtoSchema(includeClasses = { Book.class, Type.class, Author.class,
BigDecimalAdapter.class }, schemaPackageName = "book_sample")
interface BookStoreSchema extends GeneratedSchema {
}
diff --git a/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/TestServlet.java b/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/TestServlet.java
index 33624e6f1efea..a41cdd66a664a 100644
--- a/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/TestServlet.java
+++ b/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/TestServlet.java
@@ -79,7 +79,7 @@ public List getIDs() {
@Produces(MediaType.TEXT_PLAIN)
public String getCachedValue(@PathParam("id") String id) {
Book book = cache.get(id);
- return book != null ? book.getTitle() : "NULL";
+ return book != null ? book.title() : "NULL";
}
@Path("query/{id}")
@@ -96,9 +96,9 @@ public String queryAuthorSurname(@PathParam("id") String name) {
}
return list.stream()
- .map(Book::getAuthors)
+ .map(Book::authors)
.flatMap(Set::stream)
- .map(author -> author.getName() + " " + author.getSurname())
+ .map(author -> author.name() + " " + author.surname())
.sorted()
.collect(Collectors.joining(",", "[", "]"));
}
@@ -114,9 +114,9 @@ public String ickleQueryAuthorSurname(@PathParam("id") String name) {
return "No one found for " + name;
}
return list.stream()
- .map(Book::getAuthors)
+ .map(Book::authors)
.flatMap(Set::stream)
- .map(author -> author.getName() + " " + author.getSurname())
+ .map(author -> author.name() + " " + author.surname())
.sorted()
.collect(Collectors.joining(",", "[", "]"));
}
@@ -160,9 +160,10 @@ public CompletionStage incrementCounter(@PathParam("id") String id) {
@Produces(MediaType.TEXT_PLAIN)
public String continuousQuery() {
return cacheSetup.getMatches().values().stream()
- .mapToInt(Book::getPublicationYear)
+ .mapToInt(Book::publicationYear)
.mapToObj(Integer::toString)
.collect(Collectors.joining(","));
+
}
@Path("nearcache")
@@ -268,8 +269,8 @@ public String magazineQuery(@PathParam("id") String name) {
@Path("create-cache-default-config/authors")
@GET
public String magazineQuery() {
- List names1 = authorsCacheDefault.values().stream().map(a -> a.getName()).collect(Collectors.toList());
- List names2 = authorsCacheAnother.values().stream().map(a -> a.getName())
+ List names1 = authorsCacheDefault.values().stream().map(a -> a.name()).collect(Collectors.toList());
+ List names2 = authorsCacheAnother.values().stream().map(a -> a.name())
.collect(Collectors.toList());
names1.addAll(names2);
diff --git a/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/Type.java b/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/Type.java
index 02e00584959e8..87dac58e48455 100644
--- a/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/Type.java
+++ b/integration-tests/infinispan-client/src/main/java/io/quarkus/it/infinispan/client/Type.java
@@ -1,10 +1,9 @@
package io.quarkus.it.infinispan.client;
-import org.infinispan.protostream.annotations.ProtoEnumValue;
+import org.infinispan.protostream.annotations.Proto;
+@Proto
public enum Type {
- @ProtoEnumValue(number = 1)
FANTASY,
- @ProtoEnumValue(number = 2)
PROGRAMMING
}