Skip to content

Commit

Permalink
Update to Jakarta EE 10 and MP 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Emily-Jiang committed May 22, 2023
1 parent f362b9f commit e87caa7
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 78 deletions.
Binary file modified .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
42 changes: 21 additions & 21 deletions pom.xml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- Plugin versions -->
<version.liberty-maven-plugin>3.6.1</version.liberty-maven-plugin>
<version.maven-failsafe-plugin>2.22.2</version.maven-failsafe-plugin>
<version.maven-surefire-plugin>2.22.2</version.maven-surefire-plugin>
<version.liberty-maven-plugin>3.7.1</version.liberty-maven-plugin>
<version.maven-failsafe-plugin>3.0.0</version.maven-failsafe-plugin>
<version.maven-surefire-plugin>3.0.0</version.maven-surefire-plugin>
<!-- Liberty configuration -->
<liberty.var.default.http.port>9080</liberty.var.default.http.port>
<liberty.var.default.https.port>9443</liberty.var.default.https.port>
Expand All @@ -30,40 +30,40 @@
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>4.1</version>
<version>6.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<!-- Dependencies for tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.5.3</version>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>6.2.3.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-extension-providers</artifactId>
<version>3.5.3</version>
<scope>test</scope>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-json-binding-provider</artifactId>
<version>6.2.3.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1.4</version>
<scope>test</scope>
</dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.json</artifactId>
<version>2.0.1</version>
<scope>test</scope>
</dependency>
<!-- Support for JDK 9 and above -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion resources/CustomConfigSource.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"config_ordinal":550,"io_openliberty_sample_system_inMaintenance":false,"io_openliberty_sample_testConfigOverwrite":"CustomSource"}
{"config_ordinal":550,"io_openliberty_sample_system_inMaintenance":false,"io_openliberty_sample_testConfigOverwrite":"CustomSource"}
4 changes: 2 additions & 2 deletions src/main/java/io/openliberty/sample/SampleApplication.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

package io.openliberty.sample;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

@ApplicationPath("system")
public class SampleApplication extends Application {
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/io/openliberty/sample/config/ConfigResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

package io.openliberty.sample.config;

import javax.enterprise.context.RequestScoped;
import javax.ws.rs.core.MediaType;

import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.Json;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import jakarta.enterprise.context.RequestScoped;
import jakarta.ws.rs.core.MediaType;

import jakarta.json.JsonObject;
import jakarta.json.JsonObjectBuilder;
import jakarta.json.Json;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.spi.ConfigSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

package io.openliberty.sample.config;

import javax.json.stream.JsonParser;
import javax.json.stream.JsonParser.Event;
import javax.json.Json;
import jakarta.json.stream.JsonParser;
import jakarta.json.stream.JsonParser.Event;
import jakarta.json.Json;
import java.math.BigDecimal;
import java.util.*;
import java.io.StringReader;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/openliberty/sample/system/SystemConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

package io.openliberty.sample.system;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Provider;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.inject.Provider;

import org.eclipse.microprofile.config.inject.ConfigProperty;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/openliberty/sample/system/SystemHealth.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*******************************************************************************/
package io.openliberty.sample.system;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/io/openliberty/sample/system/SystemResource.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

package io.openliberty.sample.system;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;

import org.eclipse.microprofile.metrics.annotation.Counted;
import org.eclipse.microprofile.metrics.annotation.Timed;

import javax.ws.rs.GET;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;

@RequestScoped
@Path("/properties")
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/io/openliberty/sample/system/SystemRuntime.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

import java.lang.management.ManagementFactory;

import javax.enterprise.context.RequestScoped;
import jakarta.enterprise.context.RequestScoped;

import javax.ws.rs.GET;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;

import javax.management.ObjectName;
import javax.management.MBeanInfo;
Expand Down
9 changes: 5 additions & 4 deletions src/main/liberty/config/server.xml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<server description="Sample Open Liberty server">

<featureManager>
<feature>jaxrs-2.1</feature>
<feature>mpConfig-2.0</feature>
<feature>mpHealth-3.1</feature>
<feature>mpMetrics-3.0</feature>
<feature>restfulWS-3.1</feature>
<feature>jsonb-3.0</feature>
<feature>mpMetrics-5.0</feature>
<feature>mpHealth-4.0</feature>
<feature>mpConfig-3.0</feature>
</featureManager>

<applicationManager autoExpand="true" />
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/WEB-INF/web.xml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
version="5.0">
<display-name>Liberty Project</display-name>

<welcome-file-list>
Expand Down
14 changes: 7 additions & 7 deletions src/main/webapp/js/mpData.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ function getSystemMetrics() {
var req = new XMLHttpRequest();

var metricToDisplay = {};
var SRgetPropertiesTime = "application_io_openliberty_sample_system_SystemResource_getPropertiesTime";
metricToDisplay["application_getProperties_total"] = "Request Count";
metricToDisplay[SRgetPropertiesTime + "_min_seconds"] = "Min Request Time (ms)";
metricToDisplay[SRgetPropertiesTime + "_mean_seconds"] = "Mean Request Time (ms)";
metricToDisplay[SRgetPropertiesTime + "_max_seconds"] = "Max Request Time (ms)";
metricToDisplay["base_cpu_processCpuLoad_percent"] = "System CPU Usage (%)";
metricToDisplay["base_memory_usedHeap_bytes"] = "System Heap Usage (MB)";
var SRgetPropertiesTime = "io_openliberty_sample_system_SystemResource_getPropertiesTime";
metricToDisplay["getProperties_total{mp_scope=\"application\",}"] = "Request Count";
metricToDisplay[SRgetPropertiesTime + "_seconds{mp_scope=\"application\",quantile=\"0.999\",}"] = "Request Time (ms) at Quantile 0.999";
metricToDisplay[SRgetPropertiesTime + "_seconds{mp_scope=\"application\",quantile=\"0.5\",}"] = "Request Time (ms) at Quantile 0.5";
metricToDisplay[SRgetPropertiesTime + "_seconds_max{mp_scope=\"application\",}"] = "Max Request Time (ms)";
metricToDisplay["cpu_processCpuLoad_percent{mp_scope=\"base\",}"] = "System CPU Usage (%)";
metricToDisplay["memory_usedHeap_bytes{mp_scope=\"base\",}"] = "System Heap Usage (MB)";

var metricToMatch = "^(";
for (var metricKey in metricToDisplay) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
package it.io.openliberty.sample.health;

import java.util.HashMap;
import javax.json.JsonArray;
import jakarta.json.JsonArray;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand Down
14 changes: 6 additions & 8 deletions src/test/java/it/io/openliberty/sample/health/HealthUtilIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
import java.io.FileReader;
import java.io.FileWriter;

import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.core.Response;

public class HealthUtilIT {

Expand All @@ -43,7 +41,7 @@ public class HealthUtilIT {

public static JsonArray connectToHealthEnpoint(int expectedResponseCode) {
String healthURL = baseUrl + HEALTH_ENDPOINT;
Client client = ClientBuilder.newClient().register(JsrJsonpProvider.class);
Client client = ClientBuilder.newClient();
Response response = client.target(healthURL).request().get();
assertEquals(expectedResponseCode, response.getStatus(), "Response code is not matching " + healthURL);
JsonArray servicesstatus = response.readEntity(JsonObject.class).getJsonArray("checks");
Expand Down

0 comments on commit e87caa7

Please sign in to comment.