File tree Expand file tree Collapse file tree
kotlin/pt/isel/genius/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ## Usage
2+
3+ Run with:
4+
5+ ```
6+ ./gradlew bootRun
7+ ```
Original file line number Diff line number Diff line change @@ -10,13 +10,24 @@ plugins {
1010
1111group = " pt.isel"
1212version = " 0.0.1-SNAPSHOT"
13- java.sourceCompatibility = JavaVersion .VERSION_11
13+ java.sourceCompatibility = JavaVersion .VERSION_17
1414
1515repositories {
1616 mavenCentral()
1717 mavenLocal()
1818}
1919
20+ sourceSets {
21+ main {
22+ java {
23+ setSrcDirs(emptyList<String >()) // no source dirs for the java compiler
24+ }
25+ groovy {
26+ setSrcDirs(listOf (" src/main/java" , " src/main/groovy" )) // compile everything in src/ with groovy
27+ }
28+ }
29+ }
30+
2031dependencies {
2132 implementation(" org.slf4j:slf4j-simple:2.0.6" )
2233 /* *
@@ -57,6 +68,15 @@ tasks.withType<KotlinCompile> {
5768 }
5869}
5970
71+ tasks
72+ .getByName<AbstractCompile >(" compileGroovy" )
73+ .dependsOn(tasks.getByName<KotlinCompile >(" compileKotlin" ))
74+
75+ tasks
76+ .getByName<AbstractCompile >(" compileGroovy" )
77+ .classpath + = files(tasks.getByName<KotlinCompile >(" compileKotlin" ).destinationDirectory)
78+
6079tasks.withType<Test > {
6180 useJUnitPlatform()
6281}
82+
Original file line number Diff line number Diff line change 1+ package pt .isel .genius ;
2+
3+ import org .springframework .boot .SpringApplication ;
4+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
5+
6+ @ SpringBootApplication
7+ public class GeniusApplication {
8+
9+ public static void main (String [] args ) {
10+ /**
11+ * Limit request handler threads to a single worker thread.
12+ * Thus, handlers should be non-blocking to allow multiple requests concurrently.
13+ * NOTICE minimum default to 4.
14+ */
15+ System .setProperty ("reactor.netty.ioWorkerCount" , "1" ); // minimum default to 4
16+ SpringApplication .run (GeniusApplication .class , args );
17+ }
18+ }
19+
Original file line number Diff line number Diff line change 1+ package pt .isel .genius ;
2+
3+ import org .springframework .context .annotation .Bean ;
4+ import org .springframework .context .annotation .ComponentScan ;
5+ import org .springframework .context .annotation .Configuration ;
6+ import org .springframework .web .reactive .function .server .RouterFunction ;
7+ import org .springframework .web .reactive .function .server .ServerResponse ;
8+ import pt .isel .genius .groovy .ArtistRouterGroovy ;
9+ import pt .isel .genius .htmlflow .ArtistRouterHtmlFlowKt ;
10+ import pt .isel .genius .kotlinx .ArtistRouterKotlinxKt ;
11+ import pt .isel .genius .thymeleaf .ArtistRouterThymeleafKt ;
12+
13+ @ Configuration
14+ @ ComponentScan
15+ public class WebConfig {
16+ @ Bean
17+ public RouterFunction <ServerResponse > routerArtistHtmlFlow () {
18+ return ArtistRouterHtmlFlowKt .artistRouterHtmlFlow ();
19+ }
20+
21+ @ Bean
22+ public RouterFunction <ServerResponse > routerArtistKotlinX () {
23+ return ArtistRouterKotlinxKt .artistCoRouterKotlinX ();
24+ }
25+
26+ @ Bean
27+ public RouterFunction <ServerResponse > routerArtistThymeleaf () {
28+ return ArtistRouterThymeleafKt .artistRouterThymeleaf ();
29+ }
30+
31+ @ Bean
32+ public RouterFunction <ServerResponse > routerArtistGroovy () {
33+ return ArtistRouterGroovy .artistRouterHtmlGroovy ();
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ package pt .isel .genius .groovy ;
2+
3+ import org .springframework .core .ParameterizedTypeReference ;
4+ import org .springframework .http .MediaType ;
5+ import org .springframework .web .reactive .function .server .RouterFunction ;
6+ import org .springframework .web .reactive .function .server .RouterFunctions ;
7+ import org .springframework .web .reactive .function .server .ServerRequest ;
8+ import org .springframework .web .reactive .function .server .ServerResponse ;
9+ import pt .isel .genius .AppendableWriter ;
10+ import pt .isel .genius .GeniusRepositoryKt ;
11+ import reactor .core .publisher .Mono ;
12+
13+ public class ArtistRouterGroovy {
14+ public static RouterFunction <ServerResponse > artistRouterHtmlGroovy () {
15+ return RouterFunctions
16+ .route ()
17+ .path ("/groovy" , builder -> builder
18+ .GET ("/reactive/playlist" , req -> handlerPlaylist (req ))
19+ )
20+ .build ();
21+ }
22+
23+ private static Mono <ServerResponse > handlerPlaylist (ServerRequest req ) {
24+ final var out = new AppendableWriter (writer -> {
25+ ArtistViewGroovy .playlistView (writer , GeniusRepositoryKt .getTracks ());
26+ return null ;
27+ });
28+ return ServerResponse
29+ .ok ()
30+ .contentType (MediaType .TEXT_HTML )
31+ .body (out .asFlux (), new ParameterizedTypeReference <String >() {});
32+ }
33+ }
Load diff This file was deleted.
Load diff This file was deleted.
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments