General upgrade to Jakarta EE 11 APIs

Includes removal of ManagedBean and javax.annotation legacy support.
Includes AbstractJson(Http)MessageConverter revision for Yasson 3.0.
Includes initial Hibernate ORM 7.0 upgrade.

Closes gh-34011
Closes gh-33750
This commit is contained in:
Juergen Hoeller
2024-12-03 13:30:25 +01:00
parent 15c6d3449b
commit 949432ce8b
65 changed files with 200 additions and 2995 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.springframework.messaging.converter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
@@ -91,7 +92,6 @@ public abstract class AbstractJsonMessageConverter extends AbstractMessageConver
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
Writer writer = getWriter(out, headers);
toJson(payload, resolvedType, writer);
writer.flush();
return out.toByteArray();
}
else {
@@ -120,11 +120,11 @@ public abstract class AbstractJsonMessageConverter extends AbstractMessageConver
}
protected abstract Object fromJson(Reader reader, Type resolvedType);
protected abstract Object fromJson(Reader reader, Type resolvedType) throws IOException;
protected abstract Object fromJson(String payload, Type resolvedType);
protected abstract void toJson(Object payload, Type resolvedType, Writer writer);
protected abstract void toJson(Object payload, Type resolvedType, Writer writer) throws IOException;
protected abstract String toJson(Object payload, Type resolvedType);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.messaging.converter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.lang.reflect.ParameterizedType;
@@ -88,13 +89,14 @@ public class GsonMessageConverter extends AbstractJsonMessageConverter {
}
@Override
protected void toJson(Object payload, Type resolvedType, Writer writer) {
protected void toJson(Object payload, Type resolvedType, Writer writer) throws IOException {
if (resolvedType instanceof ParameterizedType) {
getGson().toJson(payload, resolvedType, writer);
}
else {
getGson().toJson(payload, writer);
}
writer.flush();
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,13 +76,9 @@ public class KotlinSerializationJsonMessageConverter extends AbstractJsonMessage
}
@Override
protected void toJson(Object payload, Type resolvedType, Writer writer) {
try {
writer.write(toJson(payload, resolvedType).toCharArray());
}
catch (IOException ex) {
throw new MessageConversionException("Could not write JSON: " + ex.getMessage(), ex);
}
protected void toJson(Object payload, Type resolvedType, Writer writer) throws IOException {
writer.write(toJson(payload, resolvedType).toCharArray());
writer.flush();
}
@Override
@@ -106,4 +102,5 @@ public class KotlinSerializationJsonMessageConverter extends AbstractJsonMessage
}
return serializer;
}
}