This is an automated email from the ASF dual-hosted git repository.

jgauravgupta pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 08fdb47  NETBEANS-3547 Support vendor specific JVM options in Payara 
Server
     new d441f95  Merge pull request #1691 from MeroRai/PAYARA-4228
08fdb47 is described below

commit 08fdb473ce3bc92b8c51f9dac9ee781e9cfbb582
Author: Mero Rai <susan.ra...@gmail.com>
AuthorDate: Thu Nov 28 21:00:25 2019 +0530

    NETBEANS-3547 Support vendor specific JVM options in Payara Server
    
    Signed-off-by: Gaurav Gupta <gaurav.gupta...@gmail.com>
---
 .../modules/payara/tooling/data/JDKVersion.java    | 53 ++++++++++++++++------
 .../modules/payara/tooling/server/ServerTasks.java |  4 +-
 .../tooling/server/parser/JvmConfigReader.java     | 12 ++++-
 3 files changed, 53 insertions(+), 16 deletions(-)

diff --git 
a/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/data/JDKVersion.java
 
b/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/data/JDKVersion.java
index ad0ed7a..873cbcd 100644
--- 
a/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/data/JDKVersion.java
+++ 
b/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/data/JDKVersion.java
@@ -41,6 +41,11 @@ public final class JDKVersion {
      * Update version number.
      */
     private final Optional<Short> update;
+    
+    /**
+     * JDK vendor
+     */
+    private final Optional<String> vendor;
 
     public static JDKVersion IDE_JDK_VERSION;
 
@@ -54,19 +59,27 @@ public final class JDKVersion {
 
     private static final Short DEFAULT_VALUE = 0;
 
-    private JDKVersion(String string) {
-        String[] split = string.split(VERSION_SPLITTER);
+    private JDKVersion(String version) {
+        if (version.contains("-")) { // NOI18N
+            String[] versionSplit = version.split("-"); // NOI18N
+            vendor = versionSplit.length > 0 ? Optional.of(versionSplit[0]) : 
Optional.empty();
+            version = versionSplit.length > 1 ? versionSplit[1] : ""; // NOI18N
+        } else {
+            vendor = Optional.empty();
+        }
+        String[] split = version.split(VERSION_SPLITTER);
         major = split.length > 0 ? Short.parseShort(split[0]) : 0;
         minor = split.length > 1 ? Optional.of(Short.parseShort(split[1])) : 
Optional.empty();
         subminor = split.length > 2 ? Optional.of(Short.parseShort(split[2])) 
: Optional.empty();
         update = split.length > 3 ? Optional.of(Short.parseShort(split[3])) : 
Optional.empty();
     }
 
-    private JDKVersion(Short major, Short minor, Short subminor, Short update) 
{
+    private JDKVersion(Short major, Short minor, Short subminor, Short update, 
String vendor) {
         this.major = major;
         this.minor = Optional.of(minor);
         this.subminor = Optional.of(subminor);
         this.update = Optional.of(update);
+        this.vendor = Optional.of(vendor);
     }
 
     /**
@@ -104,6 +117,15 @@ public final class JDKVersion {
     public Optional<Short> getUpdate() {
         return update;
     }
+    
+     /**
+     * Get JDK Vendor.
+     *
+     * @return JDK vendor.
+     */
+    public Optional<String> getVendor() {
+        return vendor;
+    }
 
     public boolean gt(JDKVersion version) {
         if (major > version.getMajor()) {
@@ -235,11 +257,15 @@ public final class JDKVersion {
         return IDE_JDK_VERSION;
     }
 
-    public static boolean isCorrectJDK(JDKVersion jdkVersion, 
Optional<JDKVersion> minVersion, Optional<JDKVersion> maxVersion) {
+    public static boolean isCorrectJDK(JDKVersion jdkVersion, Optional<String> 
vendor, Optional<JDKVersion> minVersion, Optional<JDKVersion> maxVersion) {
         boolean correctJDK = true;
-        if (minVersion.isPresent()) {
-            correctJDK = jdkVersion.ge(minVersion.get());
+        
+        if (vendor.isPresent()) {             
+            correctJDK = jdkVersion.vendor.get().contains(vendor.get());
         }
+        if (correctJDK && minVersion.isPresent()) {
+            correctJDK = jdkVersion.ge(minVersion.get());
+        }       
         if (correctJDK && maxVersion.isPresent()) {
             correctJDK = jdkVersion.le(maxVersion.get());
         }
@@ -247,7 +273,7 @@ public final class JDKVersion {
     }
 
     public static boolean isCorrectJDK(Optional<JDKVersion> minVersion, 
Optional<JDKVersion> maxVersion) {
-        return isCorrectJDK(IDE_JDK_VERSION, minVersion, maxVersion);
+        return isCorrectJDK(IDE_JDK_VERSION, Optional.empty(), minVersion, 
maxVersion);
     }
 
     static {
@@ -259,6 +285,7 @@ public final class JDKVersion {
         short minor = 0;
         short subminor = 0;
         short update = 0;
+        String vendor = System.getProperty("java.vendor"); // NOI18N
         try {
             /*
             In JEP 223 java.specification.version will be a single number 
versioning , not a dotted versioning . 
@@ -272,14 +299,14 @@ public final class JDKVersion {
                 java.specification.version  11
                 java.version                11.0.3
              */
-            String javaSpecVersion = 
System.getProperty("java.specification.version");
-            String javaVersion = System.getProperty("java.version");
-            String[] javaSpecVersionSplit = javaSpecVersion.split("\\.");
+            String javaSpecVersion = 
System.getProperty("java.specification.version"); // NOI18N
+            String javaVersion = System.getProperty("java.version"); // NOI18N
+            String[] javaSpecVersionSplit = javaSpecVersion.split("\\."); // 
NOI18N
             if (javaSpecVersionSplit.length == 1) {
                 // Handle Early Access build. e.g: 13-ea
-                String[] javaVersionSplit = javaVersion.split("-");
+                String[] javaVersionSplit = javaVersion.split("-"); // NOI18N
                 String javaVersionCategory = javaVersionSplit[0];
-                String[] split = javaVersionCategory.split("[\\.]+");
+                String[] split = javaVersionCategory.split("[\\.]+"); // NOI18N
 
                 if (split.length > 0) {
                     if (split.length > 0) {
@@ -323,6 +350,6 @@ public final class JDKVersion {
             // ignore
         }
 
-        IDE_JDK_VERSION = new JDKVersion(major, minor, subminor, update);
+        IDE_JDK_VERSION = new JDKVersion(major, minor, subminor, update, 
vendor);
     }
 }
diff --git 
a/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/server/ServerTasks.java
 
b/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/server/ServerTasks.java
index 6103efb..c8130e5 100644
--- 
a/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/server/ServerTasks.java
+++ 
b/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/server/ServerTasks.java
@@ -164,11 +164,11 @@ public class ServerTasks {
             }
         }
 
-        JDKVersion javaVersion = args.getJavaVersion() != null ? 
args.getJavaVersion() : IDE_JDK_VERSION;
+        JDKVersion javaVersion = IDE_JDK_VERSION != null ? IDE_JDK_VERSION : 
args.getJavaVersion() ;
         List<String> optList
                 = jvmConfigReader.getJvmOptions()
                         .stream()
-                        .filter(fullOption -> 
JDKVersion.isCorrectJDK(javaVersion, fullOption.minVersion, 
fullOption.maxVersion))
+                        .filter(fullOption -> 
JDKVersion.isCorrectJDK(javaVersion, fullOption.vendor, fullOption.minVersion, 
fullOption.maxVersion))
                         .map(fullOption -> fullOption.option)
                         .collect(toList());
 
diff --git 
a/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/server/parser/JvmConfigReader.java
 
b/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/server/parser/JvmConfigReader.java
index 6c92314..c994b4b 100644
--- 
a/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/server/parser/JvmConfigReader.java
+++ 
b/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/server/parser/JvmConfigReader.java
@@ -201,6 +201,7 @@ public class JvmConfigReader extends NodeListener 
implements XMLReader {
     public static class JvmOption {
 
         public final String option;
+        public final Optional<String> vendor;
         public final Optional<JDKVersion> minVersion;
         public final Optional<JDKVersion> maxVersion;
 
@@ -217,11 +218,19 @@ public class JvmConfigReader extends NodeListener 
implements XMLReader {
         public JvmOption(String option) {
             Matcher matcher = PATTERN.matcher(option);
             if (matcher.matches()) {
-                this.minVersion = 
Optional.ofNullable(JDKVersion.toValue(matcher.group(1)));
+                if (matcher.group(1).contains("-")) { // NOI18N
+                    String[] parts = matcher.group(1).split("-"); // NOI18N
+                    this.vendor = Optional.ofNullable(parts[0]);
+                    this.minVersion = 
Optional.ofNullable(JDKVersion.toValue(parts[1]));
+                } else {
+                    this.vendor = Optional.empty();
+                    this.minVersion = 
Optional.ofNullable(JDKVersion.toValue(matcher.group(1)));
+                }
                 this.maxVersion = 
Optional.ofNullable(JDKVersion.toValue(matcher.group(2)));
                 this.option = matcher.group(3);
             } else {
                 this.option = option;
+                this.vendor = Optional.empty();
                 this.minVersion = Optional.empty();
                 this.maxVersion = Optional.empty();
             }
@@ -229,6 +238,7 @@ public class JvmConfigReader extends NodeListener 
implements XMLReader {
 
         public JvmOption(String option, String minVersion, String maxVersion) {
             this.option = option;
+            this.vendor = Optional.empty();
             this.minVersion = 
Optional.ofNullable(JDKVersion.toValue(minVersion));
             this.maxVersion = 
Optional.ofNullable(JDKVersion.toValue(maxVersion));
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to