LoggingResourceBundle.java :  » Portal » Open-Portal » com » sun » portal » admin » console » logging » data » Java Open Source

Java Open Source » Portal » Open Portal 
Open Portal » com » sun » portal » admin » console » logging » data » LoggingResourceBundle.java
/**
 * $Id: LoggingResourceBundle.java,v 1.4 2005/12/13 07:47:32 sm140826 Exp $
 * Copyright 2005 Sun Microsystems, Inc. All
 * rights reserved. Use of this product is subject
 * to license terms. Federal Acquisitions:
 * Commercial Software -- Government Users
 * Subject to Standard License Terms and
 * Conditions.
 *
 * Sun, Sun Microsystems, the Sun logo, and Sun ONE
 * are trademarks or registered trademarks of Sun Microsystems,
 * Inc. in the United States and other countries.
 */
package com.sun.portal.admin.console.logging.data;

import javax.faces.context.FacesContext;
import java.util.ResourceBundle;
import java.util.Locale;

/**
 *
 */
public class LoggingResourceBundle {

    private static final String LOG_RESOURCE = "logging";
    private static ResourceBundle logResource = ResourceBundle.getBundle(LOG_RESOURCE);

    public static String getProperty(String key) {
        logResource = loadResource(logResource, LOG_RESOURCE);
        String val = null;
        try {
            val = logResource.getString(key);
        } catch (Exception e) {
            //missing resource or null key
            //drop through
        }
        if (val == null)
            return key;
        else
            return val;
    }
    private static ResourceBundle loadResource(ResourceBundle rb, String rbName) {
        FacesContext fc = FacesContext.getCurrentInstance();
        Locale locale = fc.getViewRoot().getLocale();
        return ResourceBundle.getBundle(rbName,locale);
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.