forked from TechEmpower/FrameworkBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Micronaut: Use JTE template engine and GraalVM 22 (TechEmpower#9262)
* Micronaut: Use JTE template engine and GraalVM 22 * CR * User Graalvm 21 for Micronaut Data
- Loading branch information
Showing
16 changed files
with
104 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
frameworks/Java/micronaut/common/src/main/java/benchmark/controller/FortunesBodyWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package benchmark.controller; | ||
|
||
import benchmark.model.Fortune; | ||
import gg.jte.TemplateOutput; | ||
import gg.jte.generated.precompiled.JtefortunesGenerated; | ||
import gg.jte.html.OwaspHtmlTemplateOutput; | ||
import io.micronaut.core.annotation.NonNull; | ||
import io.micronaut.core.type.Argument; | ||
import io.micronaut.core.type.MutableHeaders; | ||
import io.micronaut.http.MediaType; | ||
import io.micronaut.http.body.MessageBodyWriter; | ||
import io.micronaut.http.codec.CodecException; | ||
import io.micronaut.http.netty.NettyHttpHeaders; | ||
import jakarta.inject.Singleton; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.List; | ||
|
||
@Singleton | ||
public class FortunesBodyWriter implements MessageBodyWriter<List<Fortune>> { | ||
|
||
@Override | ||
public void writeTo(@NonNull Argument<List<Fortune>> type, | ||
@NonNull MediaType mediaType, | ||
List<Fortune> values, | ||
@NonNull MutableHeaders outgoingHeaders, | ||
@NonNull OutputStream outputStream) throws CodecException { | ||
outgoingHeaders.set(NettyHttpHeaders.CONTENT_TYPE, "text/html;charset=utf-8"); | ||
TemplateOutput output = new TemplateOutput() { | ||
|
||
@Override | ||
public void writeContent(String value) { | ||
writeBinaryContent(value.getBytes(StandardCharsets.UTF_8)); | ||
} | ||
|
||
@Override | ||
public void writeContent(String value, int beginIndex, int endIndex) { | ||
writeBinaryContent(value.substring(beginIndex, endIndex).getBytes(StandardCharsets.UTF_8)); | ||
} | ||
|
||
@Override | ||
public void writeBinaryContent(byte[] value) { | ||
try { | ||
outputStream.write(value); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
}; | ||
JtefortunesGenerated.render(new OwaspHtmlTemplateOutput(output), null, values); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@param java.util.List<benchmark.model.Fortune> fortunes | ||
<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>@for(benchmark.model.Fortune fortune : fortunes) | ||
<tr><td>${fortune.id()}</td><td>${fortune.message()}</td></tr>@endfor | ||
</table></body></html> |
8 changes: 0 additions & 8 deletions
8
frameworks/Java/micronaut/common/src/main/resources/views/fortunes.rocker.html
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
micronautVersion=4.6.0 | ||
micronautVersion=4.6.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters