diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 986d5e4..ddbe1eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,9 +12,9 @@ jobs: canSkip: ${{ steps.Checker.outputs.canSkip }} steps: - name: Get files - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Get tools - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: tools/ repository: openliberty/guides-common @@ -45,10 +45,11 @@ jobs: working-directory: finish steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK 11 - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'semeru' java-version: 11 - run: unset _JAVA_OPTIONS diff --git a/finish/pom.xml b/finish/pom.xml index b77b896..10d1cef 100644 --- a/finish/pom.xml +++ b/finish/pom.xml @@ -30,7 +30,7 @@ org.eclipse.microprofile microprofile - 6.1 + 7.0 pom provided diff --git a/finish/src/main/java/io/openliberty/guides/microprofile/util/InventoryUtil.java b/finish/src/main/java/io/openliberty/guides/microprofile/util/InventoryUtil.java index 4ba0679..6700b10 100755 --- a/finish/src/main/java/io/openliberty/guides/microprofile/util/InventoryUtil.java +++ b/finish/src/main/java/io/openliberty/guides/microprofile/util/InventoryUtil.java @@ -1,6 +1,6 @@ // tag::copyright[] /******************************************************************************* - * Copyright (c) 2017, 2022 IBM Corporation and others. + * Copyright (c) 2017, 2025 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -35,9 +35,11 @@ public class InventoryUtil { public static JsonObject getProperties(String hostname) { Client client = ClientBuilder.newClient(); URI propURI = InventoryUtil.buildUri(hostname); - return client.target(propURI) - .request(MediaType.APPLICATION_JSON) - .get(JsonObject.class); + JsonObject properties = client.target(propURI) + .request(MediaType.APPLICATION_JSON) + .get(JsonObject.class); + client.close(); + return properties; } // tag::buildLinksForHost[] @@ -69,7 +71,7 @@ public static boolean responseOk(String hostname) { HttpURLConnection http = (HttpURLConnection) target.openConnection(); http.setConnectTimeout(50); int response = http.getResponseCode(); - return (response != 200) ? false : true; + return response == 200; } catch (Exception e) { return false; } diff --git a/finish/src/main/liberty/config/server.xml b/finish/src/main/liberty/config/server.xml index 324569e..012ebd5 100755 --- a/finish/src/main/liberty/config/server.xml +++ b/finish/src/main/liberty/config/server.xml @@ -1,10 +1,11 @@ - restfulWS-3.1 - jsonb-3.0 - jsonp-2.1 - cdi-4.0 + jakartaee-10.0 + restfulWS + jsonb + jsonp + cdi diff --git a/finish/src/main/webapp/favicon.ico b/finish/src/main/webapp/favicon.ico new file mode 100644 index 0000000..c8652f3 Binary files /dev/null and b/finish/src/main/webapp/favicon.ico differ diff --git a/finish/src/main/webapp/index.html b/finish/src/main/webapp/index.html index c099a75..2ab1da7 100755 --- a/finish/src/main/webapp/index.html +++ b/finish/src/main/webapp/index.html @@ -35,11 +35,11 @@

Eclipse MicroProfile

For more information about the features used in this application, see the Open Liberty documentation:

