⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 messagemanager.java

📁 intra_mart是日本NDD公司开发的著名企业应用解决方案中间件。集成了J2ee服务器
💻 JAVA
字号:
/*
 * MessageManager.java
 *
 * Created on 2002/02/21, 20:39
 */

package jp.co.intra_mart.framework.system.message;

import java.util.ResourceBundle;

import jp.co.intra_mart.framework.system.property.PropertyManager;

import java.util.MissingResourceException;

import jp.co.intra_mart.framework.system.property.PropertyHandlerException;
import jp.co.intra_mart.framework.system.property.PropertyManagerException;

/**
 * 儊僢僙乕僕傪惂屼偟傑偡丅
 *
 * @author INTRAMART
 * @version 1.0
 */
public class MessageManager {

    /**
     * 儊僢僙乕僕僾儘僷僥傿僴儞僪儔偺僉乕
     */
    public static final String MESSAGE_PROPERTY_HANDLER_KEY = "message";

    /**
     * 儊僢僙乕僕儅僱乕僕儍
     */
    private static MessageManager manager;

    /**
     * 儊僢僙乕僕僾儘僷僥傿僴儞僪儔
     */
    private MessagePropertyHandler handler;

    /**
     * MessageManager傪怴婯偵惗惉偟傑偡丅
     * 偙偺僐儞僗僩儔僋僞偼柧帵揑偵屇傃弌偡偙偲偼偱偒傑偣傫丅
     *
     * @throws MessageManagerException 儊僢僙乕僕儅僱乕僕儍偺庢摼帪偵椺奜偑敪惗
     */
    private MessageManager() throws MessageManagerException {
        PropertyManager propertyManager;

        // 僾儘僷僥傿儅僱乕僕儍偺庢摼
        try {
            propertyManager = PropertyManager.getPropertyManager();
        } catch(PropertyManagerException e) {
            String message = null;
            try {
            } catch (MissingResourceException ex) {
                message = ResourceBundle.getBundle("jp.co.intra_mart.framework.system.message.i18n").getString("MessageManager.FailedToGetPropertyManager");
            }
            throw new MessageManagerException(message, e);
        }

        // 儊僢僙乕僕僾儘僷僥傿僴儞僪儔偺庢摼
        try {
            this.handler = (MessagePropertyHandler)propertyManager.getPropertyHandler(MESSAGE_PROPERTY_HANDLER_KEY);
        } catch(PropertyHandlerException e) {
            String message = null;
            try {
                message = ResourceBundle.getBundle("jp.co.intra_mart.framework.system.message.i18n").getString("MessageManager.FailedToGetMessagePropertyHandler");
            } catch (MissingResourceException ex) {
            }
            throw new MessageManagerException(message + " : " + MESSAGE_PROPERTY_HANDLER_KEY, e);
        }
    }

    /**
     * MessageManager傪庢摼偟傑偡丅
     *
     * @return 儊僢僙乕僕儅僱乕僕儍
     * @throws MessageManagerException 儊僢僙乕僕儅僱乕僕儍偺庢摼帪偵椺奜偑敪惗
     */
    public static synchronized MessageManager getMessageManager() throws MessageManagerException {
        if (manager == null) {
            manager = new MessageManager();
        }

        return manager;
    }

    /**
     * 儊僢僙乕僕僾儘僷僥傿僴儞僪儔傪庢摼偟傑偡丅
     *
     * @return 儊僢僙乕僕僾儘僷僥傿僴儞僪儔
     */
    public MessagePropertyHandler getMessagePropertyHandler() {
        return this.handler;
    }

    /**
     * 僉乕偵奩摉偡傞儊僢僙乕僕傪庢摼偟傑偡丅
     * 僉乕偑null偺応崌丄傑偨偼僉乕偵奩摉偡傞儊僢僙乕僕偑懚嵼偟側偄応崌丄嬻暥帤楍傪曉偟傑偡丅
     *
     * @param key 僉乕
     * @param loginGroup 儘僌僀儞僌儖乕僾
     * @return 儊僢僙乕僕
     * @deprecated intra-mart v5.0偐傜偺儊僢僙乕僕儅僗僞偵偼儘僌僀儞僌儖乕僾偺奣擮偑偁傝傑偣傫丅<BR>
     * 愝掕偝傟偰偄傞{@link jp.co.intra_mart.framework.system.message.MessagePropertyHandler}偵傛偭偰偼丄
     * 僷儔儊乕僞loginGroup偼幚嵺偵偼巊梡偟側偄壜擻惈偑偁傝傑偡丅{@link #getMessage(String)}傪巊梡偟偰偔偩偝偄丅
     */
    public String getMessage(String key, String loginGroup) {
        String result = "";
        if (key != null) {
            result = this.handler.getMessage(key, loginGroup);
        }
        return result;
    }

    /**
     * 僉乕偵奩摉偡傞儊僢僙乕僕傪庢摼偟傑偡丅
     * 僉乕偑null偺応崌丄傑偨偼僉乕偵奩摉偡傞儊僢僙乕僕偑懚嵼偟側偄応崌丄嬻暥帤楍傪曉偟傑偡丅
     *
     * @param key 僉乕
     * @return 儊僢僙乕僕
     */
    public String getMessage(String key) {
        String result = "";
        if (key != null) {
            result = this.handler.getMessage(key);
        }
        return result;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -