diff --git a/nucleus/admin/launcher/pom.xml b/nucleus/admin/launcher/pom.xml index d82b92b4631..c892a9c221f 100644 --- a/nucleus/admin/launcher/pom.xml +++ b/nucleus/admin/launcher/pom.xml @@ -39,7 +39,6 @@ only if the new code is made subject to such option by the copyright holder. - Portions Copyright [2018] [Payara Foundation and/or its affiliates] --> @@ -73,12 +72,7 @@ org.glassfish.main.common common-util ${project.version} - - - org.glassfish.main.core - glassfish - ${project.version} - + org.glassfish.main.core logging diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java index ce248b98a13..c5059097ad5 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java @@ -36,52 +36,31 @@ * and therefore, elected the GPL Version 2 license, then the option applies * only if the new code is made subject to such option by the copyright * holder. - * - * Portions Copyright [2016-2018] [Payara Foundation and/or its affiliates] */ +// Portions Copyright [2016-2018] [Payara Foundation and/or its affiliates] package com.sun.enterprise.admin.launcher; -import static com.sun.enterprise.admin.launcher.GFLauncherConstants.DEFAULT_LOGFILE; -import static com.sun.enterprise.admin.launcher.GFLauncherConstants.FLASHLIGHT_AGENT_NAME; -import static com.sun.enterprise.admin.launcher.GFLauncherConstants.LIBMON_NAME; -import static com.sun.enterprise.admin.launcher.GFLauncherConstants.NEWLINE; -import static com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY; -import static com.sun.enterprise.util.SystemPropertyConstants.INSTANCE_ROOT_PROPERTY; -import static com.sun.enterprise.util.SystemPropertyConstants.JAVA_ROOT_PROPERTY; -import static fish.payara.admin.launcher.PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY; -import static fish.payara.admin.launcher.PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE; -import static fish.payara.admin.launcher.PayaraDefaultJvmOptions.GRIZZLY_NPN_JAR_LOCATION; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.io.*; +import java.util.*; import java.util.logging.Level; -import java.util.stream.Collectors; - import com.sun.enterprise.universal.collections.CollectionUtils; -import com.sun.enterprise.universal.glassfish.ASenvPropertyReader; import com.sun.enterprise.universal.glassfish.GFLauncherUtils; import com.sun.enterprise.universal.glassfish.TokenResolver; import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.io.SmartFile; import com.sun.enterprise.universal.process.ProcessStreamDrainer; -import com.sun.enterprise.universal.xml.MiniXmlParser; import com.sun.enterprise.universal.xml.MiniXmlParserException; -import com.sun.enterprise.util.JDK; import com.sun.enterprise.util.OS; import com.sun.enterprise.util.SystemPropertyConstants; import com.sun.enterprise.util.io.FileUtils; +import com.sun.enterprise.universal.glassfish.ASenvPropertyReader; +import com.sun.enterprise.universal.xml.MiniXmlParser; +import static com.sun.enterprise.util.SystemPropertyConstants.*; +import static com.sun.enterprise.admin.launcher.GFLauncherConstants.*; +import com.sun.enterprise.util.JDK; +import fish.payara.admin.launcher.PayaraDefaultJvmOptions; +import java.util.stream.Collectors; /** * This is the main Launcher class designed for external and internal usage. @@ -907,21 +886,14 @@ private void setupProfilerAndJvmOptions(MiniXmlParser parser) throws MiniXmlPars } private void addDefaultJvmOptions() { - if (!jvmOptions.getCombinedMap().containsKey(GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY)) { - jvmOptions.sysProps.put(GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY, - GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE); + if (!jvmOptions.getCombinedMap().containsKey(PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY)) { + jvmOptions.sysProps.put(PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY, + PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE); // Log that we've made the change GFLauncherLogger.fine(GFLauncherLogger.DEFAULT_JVM_OPTION, - GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY, - GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE); - } - - // Attempt to load the Grizzly NPN jar if it's needed - if (GRIZZLY_NPN_JAR_LOCATION != null && !jvmOptions.getCombinedMap().containsKey(GRIZZLY_NPN_JAR_LOCATION)) { - jvmOptions.xProps.put(GRIZZLY_NPN_JAR_LOCATION, null); - - GFLauncherLogger.fine(GFLauncherLogger.DEFAULT_JVM_OPTION, GRIZZLY_NPN_JAR_LOCATION, null); + PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY, + PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE); } } diff --git a/nucleus/admin/launcher/src/main/java/fish/payara/admin/launcher/PayaraDefaultJvmOptions.java b/nucleus/admin/launcher/src/main/java/fish/payara/admin/launcher/PayaraDefaultJvmOptions.java index 69b3ee01182..6281ad00cda 100644 --- a/nucleus/admin/launcher/src/main/java/fish/payara/admin/launcher/PayaraDefaultJvmOptions.java +++ b/nucleus/admin/launcher/src/main/java/fish/payara/admin/launcher/PayaraDefaultJvmOptions.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2018] Payara Foundation and/or its affiliates. All rights reserved. + * Copyright (c) [2016-2017] Payara Foundation and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -39,77 +39,11 @@ */ package fish.payara.admin.launcher; -import com.sun.enterprise.glassfish.bootstrap.MainHelper; - /** * * @author Andrew Pielage */ public class PayaraDefaultJvmOptions { - - public static final String GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY = "org.glassfish.grizzly.DEFAULT_MEMORY_MANAGER"; - public static final String GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE = "org.glassfish.grizzly.memory.HeapMemoryManager"; - - private static String LATEST_NPN_JAR_VERSION = "1.8.1"; - private static String GRIZZLY_NPN_JAR_LOCATION_BASE = "bootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap"; - /** - * The location of the NPN Jar to load to the boot classpath. If null, none is - * required. - */ - public static final String GRIZZLY_NPN_JAR_LOCATION; - - // Configure the Grizzly NPN Jar version, and from that find the location. - static { - String npnVersion = null; - String jarLocation = null; - - try { - // For Java 8, configure the ALPN jar. Other versions of Java don't require this - if (MainHelper.getMajorJdkVersion() == 1 && MainHelper.getMinorJdkVersion() == 8) { - npnVersion = getNpnVersionFromJavaVersion(); - jarLocation = GRIZZLY_NPN_JAR_LOCATION_BASE - + ((npnVersion == null) ? "" : "-" + npnVersion) - + ".jar"; - } - } catch (Throwable t) { - // Any exceptions will also cause the NPN jar to be set to null - jarLocation = null; - } finally { - GRIZZLY_NPN_JAR_LOCATION = jarLocation; - } - } - - /** - * Finds the NPN jar version that corresponds to the current Java version. - * - * @return the correct NPN jar version, or null if none is recognised. If the - * Java version is unrecognised, the latest NPN jar version will be - * returned. - */ - private static String getNpnVersionFromJavaVersion() { - final String javaVersion = System.getProperty("java.version"); - String npnVersion = null; - - // If the Java version is in a recognised format - if (javaVersion != null && javaVersion.matches("1.8.0_[0-9]{2,3}.*")) { - // Remove all letters, and parse the version to an integer - final Integer patchVersion = Integer.parseInt(javaVersion.split("_")[1].replaceAll("[^0-9]", "")); - - if (patchVersion >= 191) { - npnVersion = LATEST_NPN_JAR_VERSION; - } else if (patchVersion >= 161) { - npnVersion = "1.8"; - } else if (patchVersion >= 121) { - npnVersion = "1.7"; - } else if (patchVersion >= 72) { - npnVersion = "1.6"; - } - } else { - // The java version is unrecognisable, but is Java 8 - // In this case, assume the most recent NPN version - npnVersion = LATEST_NPN_JAR_VERSION; - } - - return npnVersion; - } + public static final String GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY="org.glassfish.grizzly.DEFAULT_MEMORY_MANAGER"; + public static final String GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE="org.glassfish.grizzly.memory.HeapMemoryManager"; } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/MainHelper.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/MainHelper.java index 5813d206cce..bb55ec7749e 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/MainHelper.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/MainHelper.java @@ -36,9 +36,8 @@ * and therefore, elected the GPL Version 2 license, then the option applies * only if the new code is made subject to such option by the copyright * holder. - * - * Portions Copyright [2017-2018] [Payara Foundation and/or its affiliates] */ +// Portions Copyright [2017] [Payara Foundation and/or its affiliates] package com.sun.enterprise.glassfish.bootstrap; import com.sun.enterprise.module.bootstrap.ArgumentManager; @@ -81,7 +80,7 @@ static void checkJdkVersion() { } } - public static int getMajorJdkVersion() { + private static int getMajorJdkVersion() { String jv = System.getProperty("java.version"); String[] split = jv.split("[\\._\\-]+"); if (split.length > 0) { @@ -90,7 +89,7 @@ public static int getMajorJdkVersion() { return -1; } - public static int getMinorJdkVersion() { + private static int getMinorJdkVersion() { // this is a subset of the code in com.sun.enterprise.util.JDK // this module has no dependencies on util code so it was dragged in here.