Skip to content

Commit

Permalink
Merge pull request #27 from jGauravGupta/FISH-8087
Browse files Browse the repository at this point in the history
FISH-8087 JDK 21 Support in Payara Starter
  • Loading branch information
jGauravGupta authored Jan 11, 2024
2 parents 02341da + ae52d10 commit eec0ad2
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private void validateInput(String profile, String jakartaEEVersion, String javaV
}

if (!isValidJavaVersion(javaVersion)) {
throwAndDelete("Failed, valid Java SE versions are 8, 11, and 17", outputDirectory);
throwAndDelete("Failed, valid Java SE versions are 8, 11, 17, and 21", outputDirectory);
}

if (!isValidPlatform(platform)) {
Expand All @@ -60,7 +60,7 @@ private boolean isValidProfile(String profile) {
}

private boolean isValidJavaVersion(String version) {
return version.equals("8") || version.equals("11") || version.equals("17");
return version.equals("8") || version.equals("11") || version.equals("17") || version.equals("21");
}

private boolean isValidPlatform(String platform) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
</requiredProperty>
<requiredProperty key="javaVersion">
<defaultValue>17</defaultValue>
<validationRegex>^(8|11|17)$</validationRegex>
<validationRegex>^(8|11|17|21)$</validationRegex>
</requiredProperty>
<requiredProperty key="platform">
<defaultValue>server</defaultValue>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
#end
#end
#if (${platform} == 'server')
#if (${javaVersion} == '17')
#if (${javaVersion} == '21')
#if (${profile} == 'full')
#set ($baseImage = "payara/server-full:${payaraVersion}-jdk21")
#else
#set ($baseImage = "payara/server-web:${payaraVersion}-jdk21")
#end
#elseif (${javaVersion} == '17')
#if (${profile} == 'full')
#set ($baseImage = "payara/server-full:${payaraVersion}-jdk17")
#else
Expand All @@ -26,7 +32,9 @@
#end
#end
#elseif (${platform} == 'micro')
#if (${javaVersion} == '17')
#if (${javaVersion} == '21')
#set ($baseImage = "payara/micro:${payaraVersion}-jdk21")
#elseif (${javaVersion} == '17')
#set ($baseImage = "payara/micro:${payaraVersion}-jdk17")
#elseif (${javaVersion} == '11')
#set ($baseImage = "payara/micro:${payaraVersion}-jdk11")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To run the application locally, follow these steps:

1. Open a terminal and navigate to the project's root directory.

2. Make sure you have the appropriate Java version installed. We have tested with Java SE 8, Java SE 11, and Java SE 17.
2. Make sure you have the appropriate Java version installed. We have tested with Java SE 8, Java SE 11, Java SE 17, and Java SE 21.

3. Execute the following command:

Expand Down
77 changes: 55 additions & 22 deletions starter-ui/src/main/webapp/assets/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ form.addEventListener('submit', function (event) {
event.preventDefault();

document.getElementById('loadingBar').style.display = 'block';
document.getElementById('loadingBar').scrollIntoView({ behavior: 'smooth' });
document.getElementById('loadingBar').scrollIntoView({behavior: 'smooth'});

const form = event.target;
const formData = new FormData(form);
Expand Down Expand Up @@ -159,12 +159,19 @@ const jakartaVersions = {
};

const javaVersions = {
"21": "Java SE 21",
"17": "Java SE 17",
"11": "Java SE 11",
"8": "Java SE 8"
};


const payaraVersionSelect = document.getElementById('payaraVersion');
const jakartaEEVersionSelect = document.getElementById('jakartaEEVersion');
const javaVersionSelect = document.getElementById('javaVersion');
const webProfileRadioButton = document.getElementById('web');
const coreProfileRadioButton = document.getElementById('core');

// Function to populate a select element with options
function populateSelect(selectId, optionOrder, optionMap) {
const select = document.getElementById(selectId);
Expand Down Expand Up @@ -195,63 +202,89 @@ function populatePayaraVersionsDropdown(jakartaEEVersion) {
}
})
.then(versions => {
const payaraVersion = document.getElementById('payaraVersion');
payaraVersion.innerHTML = ''; // Clear existing options
payaraVersionSelect.innerHTML = ''; // Clear existing options

// Add an option for each version
versions.forEach(version => {
const option = document.createElement('option');
option.value = version;
option.text = version;
payaraVersion.appendChild(option);
payaraVersionSelect.appendChild(option);
});
listJavaVersionOption();
})
.catch(error => {
console.error('Error:', error);
});
}


const jakartaEEVersionSelect = document.getElementById('jakartaEEVersion');
const javaVersionSelect = document.getElementById('javaVersion');
const webProfileRadioButton = document.getElementById('web');
const coreProfileRadioButton = document.getElementById('core');

// Attach an event listener to the jakartaEEVersion select element
jakartaEEVersionSelect.addEventListener('change', function (event) {

const selectedValue = event.target.value;
const selectedVersion = parseFloat(selectedValue);

// Call the function to populate the Payara version dropdown with the selected Jakarta EE version
populatePayaraVersionsDropdown(selectedValue);

// Disable the Core Profile radio button for versions below 10
if (selectedVersion < 10) {
if (coreProfileRadioButton.checked) {
webProfileRadioButton.checked = true;
}
coreProfileRadioButton.disabled = true;
coreProfileRadioButton.checked = false;
} else {
coreProfileRadioButton.disabled = false;
}
});

// Attach an event listener to the payaraVersion select element
payaraVersionSelect.addEventListener('change', function (event) {
listJavaVersionOption();
});

// List Java Version options based on the selected Jakarta EE Version and Payara Version
function listJavaVersionOption() {
const jakartaEEVersion = jakartaEEVersionSelect.value;
const payaraVersion = payaraVersionSelect.value;

// Get the "Java Version" options select element
const javaVersionOptions = javaVersionSelect.querySelectorAll('option');
// Clear existing options
javaVersionOptions.forEach(option => {
option.remove();
});

// Add options based on the selected Jakarta EE Version
if (selectedValue === '8') {
if (jakartaEEVersion === '8') {
addJavaVersionOption('11', 'Java SE 11');
addJavaVersionOption('8', 'Java SE 8');
} else {
if (compareVersion(payaraVersion, '6.2023.11') > 0) {
// Payara version is greater than '6.2023.11'
addJavaVersionOption('21', 'Java SE 21');
}
addJavaVersionOption('17', 'Java SE 17');
addJavaVersionOption('11', 'Java SE 11');
}
}

// Disable the Core Profile radio button for versions below 10
if (selectedVersion < 10) {
if(coreProfileRadioButton.checked) {
webProfileRadioButton.checked = true;
// Function to compare two version strings
function compareVersion(version1, version2) {
const v1 = version1.split('.').map(Number);
const v2 = version2.split('.').map(Number);

for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
const num1 = v1[i] || 0;
const num2 = v2[i] || 0;

if (num1 !== num2) {
return num1 - num2;
}
coreProfileRadioButton.disabled = true;
coreProfileRadioButton.checked = false;
} else {
coreProfileRadioButton.disabled = false;
}
});

return 0;
}

// Function to add an option to the "Java Version" select element
function addJavaVersionOption(value, text) {
Expand Down Expand Up @@ -305,7 +338,7 @@ const fileRealmCheckbox = document.getElementById('formAuthFileRealm');
const databaseCheckbox = document.getElementById('formAuthDB');
const ldapCheckbox = document.getElementById('formAuthLDAP');

coreRadioButton.addEventListener('change', function(event) {
coreRadioButton.addEventListener('change', function (event) {
if (event.target.checked) {
// Disable Form Authentication checkboxes for the Core Profile
fileRealmCheckbox.disabled = true;
Expand Down

0 comments on commit eec0ad2

Please sign in to comment.