diff --git a/CHANGELOG.md b/CHANGELOG.md index 63cc0d0e..d2ec4508 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v.1.1.0: +* Enhance : Add support for Payara 5.184 and 5.191 + ## v.1.0.2: * Enhance : Improve systemd restarting on failure * Enhance : Wait for Glassfish admin to be ready before adding a library diff --git a/libraries/asadmin.rb b/libraries/asadmin.rb index d6c10666..aba14ef9 100644 --- a/libraries/asadmin.rb +++ b/libraries/asadmin.rb @@ -32,6 +32,38 @@ def escape_property(string) string.to_s.gsub(/([#{Regexp.escape('\/,=:.!$%^&*|{}[]"`~;')}])/) { |match| "\\#{match}" } end + # asadmin (and REST API) returns JDK version restrictions for JVM options in different format than it requires as input + # This function converts between the return-format and input-format (or optionally without any version) + # + # For example: + # From: "-Xbootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap-1.6.jar --> JDK versions: min(1.8.0), max(1.8.0.120) (Inactive on this JDK)" + # To: "[1.8.0|1.8.0u120]-Xbootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap-1.6.jar" + # + def transform_jvm_options(options, withoutversions = false) + options.map do |line| + min = '' + max = '' + unless withoutversions + capture = line.match(/min\(([\d\.]+)\)/) + min = capture.captures.first unless capture.nil? + + capture = line.match(/max\(([\d\.]+)\)/) + max = capture.captures.first unless capture.nil? + + min = min.gsub(/(\d+)\.(\d+)\.(\d+)\.(\d+)/, '\1.\2.\3u\4') + max = max.gsub(/(\d+)\.(\d+)\.(\d+)\.(\d+)/, '\1.\2.\3u\4') + end + + base = line.gsub(/ --> JDK versions: [A-Za-z\(\d\.\), ]+/, '') + + if min != '' || max != '' + "[#{min}|#{max}]#{base}" + else + base + end + end + end + def self.pipe_filter(node, pattern, regexp: true, line: false) case node['os'] when 'linux' diff --git a/metadata.rb b/metadata.rb index b0d11c05..093da8aa 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache-2.0' description 'Installs/Configures GlassFish Application Server' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '1.0.2' +version '1.1.0' chef_version '>= 13.0' if respond_to?(:chef_version) diff --git a/providers/jvm_options.rb b/providers/jvm_options.rb index d3b35e7f..0e76c77c 100644 --- a/providers/jvm_options.rb +++ b/providers/jvm_options.rb @@ -78,14 +78,15 @@ def service_name existing = output.split("\n") if node.linux? existing = output.split("\r\n") if node.windows? - existing_option_string = encode_options(existing) + existing_option_string = encode_options(transform_jvm_options(existing)) new_option_string = encode_options(new_resource.options) if existing_option_string != new_option_string + existing_option_string = encode_options(transform_jvm_options(existing, true)) execute "asadmin_delete-jvm-options #{new_resource.name}" do delete_command = [] delete_command << 'delete-jvm-options' - delete_command << existing_option_string + delete_command << existing_option_string # This needs to be sent without the JDK version number restrictions delete_command << asadmin_target_flag timeout node['glassfish']['asadmin']['timeout'] + 5 diff --git a/resources/domain.rb b/resources/domain.rb index 5a3b9725..256045f0 100644 --- a/resources/domain.rb +++ b/resources/domain.rb @@ -172,6 +172,20 @@ def security_jvm_options ] end +def grizzly_options + if node['glassfish']['variant'] == 'payara' && node['glassfish']['version'].split('.')[0].to_i >= 5 && node['glassfish']['version'].split('.')[1].to_i >= 184 + [ + '[1.8.0|1.8.0u120]-Xbootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap-1.6.jar', + '[1.8.0u121|1.8.0u160]-Xbootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap-1.7.jar', + '[1.8.0u161|1.8.0u190]-Xbootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap-1.8.jar', + '[1.8.0u191|1.8.0u500]-Xbootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap-1.8.1.jar', + '[9|]-Xbootclasspath/a:${com.sun.aas.installRoot}/lib/grizzly-npn-api.jar', + ] + else + [] + end +end + def development_jvm_options [ '-Djdbc.drivers=org.apache.derby.jdbc.ClientDriver', @@ -179,7 +193,8 @@ def development_jvm_options end def default_jvm_options - runtime_jvm_options + + grizzly_options + + runtime_jvm_options + development_jvm_options + common_jvm_options + installation_jvm_options +