From a0f9aa92626bb003d1a075869984b249af36d9af Mon Sep 17 00:00:00 2001 From: Rhys Williams <170514543+Viii3@users.noreply.github.com> Date: Wed, 21 Aug 2024 12:28:28 +0100 Subject: [PATCH 1/2] Add LogStrings.properties for EJB. --- .../container/ejb/LogStrings.properties | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 appserver/ejb/ejb-container/src/main/resources/com/sun/logging/enterprise/system/container/ejb/LogStrings.properties diff --git a/appserver/ejb/ejb-container/src/main/resources/com/sun/logging/enterprise/system/container/ejb/LogStrings.properties b/appserver/ejb/ejb-container/src/main/resources/com/sun/logging/enterprise/system/container/ejb/LogStrings.properties new file mode 100644 index 00000000000..a624a81c934 --- /dev/null +++ b/appserver/ejb/ejb-container/src/main/resources/com/sun/logging/enterprise/system/container/ejb/LogStrings.properties @@ -0,0 +1,38 @@ +# Copyright (c) 2024 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 +# and Distribution License("CDDL") (collectively, the "License"). You +# may not use this file except in compliance with the License. You can +# obtain a copy of the License at +# https://github.com/payara/Payara/blob/main/LICENSE.txt +# See the License for the specific +# language governing permissions and limitations under the License. +# +# When distributing the software, include this License Header Notice in each +# file and include the License file at glassfish/legal/LICENSE.txt. +# +# GPL Classpath Exception: +# The Payara Foundation designates this particular file as subject to the "Classpath" +# exception as provided by the Payara Foundation in the GPL Version 2 section of the License +# file that accompanied this code. +# +# Modifications: +# If applicable, add the following below the License Header, with the fields +# enclosed by brackets [] replaced by your own identifying information: +# "Portions Copyright [year] [name of copyright owner]" +# +# Contributor(s): +# If you wish your version of this file to be governed by only the CDDL or +# only the GPL Version 2, indicate your decision by adding "[Contributor] +# elects to include this software in this distribution under the [CDDL or GPL +# Version 2] license." If you don't indicate a single choice of license, a +# recipient has the option to distribute your version of this file under +# either the CDDL, the GPL Version 2 or to extend the choice of license to +# its licensees as provided above. However, if you add GPL Version 2 code +# 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. +# + +# No log strings to show. \ No newline at end of file From f5a7bb79a44cdb68c02ad6c7aed41da26525bc6a Mon Sep 17 00:00:00 2001 From: Rhys Williams <170514543+Viii3@users.noreply.github.com> Date: Tue, 27 Aug 2024 14:02:58 +0100 Subject: [PATCH 2/2] FISH-9456: Allow LogDomains to use LogMessages. --- .../container/ejb/LogStrings.properties | 38 ------------------- .../main/java/com/sun/logging/LogDomains.java | 27 ++++++++----- 2 files changed, 18 insertions(+), 47 deletions(-) delete mode 100644 appserver/ejb/ejb-container/src/main/resources/com/sun/logging/enterprise/system/container/ejb/LogStrings.properties diff --git a/appserver/ejb/ejb-container/src/main/resources/com/sun/logging/enterprise/system/container/ejb/LogStrings.properties b/appserver/ejb/ejb-container/src/main/resources/com/sun/logging/enterprise/system/container/ejb/LogStrings.properties deleted file mode 100644 index a624a81c934..00000000000 --- a/appserver/ejb/ejb-container/src/main/resources/com/sun/logging/enterprise/system/container/ejb/LogStrings.properties +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) 2024 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 -# and Distribution License("CDDL") (collectively, the "License"). You -# may not use this file except in compliance with the License. You can -# obtain a copy of the License at -# https://github.com/payara/Payara/blob/main/LICENSE.txt -# See the License for the specific -# language governing permissions and limitations under the License. -# -# When distributing the software, include this License Header Notice in each -# file and include the License file at glassfish/legal/LICENSE.txt. -# -# GPL Classpath Exception: -# The Payara Foundation designates this particular file as subject to the "Classpath" -# exception as provided by the Payara Foundation in the GPL Version 2 section of the License -# file that accompanied this code. -# -# Modifications: -# If applicable, add the following below the License Header, with the fields -# enclosed by brackets [] replaced by your own identifying information: -# "Portions Copyright [year] [name of copyright owner]" -# -# Contributor(s): -# If you wish your version of this file to be governed by only the CDDL or -# only the GPL Version 2, indicate your decision by adding "[Contributor] -# elects to include this software in this distribution under the [CDDL or GPL -# Version 2] license." If you don't indicate a single choice of license, a -# recipient has the option to distribute your version of this file under -# either the CDDL, the GPL Version 2 or to extend the choice of license to -# its licensees as provided above. However, if you add GPL Version 2 code -# 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. -# - -# No log strings to show. \ No newline at end of file diff --git a/nucleus/common/common-util/src/main/java/com/sun/logging/LogDomains.java b/nucleus/common/common-util/src/main/java/com/sun/logging/LogDomains.java index 3b881122faf..6dab0489ded 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/logging/LogDomains.java +++ b/nucleus/common/common-util/src/main/java/com/sun/logging/LogDomains.java @@ -78,6 +78,8 @@ private LogDomains() {} */ public static final String RESOURCE_BUNDLE = "LogStrings"; + public static final String RESOURCE_BUNDLE_MESSAGES = "LogMessages"; + /** * Field */ @@ -363,26 +365,33 @@ public static Logger getLogger(final Class clazz, final String namePrefix, final return logManager.getLogger(cLogger.getName()); } - private static ResourceBundle getResourceBundle(final String name, final Class clazz, - final ClassLoader resourceBundleLoader) { - final ResourceBundle classBundle = findResourceBundle(name, clazz, resourceBundleLoader); + private static ResourceBundle getResourceBundle (final String name, final Class clazz, final ClassLoader resourceBundleLoader) { + ResourceBundle classBundle = findResourceBundle(name, clazz, resourceBundleLoader); + if (classBundle == null) { // EJB uses LogMessages instead of LogStrings, check for this file if necessary. + classBundle = findResourceBundle(name, clazz, resourceBundleLoader, RESOURCE_BUNDLE_MESSAGES); + } + if (classBundle != null) { return classBundle; } + Logger.getAnonymousLogger().log(Level.INFO, "Cannot find the resource bundle for the name {0} for {1} using {2}", new Object[]{name, clazz, resourceBundleLoader}); return null; } - private static ResourceBundle findResourceBundle(final String name, final Class clazz, - final ClassLoader classLoader) { - final ResourceBundle packageRootBundle = tryTofindResourceBundle(name, classLoader); + private static ResourceBundle findResourceBundle (final String name, final Class clazz, final ClassLoader classLoader) { + return findResourceBundle(name, clazz, classLoader, LogDomains.RESOURCE_BUNDLE); + } + + private static ResourceBundle findResourceBundle (final String name, final Class clazz, final ClassLoader classLoader, final String fileSuffix) { + final ResourceBundle packageRootBundle = tryToFindResourceBundle(name, classLoader, fileSuffix); if (packageRootBundle != null) { return packageRootBundle; } // not found. Ok, let's try to go through the class's package tree final StringBuilder rbPackage = new StringBuilder(clazz.getPackage().getName()); while (true) { - final ResourceBundle subPkgBundle = tryTofindResourceBundle(rbPackage.toString(), classLoader); + final ResourceBundle subPkgBundle = tryToFindResourceBundle(rbPackage.toString(), classLoader, fileSuffix); if (subPkgBundle != null) { return subPkgBundle; } @@ -402,9 +411,9 @@ private static String getLoggerName(Class clazz, String logDomainsConstantName) return loggerName; } - private static ResourceBundle tryTofindResourceBundle(final String name, final ClassLoader classLoader) { + private static ResourceBundle tryToFindResourceBundle (final String name, final ClassLoader classLoader, final String fileSuffix) { try { - return ResourceBundle.getBundle(name + "." + LogDomains.RESOURCE_BUNDLE, Locale.getDefault(), classLoader); + return ResourceBundle.getBundle(name + "." + fileSuffix, Locale.getDefault(), classLoader); } catch (MissingResourceException e) { return null; }