Skip to content

Commit f1be10e

Browse files
Update to MP6 and JEE10 (#237)
* update versions * Updating SystemClient.java (#238) * Updating SystemClient.java * updating copyright + start SystemClient * Update SystemClient.java * Update SystemClient.java --------- Co-authored-by: Gilbert Kwan <[email protected]> * remove unnecessary import statements --------- Co-authored-by: jakub-pomykala <[email protected]>
1 parent f3f6c9b commit f1be10e

File tree

38 files changed

+478
-480
lines changed

38 files changed

+478
-480
lines changed

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ jobs:
4747
working-directory: finish
4848
steps:
4949
- uses: actions/checkout@v2
50-
- name: Set up JDK 8
50+
- name: Set up JDK 11
5151
uses: actions/setup-java@v1
5252
with:
53-
java-version: 8
53+
java-version: 11
5454
- run: unset _JAVA_OPTIONS
5555
- name: Run tests
5656
run: ../scripts/testApp.sh

LICENSE

+246-172
Large diffs are not rendered by default.

finish/inventory/pom.xml

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
17-
<maven.compiler.source>1.8</maven.compiler.source>
18-
<maven.compiler.target>1.8</maven.compiler.target>
17+
<maven.compiler.source>11</maven.compiler.source>
18+
<maven.compiler.target>11</maven.compiler.target>
1919
<!-- Default test properties -->
2020
<!-- tag::system.kube.service[] -->
2121
<system.kube.service>system-service</system.kube.service>
@@ -36,13 +36,13 @@
3636
<dependency>
3737
<groupId>jakarta.platform</groupId>
3838
<artifactId>jakarta.jakartaee-api</artifactId>
39-
<version>9.1.0</version>
39+
<version>10.0.0</version>
4040
<scope>provided</scope>
4141
</dependency>
4242
<dependency>
4343
<groupId>org.eclipse.microprofile</groupId>
4444
<artifactId>microprofile</artifactId>
45-
<version>5.0</version>
45+
<version>6.0</version>
4646
<type>pom</type>
4747
<scope>provided</scope>
4848
</dependency>
@@ -56,19 +56,19 @@
5656
<dependency>
5757
<groupId>org.junit.jupiter</groupId>
5858
<artifactId>junit-jupiter</artifactId>
59-
<version>5.8.2</version>
59+
<version>5.9.2</version>
6060
<scope>test</scope>
6161
</dependency>
6262
<dependency>
6363
<groupId>org.jboss.resteasy</groupId>
6464
<artifactId>resteasy-client</artifactId>
65-
<version>6.0.0.Final</version>
65+
<version>6.2.3.Final</version>
6666
<scope>test</scope>
6767
</dependency>
6868
<dependency>
6969
<groupId>org.jboss.resteasy</groupId>
7070
<artifactId>resteasy-json-binding-provider</artifactId>
71-
<version>6.0.0.Final</version>
71+
<version>6.2.3.Final</version>
7272
<scope>test</scope>
7373
</dependency>
7474
<dependency>
@@ -96,13 +96,13 @@
9696
<plugin>
9797
<groupId>org.apache.maven.plugins</groupId>
9898
<artifactId>maven-surefire-plugin</artifactId>
99-
<version>2.22.2</version>
99+
<version>3.0.0</version>
100100
</plugin>
101101
<!-- Plugin to run functional tests -->
102102
<plugin>
103103
<groupId>org.apache.maven.plugins</groupId>
104104
<artifactId>maven-failsafe-plugin</artifactId>
105-
<version>2.22.2</version>
105+
<version>3.0.0</version>
106106
<configuration>
107107
<systemPropertyVariables>
108108
<inventory.service.root>${inventory.service.root}</inventory.service.root>

finish/inventory/src/main/java/io/openliberty/guides/inventory/InventoryApplication.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
/*******************************************************************************
33
* Copyright (c) 2017, 2022 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312

finish/inventory/src/main/java/io/openliberty/guides/inventory/InventoryManager.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// tag::copyright[]
22
/*******************************************************************************
3-
* Copyright (c) 2017, 2022 IBM Corporation and others.
3+
* Copyright (c) 2017, 2023 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package io.openliberty.guides.inventory;
@@ -16,11 +15,10 @@
1615
import java.util.Collections;
1716
import java.util.List;
1817
import java.util.Properties;
19-
import io.openliberty.guides.inventory.client.SystemClient;
18+
2019
import io.openliberty.guides.inventory.model.InventoryList;
2120
import io.openliberty.guides.inventory.model.SystemData;
2221
import jakarta.enterprise.context.ApplicationScoped;
23-
import jakarta.inject.Inject;
2422

2523
// tag::ApplicationScoped[]
2624
@ApplicationScoped

finish/inventory/src/main/java/io/openliberty/guides/inventory/InventoryResource.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
/*******************************************************************************
33
* Copyright (c) 2017, 2022 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package io.openliberty.guides.inventory;
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// tag::copyright[]
22
/*******************************************************************************
3-
* Copyright (c) 2017, 2022 IBM Corporation and others.
3+
* Copyright (c) 2017, 2023 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package io.openliberty.guides.inventory.client;
@@ -30,75 +29,50 @@
3029
@RequestScoped
3130
public class SystemClient {
3231

33-
// Constants for building URI to the system service.
34-
private final String SYSTEM_PROPERTIES = "/system/properties";
35-
private final String PROTOCOL = "http";
32+
// Constants for building URI to the system service.
33+
private final String SYSTEM_PROPERTIES = "/system/properties";
34+
private final String PROTOCOL = "http";
3635

37-
@Inject
38-
@ConfigProperty(name = "default.http.port")
39-
String DEFAULT_PORT;
36+
@Inject
37+
@ConfigProperty(name = "default.http.port")
38+
String DEFAULT_PORT;
4039

41-
// Wrapper function that gets properties
42-
public Properties getProperties(String hostname) {
43-
String url = buildUrl(PROTOCOL, hostname, Integer.valueOf(DEFAULT_PORT),
44-
SYSTEM_PROPERTIES);
45-
Builder clientBuilder = buildClientBuilder(url);
46-
return getPropertiesHelper(clientBuilder);
47-
}
48-
49-
// tag::doc[]
50-
/**
51-
* Builds the URI string to the system service for a particular host.
52-
* @param protocol
53-
* - http or https.
54-
* @param host
55-
* - name of host.
56-
* @param port
57-
* - port number.
58-
* @param path
59-
* - Note that the path needs to start with a slash!!!
60-
* @return String representation of the URI to the system properties service.
61-
*/
62-
// end::doc[]
63-
protected String buildUrl(String protocol, String host, int port, String path) {
64-
try {
65-
URI uri = new URI(protocol, null, host, port, path, null, null);
66-
return uri.toString();
67-
} catch (Exception e) {
68-
System.err.println("Exception thrown while building the URL: " + e.getMessage());
69-
return null;
40+
// Wrapper function that gets properties
41+
public Properties getProperties(String hostname) {
42+
Properties properties = null;
43+
Client client = ClientBuilder.newClient();
44+
try {
45+
Builder builder = getBuilder(hostname, client);
46+
properties = getPropertiesHelper(builder);
47+
} catch (Exception e) {
48+
System.err.println(
49+
"Exception thrown while getting properties: " + e.getMessage());
50+
} finally {
51+
client.close();
52+
}
53+
return properties;
7054
}
71-
}
7255

73-
// Method that creates the client builder
74-
protected Builder buildClientBuilder(String urlString) {
75-
try {
76-
Client client = ClientBuilder.newClient();
77-
Builder builder = client.target(urlString).request();
78-
return builder.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
79-
} catch (Exception e) {
80-
System.err.println("Exception thrown while building the client: "
81-
+ e.getMessage());
82-
return null;
56+
// Method that creates the client builder
57+
private Builder getBuilder(String hostname, Client client) throws Exception {
58+
URI uri = new URI(
59+
PROTOCOL, null, hostname, Integer.valueOf(DEFAULT_PORT),
60+
SYSTEM_PROPERTIES, null, null);
61+
String urlString = uri.toString();
62+
Builder builder = client.target(urlString).request();
63+
builder.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
64+
return builder;
8365
}
84-
}
8566

86-
// Helper method that processes the request
87-
protected Properties getPropertiesHelper(Builder builder) {
88-
try {
89-
Response response = builder.get();
90-
if (response.getStatus() == Status.OK.getStatusCode()) {
91-
return response.readEntity(Properties.class);
92-
} else {
93-
System.err.println("Response Status is not OK.");
94-
}
95-
} catch (RuntimeException e) {
96-
System.err.println("Runtime exception: " + e.getMessage());
97-
} catch (Exception e) {
98-
System.err.println("Exception thrown while invoking the request: "
99-
+ e.getMessage());
67+
// Helper method that processes the request
68+
private Properties getPropertiesHelper(Builder builder) throws Exception {
69+
Response response = builder.get();
70+
if (response.getStatus() == Status.OK.getStatusCode()) {
71+
return response.readEntity(Properties.class);
72+
} else {
73+
System.err.println("Response Status is not OK.");
74+
return null;
75+
}
10076
}
101-
return null;
102-
}
10377

10478
}

finish/inventory/src/main/java/io/openliberty/guides/inventory/health/InventoryReadinessCheck.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
/*******************************************************************************
33
* Copyright (c) 2019, 2022 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package io.openliberty.guides.inventory.health;

finish/inventory/src/main/java/io/openliberty/guides/inventory/model/InventoryList.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
/*******************************************************************************
33
* Copyright (c) 2017, 2018 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package io.openliberty.guides.inventory.model;

finish/inventory/src/main/java/io/openliberty/guides/inventory/model/SystemData.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
/*******************************************************************************
33
* Copyright (c) 2017, 2019 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package io.openliberty.guides.inventory.model;

finish/inventory/src/main/liberty/config/server.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<server description="Sample Liberty server">
22

33
<featureManager>
4-
<feature>restfulWS-3.0</feature>
5-
<feature>jsonb-2.0</feature>
6-
<feature>cdi-3.0</feature>
4+
<feature>restfulWS-3.1</feature>
5+
<feature>jsonb-3.0</feature>
6+
<feature>cdi-4.0</feature>
77
<feature>mpConfig-3.0</feature>
8-
<feature>jsonp-2.0</feature>
8+
<feature>jsonp-2.1</feature>
99
<feature>mpHealth-4.0</feature>
1010
</featureManager>
1111

finish/inventory/src/main/webapp/index.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
Copyright (c) 2016, 2022 IBM Corp.
2+
Copyright (c) 2016, 2023 IBM Corp.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -30,12 +30,12 @@ <h2>Eclipse MicroProfile</h2>
3030
<p>
3131
For more information about the features used in this application, see the Open Liberty documentation:
3232
<ul>
33-
<li><a href="https://openliberty.io/docs/ref/feature/#microProfile-5.0.html" target="_blank" rel="noopener noreferrer">MicroProfile 5.0</a></li>
34-
<li><a href="https://openliberty.io/docs/ref/feature/#restfulWS-3.0.html" target="_blank" rel="noopener noreferrer">Java RESTful Services 3.0</a></li>
35-
<li><a href="https://openliberty.io/docs/ref/feature/#cdi-3.0.html" target="_blank" rel="noopener noreferrer">Contexts and Dependency Injection 3.0</a></li>
33+
<li><a href="https://openliberty.io/docs/ref/feature/#microProfile-6.0.html" target="_blank" rel="noopener noreferrer">MicroProfile 6.0</a></li>
34+
<li><a href="https://openliberty.io/docs/ref/feature/#restfulWS-3.1.html" target="_blank" rel="noopener noreferrer">Jakarta RESTful Web Services 3.1</a></li>
35+
<li><a href="https://openliberty.io/docs/ref/feature/#cdi-4.0.html" target="_blank" rel="noopener noreferrer">Jakarta Contexts and Dependency Injection 4.0</a></li>
3636
<li><a href="https://openliberty.io/docs/ref/feature/#mpConfig-3.0.html" target="_blank" rel="noopener noreferrer">MicroProfile Config 3.0</a></li>
37-
<li><a href="https://openliberty.io/docs/ref/feature/#jsonp-2.0.html" target="_blank" rel="noopener noreferrer">JavaScript Object Notation Processing 2.0</a></li>
38-
<li><a href="https://openliberty.io/docs/ref/feature/#jsonb-2.0.html" target="_blank" rel="noopener noreferrer">JavaScript Object Notation Binding 2.0</a></li>
37+
<li><a href="https://openliberty.io/docs/ref/feature/#jsonp-2.1.html" target="_blank" rel="noopener noreferrer">Jakarta JSON Processing 2.1</a></li>
38+
<li><a href="https://openliberty.io/docs/ref/feature/#jsonb-3.0.html" target="_blank" rel="noopener noreferrer">Jakarta JSON Binding 3.0</a></li>
3939
</ul>
4040
</p>
4141
</div>

finish/inventory/src/test/java/it/io/openliberty/guides/inventory/InventoryEndpointIT.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
/*******************************************************************************
33
* Copyright (c) 2018, 2022 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package it.io.openliberty.guides.inventory;

0 commit comments

Comments
 (0)