01: /**
02: * $Id: LoggingResourceBundle.java,v 1.4 2005/12/13 07:47:32 sm140826 Exp $
03: * Copyright 2005 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.admin.console.logging.data;
14:
15: import javax.faces.context.FacesContext;
16: import java.util.ResourceBundle;
17: import java.util.Locale;
18:
19: /**
20: *
21: */
22: public class LoggingResourceBundle {
23:
24: private static final String LOG_RESOURCE = "logging";
25: private static ResourceBundle logResource = ResourceBundle
26: .getBundle(LOG_RESOURCE);
27:
28: public static String getProperty(String key) {
29: logResource = loadResource(logResource, LOG_RESOURCE);
30: String val = null;
31: try {
32: val = logResource.getString(key);
33: } catch (Exception e) {
34: //missing resource or null key
35: //drop through
36: }
37: if (val == null)
38: return key;
39: else
40: return val;
41: }
42:
43: private static ResourceBundle loadResource(ResourceBundle rb,
44: String rbName) {
45: FacesContext fc = FacesContext.getCurrentInstance();
46: Locale locale = fc.getViewRoot().getLocale();
47: return ResourceBundle.getBundle(rbName, locale);
48: }
49:
50: }
|