diff --git a/start/pom.xml b/start/pom.xml index b77b896..10d1cef 100644 --- a/start/pom.xml +++ b/start/pom.xml @@ -30,7 +30,7 @@ org.eclipse.microprofile microprofile - 6.1 + 7.0 pom provided diff --git a/start/src/main/java/io/openliberty/guides/microprofile/InventoryManager.java b/start/src/main/java/io/openliberty/guides/microprofile/InventoryManager.java index 3f73102..f21a840 100755 --- a/start/src/main/java/io/openliberty/guides/microprofile/InventoryManager.java +++ b/start/src/main/java/io/openliberty/guides/microprofile/InventoryManager.java @@ -1,6 +1,6 @@ // tag::copyright[] /******************************************************************************* - * Copyright (c) 2017, 2022 IBM Corporation and others. + * Copyright (c) 2017, 2025 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -22,18 +22,12 @@ import io.openliberty.guides.microprofile.util.InventoryUtil; import io.openliberty.guides.microprofile.util.ReadyJson; -// tag::header[] -// tag::cdi-scope[] @ApplicationScoped -// end::cdi-scope[] public class InventoryManager { -// end::header[] private ConcurrentMap inv = new ConcurrentHashMap<>(); - // tag::get[] public JsonObject get(String hostname) { - // tag::method-contents[] JsonObject properties = inv.get(hostname); if (properties == null) { if (InventoryUtil.responseOk(hostname)) { @@ -44,21 +38,13 @@ public JsonObject get(String hostname) { } } return properties; - // end::method-contents[] } - // end::get[] - // tag::add[] public void add(String hostname, JsonObject systemProps) { - // tag::method-contents[] inv.putIfAbsent(hostname, systemProps); - // end::method-contents[] } - // end::add[] - // tag::list[] public JsonObject list() { - // tag::method-contents[] JsonObjectBuilder systems = Json.createObjectBuilder(); inv.forEach((host, props) -> { JsonObject systemProps = Json.createObjectBuilder() @@ -70,8 +56,6 @@ public JsonObject list() { systems.add("hosts", systems); systems.add("total", inv.size()); return systems.build(); - // end::method-contents[] } - // end::list[] } diff --git a/start/src/main/java/io/openliberty/guides/microprofile/InventoryResource.java b/start/src/main/java/io/openliberty/guides/microprofile/InventoryResource.java index 269a74c..64de67d 100755 --- a/start/src/main/java/io/openliberty/guides/microprofile/InventoryResource.java +++ b/start/src/main/java/io/openliberty/guides/microprofile/InventoryResource.java @@ -1,6 +1,6 @@ // tag::copyright[] /******************************************************************************* - * Copyright (c) 2017, 2022 IBM Corporation and others. + * Copyright (c) 2017, 2025 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -20,38 +20,23 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; -// tag::header[] -// tag::cdi-scope[] @ApplicationScoped -// end::cdi-scope[] @Path("hosts") public class InventoryResource { -// end::header[] - - // tag::injection[] @Inject InventoryManager manager; - // end::injection[] - // tag::getPropertiesForHost[] @GET @Path("{hostname}") @Produces(MediaType.APPLICATION_JSON) public JsonObject getPropertiesForHost(@PathParam("hostname") String hostname) { - // tag::method-contents[] return manager.get(hostname); - // end::method-contents[] } - // end::getPropertiesForHost[] - // tag::listContents[] @GET @Produces(MediaType.APPLICATION_JSON) public JsonObject listContents() { - // tag::method-contents[] return manager.list(); - // end::method-contents[] } - // end::listContents[] } diff --git a/start/src/main/java/io/openliberty/guides/microprofile/util/InventoryUtil.java b/start/src/main/java/io/openliberty/guides/microprofile/util/InventoryUtil.java index c6c44c2..1bce562 100755 --- a/start/src/main/java/io/openliberty/guides/microprofile/util/InventoryUtil.java +++ b/start/src/main/java/io/openliberty/guides/microprofile/util/InventoryUtil.java @@ -1,6 +1,6 @@ // tag::copyright[] /******************************************************************************* - * Copyright (c) 2017, 2022 IBM Corporation and others. + * Copyright (c) 2017, 2025 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -30,9 +30,11 @@ public class InventoryUtil { public static JsonObject getProperties(String hostname) { Client client = ClientBuilder.newClient(); URI propURI = InventoryUtil.buildUri(hostname); - return client.target(propURI) - .request(MediaType.APPLICATION_JSON) - .get(JsonObject.class); + JsonObject properties = client.target(propURI) + .request(MediaType.APPLICATION_JSON) + .get(JsonObject.class); + client.close(); + return properties; } public static boolean responseOk(String hostname) { @@ -41,7 +43,7 @@ public static boolean responseOk(String hostname) { HttpURLConnection http = (HttpURLConnection) target.openConnection(); http.setConnectTimeout(50); int response = http.getResponseCode(); - return (response != 200) ? false : true; + return response == 200; } catch (Exception e) { return false; } diff --git a/start/src/main/liberty/config/server.xml b/start/src/main/liberty/config/server.xml index 324569e..012ebd5 100755 --- a/start/src/main/liberty/config/server.xml +++ b/start/src/main/liberty/config/server.xml @@ -1,10 +1,11 @@ - restfulWS-3.1 - jsonb-3.0 - jsonp-2.1 - cdi-4.0 + jakartaee-10.0 + restfulWS + jsonb + jsonp + cdi diff --git a/start/src/main/webapp/favicon.ico b/start/src/main/webapp/favicon.ico new file mode 100644 index 0000000..c8652f3 Binary files /dev/null and b/start/src/main/webapp/favicon.ico differ diff --git a/start/src/main/webapp/index.html b/start/src/main/webapp/index.html index c099a75..2ab1da7 100755 --- a/start/src/main/webapp/index.html +++ b/start/src/main/webapp/index.html @@ -35,11 +35,11 @@

Eclipse MicroProfile

For more information about the features used in this application, see the Open Liberty documentation: