Skip to content

Commit

Permalink
Migrate to Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
ravinperera00 committed Jan 8, 2025
1 parent df6c393 commit fc1edf2
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 100 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ To report bugs, request new features, start new discussions, view project boards
## Building from the source
### Setting up the prerequisites
1. Download and install Java SE Development Kit (JDK) version 17. You can install either [OpenJDK](https://adoptopenjdk.net/) or [Oracle JDK](https://www.oracle.com/java/technologies/downloads/).
1. Download and install Java SE Development Kit (JDK) version 21. You can install either [OpenJDK](https://adoptopenjdk.net/) or [Oracle JDK](https://www.oracle.com/java/technologies/downloads/).
> **Note:** Set the JAVA_HOME environment variable to the path name of the directory into which you installed JDK.
Expand Down
32 changes: 16 additions & 16 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
distribution = "2201.10.0"
distribution = "2201.11.0-20241117-133400-a3054b77"
org = "ballerinax"
name = "salesforce"
version = "8.1.0"
Expand All @@ -13,88 +13,88 @@ repository = "https://github.com/ballerina-platform/module-ballerinax-salesforce
[build-options]
observabilityIncluded = true

[platform.java17]
[platform.java21]
graalvmCompatible = true

[[platform.java17.dependency]]
[[platform.java21.dependency]]
path = "../native/build/libs/salesforce-native-8.1.0.jar"
groupId = "io.ballerinax"
artifactId = "salesforce"
version = "8.1.0"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.opencsv"
artifactId = "opencsv"
version = "5.9"
path = "./lib/opencsv-5.9.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.cometd.java"
artifactId = "bayeux-api"
version = "4.0.9"
path = "./lib/bayeux-api-4.0.9.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.cometd.java"
artifactId = "cometd-java-client"
version = "4.0.9"
path = "./lib/cometd-java-client-4.0.9.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.cometd.java"
artifactId = "cometd-java-common"
version = "4.0.9"
path = "./lib/cometd-java-common-4.0.9.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.eclipse.jetty"
artifactId = "jetty-client"
version = "9.4.55.v20240627"
path = "./lib/jetty-client-9.4.55.v20240627.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.eclipse.jetty"
artifactId = "jetty-http"
version = "9.4.55.v20240627"
path = "./lib/jetty-http-9.4.55.v20240627.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.eclipse.jetty"
artifactId = "jetty-io"
version = "9.4.55.v20240627"
path = "./lib/jetty-io-9.4.55.v20240627.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.eclipse.jetty"
artifactId = "jetty-util"
version = "9.4.55.v20240627"
path = "./lib/jetty-util-9.4.55.v20240627.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.eclipse.jetty"
artifactId = "jetty-util-ajax"
version = "9.4.55.v20240627"
path = "./lib/jetty-util-ajax-9.4.55.v20240627.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.json"
artifactId = "json"
version = "20240303"
path = "./lib/json-20240303.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
artifactId = "jackson-databind"
version = "2.13.5"
path = "./lib/jackson-databind-2.13.5.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
artifactId = "jackson-annotations"
version = "2.13.5"
path = "./lib/jackson-annotations-2.13.5.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
artifactId = "jackson-core"
version = "2.13.5"
Expand Down
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.10.0"
distribution-version = "2201.11.0-20241117-133400-a3054b77"

[[package]]
org = "ballerina"
Expand Down
32 changes: 16 additions & 16 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
distribution = "2201.10.0"
distribution = "2201.11.0-20241117-133400-a3054b77"
org = "ballerinax"
name = "salesforce"
version = "@toml.version@"
Expand All @@ -13,88 +13,88 @@ repository = "https://github.com/ballerina-platform/module-ballerinax-salesforce
[build-options]
observabilityIncluded = true

[platform.java17]
[platform.java21]
graalvmCompatible = true

[[platform.java17.dependency]]
[[platform.java21.dependency]]
path = "../native/build/libs/[email protected]@.jar"
groupId = "io.ballerinax"
artifactId = "salesforce"
version = "@project.version@"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.opencsv"
artifactId = "opencsv"
version = "@opencsv.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.cometd.java"
artifactId = "bayeux-api"
version = "@cometd.java.client.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.cometd.java"
artifactId = "cometd-java-client"
version = "@cometd.java.client.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.cometd.java"
artifactId = "cometd-java-common"
version = "@cometd.java.client.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.eclipse.jetty"
artifactId = "jetty-client"
version = "@jetty.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.eclipse.jetty"
artifactId = "jetty-http"
version = "@jetty.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.eclipse.jetty"
artifactId = "jetty-io"
version = "@jetty.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.eclipse.jetty"
artifactId = "jetty-util"
version = "@jetty.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.eclipse.jetty"
artifactId = "jetty-util-ajax"
version = "@jetty.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.json"
artifactId = "json"
version = "@json.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
artifactId = "jackson-databind"
version = "@jackson.databind.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
artifactId = "jackson-annotations"
version = "@jackson.annotations.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
artifactId = "jackson-core"
version = "@jackson.core.version@"
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ group=io.ballerina.lib
version=8.1.1-SNAPSHOT

checkstylePluginVersion=10.12.0
spotbugsPluginVersion=5.0.14
spotbugsPluginVersion=6.0.18
shadowJarPluginVersion=8.1.1
downloadPluginVersion=5.4.0
releasePluginVersion=2.8.0
testngVersion=7.6.1
openCsvVersion=5.9
ballerinaGradlePluginVersion=2.2.3

ballerinaLangVersion=2201.10.0
ballerinaLangVersion=2201.11.0-20241117-133400-a3054b77

jacocoToolVersion=0.8.8
jacksonDatabindVersion=2.13.5
Expand Down
9 changes: 6 additions & 3 deletions native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

sourceCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21

jacoco {
toolVersion = "0.8.10"
Expand All @@ -70,9 +70,12 @@ test {
}

spotbugsMain {
def classLoader = plugins["com.github.spotbugs"].class.classLoader
def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence")
def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort")
effort = SpotBugsEffort.MAX
reportLevel = SpotBugsConfidence.LOW
ignoreFailures = true
effort = "max"
reportLevel = "low"
reportsDir = file("$project.buildDir/reports/spotbugs")
def excludeFile = file("${rootDir}/build-config/spotbugs-exclude.xml")
if (excludeFile.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import io.ballerina.runtime.api.PredefinedTypes;
import io.ballerina.runtime.api.Runtime;
import io.ballerina.runtime.api.async.StrandMetadata;
import io.ballerina.runtime.api.concurrent.StrandMetadata;
import io.ballerina.runtime.api.creators.ValueCreator;
import io.ballerina.runtime.api.types.MethodType;
import io.ballerina.runtime.api.types.ObjectType;
Expand Down Expand Up @@ -95,22 +94,17 @@ public void handleDispatch(Map<String, Object> eventData) {
}

private void executeResourceOnEvent(BMap<BString, Object> eventRecord, String functionName) {
StrandMetadata metaData = new StrandMetadata(ModuleUtils.getModule().getOrg(),
ModuleUtils.getModule().getName(), ModuleUtils.getModule().getMajorVersion(), functionName);
executeResource(functionName, metaData, eventRecord);
executeResource(functionName, eventRecord);
}

private void executeResource(String functionName, StrandMetadata metaData,
BMap<BString, Object> eventRecord) {
private void executeResource(String functionName, BMap<BString, Object> eventRecord) {

ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(service));
if (serviceType.isIsolated() && serviceType.isIsolated(functionName)) {
runtime.invokeMethodAsyncConcurrently(service, functionName, null, metaData, null, null,
PredefinedTypes.TYPE_NULL, eventRecord, true);
} else {
runtime.invokeMethodAsyncSequentially(service, functionName, null, metaData, null, null,
PredefinedTypes.TYPE_NULL, eventRecord, true);
}
Thread.startVirtualThread(() -> {
boolean isIsolated = serviceType.isIsolated() && serviceType.isIsolated(functionName);
runtime.callMethod(service, functionName,
new StrandMetadata(isIsolated, ModuleUtils.getProperties(functionName)), eventRecord);
});
}

/**
Expand Down
12 changes: 12 additions & 0 deletions native/src/main/java/io/ballerinax/salesforce/ModuleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.Module;

import java.util.HashMap;
import java.util.Map;

/**
* This class will hold module related utility functions.
*/
Expand All @@ -42,4 +45,13 @@ public static void setModule(Environment env) {
public static Module getModule() {
return salesforceModule;
}

public static Map<String, Object> getProperties(String resourceName) {
Map<String, Object> properties = new HashMap<>();
properties.put("moduleOrg", getModule().getOrg());
properties.put("moduleName", getModule().getName());
properties.put("moduleVersion", getModule().getMajorVersion());
properties.put("parentFunctionName", resourceName);
return properties;
}
}
Loading

0 comments on commit fc1edf2

Please sign in to comment.