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

📄 defaultsessionpropertyhandler.java

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

package jp.co.intra_mart.framework.base.session;

import java.util.ResourceBundle;

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

import java.util.MissingResourceException;

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

/**
 * 僙僢僔儑儞偵娭楢偡傞僨僼僅儖僩偺僾儘僷僥傿僴儞僪儔偱偡丅
 * 僾儘僷僥傿偺愝掕撪梕偼埲壓偺偲偍傝偱偡丅
 * <TABLE border="1">
 *  <TR>
 *      <TH>僉乕</TH>
 *      <TH>撪梕</TH>
 *  </TR>
 *  <TR>
 *      <TD>factory.name</TD>
 *      <TD>{@link SessionFactory}偺僋儔僗柤</TD>
 *  </TR>
 *  <TR>
 *      <TD>object.param</TD>
 *      <TD>儕僋僄僗僩偵搉偡僙僢僔儑儞ID偺僷儔儊乕僞柤</TD>
 *  </TR>
 *  <TR>
 *      <TD>error.page.path</TD>
 *      <TD>僙僢僔儑儞僄儔乕乮僙僢僔儑儞僞僀儉傾僂僩摍乯偺偲偒偵昞帵偡傞儁乕僕偺僷僗</TD>
 *  </TR>
 *  <TR>
 *      <TD>object.key</TD>
 *      <TD>儕僋僄僗僩偺懏惈偵{@link SessionObject}傪曐懚偡傞帪偺僉乕</TD>
 *  </TR>
 *  <TR>
 *      <TD>reserved.user.key</TD>
 *      <TD>{@link SessionObject}偺懏惈偵愝掕偝傟偰偄傞儐乕僓ID偺僉乕</TD>
 *  </TR>
 *  <TR>
 *      <TD>reserved.group.key</TD>
 *      <TD>{@link SessionObject}偺懏惈偵愝掕偝傟偰偄傞儘僌僀儞僌儖乕僾ID偺僉乕</TD>
 *  </TR>
 * </TABLE>
 *
 * @author INTRAMART
 * @version 1.0
 */
public class DefaultSessionPropertyHandler implements SessionPropertyHandler {

    /**
     * 僨僼僅儖僩偺儕僜乕僗僶儞僪儖柤
     */
    public static final String DEFAULT_BUNDLE_NAME = "SessionConfig";

    /**
     * 儕僜乕僗僶儞僪儖柤偺僷儔儊乕僞柤
     */
    public static final String DEFAULT_BUNDLE_NAME_PARAM = "bundle";

    /**
     * 僙僢僔儑儞儕僜乕僗忣曬偑愝掕偝傟偰偄傞儕僜乕僗僶儞僪儖
     */
    private ResourceBundle bundle;

    /**
     * DefaultSessionPropertyHandler傪怴婯偵惗惉偟傑偡丅
     */
    public DefaultSessionPropertyHandler() {
        this.bundle = null;
    }

    /**
     * 僾儘僷僥傿僴儞僪儔傪弶婜壔偟傑偡丅
     *
     * @param params 弶婜僷儔儊乕僞
     * @throws PropertyHandlerException 僾儘僷僥傿僴儞僪儔偺弶婜壔帪偵椺奜偑敪惗
     */
    public void init(PropertyParam[] params) throws PropertyHandlerException {
        String bundleName = null;

        if (params != null) {
            for (int i = 0; i < params.length; i++) {
                if (params[i].getName().equals(DEFAULT_BUNDLE_NAME_PARAM)) {
                    bundleName = params[i].getValue();
                }
            }
        }
        if (bundleName == null) {
            bundleName = DEFAULT_BUNDLE_NAME;
        }

        this.bundle = ResourceBundle.getBundle(bundleName);
    }

    /**
     * 僙僢僔儑儞僼傽僋僩儕偺僋儔僗柤傪庢摼偟傑偡丅
     * 壗傕愝掕偝傟偰偄側偄応崌null偑曉傝傑偡丅
     *
     * @return 僙僢僔儑儞僼傽僋僩儕偺僋儔僗柤乮愝掕偝傟偰偄側偄応崌null乯
     * @throws SessionPropertyException 僙僢僔儑儞僼傽僋僩儕偺僋儔僗柤偺庢摼帪偵椺奜偑敪惗
     * @deprecated 僙僢僔儑儞偲偟偰偼HttpSession傪捈愙棙梡偡傞傛偆偵偟偰偔偩偝偄丅
     */
    public String getSessionFactoryName() throws SessionPropertyException {
        String name;

        try {
            name = this.bundle.getString("factory.name");
        } catch (MissingResourceException e) {
            name = null;
        } catch (Throwable e) {
            String message = null;
            try {
                message =ResourceBundle.getBundle("jp.co.intra_mart.framework.base.session.i18n").getString("DefaultSessionPropertyHandler.FailedToGetFactory");
            } catch (MissingResourceException ex) {
            }
            throw new SessionPropertyException(message, e);
        }

        return name;
    }

