01: /*
02: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.monitoring;
06:
07: import com.sun.portal.log.common.PortalLogger;
08:
09: import java.util.Locale;
10: import java.util.ResourceBundle;
11: import java.util.MissingResourceException;
12: import java.util.logging.Level;
13: import java.util.logging.LogRecord;
14: import java.util.logging.Logger;
15:
16: public class ResourceBundleHelper {
17: private static final Logger logger = PortalLogger
18: .getLogger(ResourceBundleHelper.class);
19:
20: private static LogRecord getLogRecord(Level level, String message,
21: Object[] parameters, Throwable t) {
22: LogRecord result = new LogRecord(level, message);
23: result.setLoggerName(logger.getName());
24: result.setParameters(parameters);
25: result.setThrown(t);
26: return result;
27: }
28:
29: public static ResourceBundle getResourceBundle(
30: ResourceBundleWrapper resourceBundleWrapper) {
31: ResourceBundle result = null;
32:
33: String resourceBundleBaseName = resourceBundleWrapper
34: .getResourceBundleBaseName();
35: if (resourceBundleBaseName != null) {
36: if (resourceBundleBaseName.length() != 0) {
37: Locale locale = resourceBundleWrapper.getLocale();
38: try {
39: if (locale != null) {
40: result = ResourceBundle.getBundle(
41: resourceBundleBaseName, locale);
42: } else {
43: result = ResourceBundle
44: .getBundle(resourceBundleBaseName);
45: }
46: } catch (MissingResourceException e) {
47: if (logger.isLoggable(Level.SEVERE)) {
48: logger.log(getLogRecord(Level.SEVERE,
49: "PSMN_CSPM0001", new Object[] { e
50: .getLocalizedMessage() }, e));
51: }
52: }
53: }
54: }
55:
56: return result;
57: }
58: }
|