Skip to content

Commit

Permalink
Apply fixes from reviewer; Downgrade to Java 17 and Helidon BOM 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
olyagpl committed Dec 11, 2023
1 parent ec4042b commit 45ffa72
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 24 deletions.
4 changes: 2 additions & 2 deletions js-java-async-helidon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This is a polyglot Helidon HTTP web service that demonstrates how multiple JavaS

1. Download and install the latest GraalVM JDK using [SDKMAN!](https://sdkman.io/).
```bash
sdk install java 21.0.1-graal
sdk install java 17.0.9-graal
```

2. Download or clone the repository and navigate into the `js-java-async-helidon` directory:
Expand All @@ -31,7 +31,7 @@ Now you are all set to run the polyglot Helidon Web service.

You can run this Helidon HTTP web service with the following command:
```bash
$JAVA_HOME/bin/java -jar target/polyglotHelidonService-SNAPSHOT-jar-with-dependencies.jar
$JAVA_HOME/bin/java -jar target/polyglotHelidonService-1.0-jar-with-dependencies.jar
```

The application will create a new HTTP web service accepting requests on port `8080`.
Expand Down
43 changes: 34 additions & 9 deletions js-java-async-helidon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,48 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>21</source>
<target>21</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<arguments>
<argument>--module-path</argument>
<!-- automatically creates the modulepath using all project dependencies -->
<modulepath/>
<argument>-m</argument>
<argument>org.graalvm.demo.JsJavaAsyncHelidonService</argument>
</arguments>
</configuration>
</execution>
</executions>
<configuration>
<executable>${JAVA_HOME}/bin/java</executable>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<graalvm.version>21.0.1</graalvm.version>
<graalvm.version>23.1.1</graalvm.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.helidon</groupId>
<artifactId>helidon-bom</artifactId>
<version>4.0.0</version>
<version>3.2.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -72,27 +97,27 @@
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>collections</artifactId>
<version>23.1.1</version>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>nativeimage</artifactId>
<version>23.1.1</version>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>word</artifactId>
<version>23.1.1</version>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>polyglot</artifactId>
<version>23.1.0</version>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>js</artifactId>
<version>23.1.0</version>
<version>${graalvm.version}</version>
<type>pom</type>
</dependency>
</dependencies>
Expand Down
4 changes: 2 additions & 2 deletions js-java-async-helidon/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module embedding {
module demo {
exports org.graalvm.demo;

requires org.graalvm.polyglot;
requires io.helidon.webserver;
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
package org.graalvm.demo;

import io.helidon.webserver.Routing;
import io.helidon.webserver.ServerConfiguration;
import io.helidon.webserver.WebServer;

/**
Expand Down Expand Up @@ -71,12 +70,12 @@ class HelidonService {
+ "})";
private final String requestPath;
private final ConcurrentJsExecutor jsExecutor;
private final ServerConfiguration configuration;
private final int port;

HelidonService(String requestPath, ServerConfiguration configuration) {
HelidonService(String requestPath, int port) {
this.requestPath = requestPath;
this.jsExecutor = new ConcurrentJsExecutor(jsCode);
this.configuration = configuration;
this.port = port;
}

/**
Expand All @@ -86,7 +85,7 @@ public void init() {
/*
* Register a request handler for the HTTP GET request.
*/
WebServer.create(configuration, Routing.builder().get(requestPath, (req, res) -> {
Routing routing = Routing.builder().get(requestPath, (req, res) -> {
/*
* Parse `?request=xxx` from an incoming request's URL. If not found, use a
* default value.
Expand Down Expand Up @@ -120,7 +119,11 @@ public void init() {
res.send("There was an error: " + ex.getMessage());
}
});
}).build()).start();
}).build();
WebServer.builder()
.port(port)
.addRouting(routing)
.build()
.start();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
*/
package org.graalvm.demo;

import io.helidon.webserver.ServerConfiguration;

/**
* Main Helidon web service class. The Helidon HTTP service will listen for
* incoming requests on the following URLs: <a
Expand All @@ -60,8 +58,7 @@ public class JsJavaAsyncHelidonService {
private static final int PORT = 8080;

public static void main(String[] args) {
ServerConfiguration configuration = ServerConfiguration.builder().port(PORT).build();
new HelidonService(ROUTE, configuration).init();
new HelidonService(ROUTE, PORT).init();
}

}

0 comments on commit 45ffa72

Please sign in to comment.