    /**
     * 僙僢僔儑儞ID偺僷儔儊乕僞柤傪庢摼偟傑偡丅
     * 壗傕愝掕偝傟偰偄側偄応崌null偑曉傝傑偡丅
     *
     * @return 僙僢僔儑儞ID偺僷儔儊乕僞柤乮愝掕偝傟偰偄側偄応崌null乯
     * @throws SessionPropertyException 僙僢僔儑儞ID偺僷儔儊乕僞柤偺庢摼帪偵椺奜偑敪惗
     * @deprecated HttpSession傪捈愙巊梡偡傞応崌丄偙偺儊僜僢僪偼晄梫偵側傝傑偡丅
     */
    public String getSessionParameter() throws SessionPropertyException {
        String param;

        try {
            param = this.bundle.getString("object.param");
        } catch (MissingResourceException e) {
            param = null;
        } catch (Throwable e) {
            String message = null;
            try {
                message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.session.i18n").getString("DefaultSessionPropertyHandler.FailedToGetSessionIDParam");
            } catch (MissingResourceException ex) {
            }
            throw new SessionPropertyException(message, e);
        }

        return param;
    }

    /**
     * 僙僢僔儑儞僆僽僕僃僋僩偺僉乕傪庢摼偟傑偡丅
     * 壗傕愝掕偝傟偰偄側偄応崌null偑曉傝傑偡丅
     *
     * @return 僙僢僔儑儞僆僽僕僃僋僩偺僉乕乮愝掕偝傟偰偄側偄応崌null乯
     * @throws SessionPropertyException 僙僢僔儑儞僆僽僕僃僋僩偺僉乕偺庢摼帪偵椺奜偑敪惗
     * @deprecated HttpSession傪捈愙庢摼偡傞傛偆偵偟偰偔偩偝偄丅
     */
    public String getSessionObjectKey() throws SessionPropertyException {
        String name;

        try {
            name = this.bundle.getString("object.key");
        } catch (MissingResourceException e) {
            name = null;
        } catch (Throwable e) {
            String message = null;
            try {
                message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.session.i18n").getString("DefaultSessionPropertyHandler.FailedToGetSessionKey");
            } catch (MissingResourceException ex) {
            }
            throw new SessionPropertyException(message, e);
        }

        return name;
    }

    /**
     * 僙僢僔儑儞偵搊榐偝傟偰偄傞儘僌僀儞儐乕僓ID偺僉乕傪庢摼偟傑偡丅
     *
     * @return 儘僌僀儞儐乕僓ID偺僉乕
     * @throws SessionPropertyException 懏惈柤偺庢摼帪偵椺奜偑敪惗
     */
    public String getLoginUserIDKey() throws SessionPropertyException {
        String key;

        try {
            key = this.bundle.getString("reserved.user.key");
        } catch (MissingResourceException e) {
            String message = null;
            try {
                message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.session.i18n").getString("DefaultSessionPropertyHandler.FailedToGetLoginUser");
            } catch (MissingResourceException ex) {
            }
            throw new SessionPropertyException(message, e);
        }

        return key;
    }

    /**
     * 僙僢僔儑儞偵搊榐偝傟偰偄傞儘僌僀儞僌儖乕僾ID偺僉乕傪庢摼偟傑偡丅
     *
     * @return 儘僌僀儞僌儖乕僾ID偺僉乕
     * @throws SessionPropertyException 懏惈柤偺庢摼帪偵椺奜偑敪惗
     */
    public String getLoginGroupIDKey() throws SessionPropertyException {
        String key;

        try {
            key = this.bundle.getString("reserved.group.key");
        } catch (MissingResourceException e) {
            String message = null;
            try {
                message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.session.i18n").getString("DefaultSessionPropertyHandler.FailedToGetLoginGroup");
            } catch (MissingResourceException ex) {
            }
            throw new SessionPropertyException(message, e);
        }

        return key;
    }

    /**
     * 僙僢僔儑儞僄儔乕儁乕僕偺僷僗傪庢摼偟傑偡丅
     *
     * @return 僙僢僔儑儞僄儔乕儁乕僕偺僷僗
     * @throws SessionPropertyException 僙僢僔儑儞僄儔乕儁乕僕偺僷僗偺庢摼帪偵椺奜偑敪惗
     */
    public String getSessionErrorPagePath() throws SessionPropertyException {
        try {
            return this.bundle.getString("error.page.path");
        } catch (MissingResourceException e) {
            String message = null;
            try {
                message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.session.i18n").getString("DefaultSessionPropertyHandler.FailedToGetSessionErrorPagePath");
            } catch (MissingResourceException ex) {
            }
            throw new SessionPropertyException(message, e);
        }
    }
}

⌨️ 快捷键说明

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