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

📄 servicemanager.java

📁 intra_mart是日本NDD公司开发的著名企业应用解决方案中间件。集成了J2ee服务器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * @return 僩儔儞僕僔儑儞
     * @throws ServicePropertyException 僒乕價僗僾儘僷僥傿偺庢摼帪偵椺奜偑敪惗
     * @throws TransitionException 僩儔儞僕僔儑儞庢摼帪偵椺奜偑敪惗
     * @deprecated 偙偺儊僜僢僪偱偼側偔{@link #getTransition(java.lang.String, java.lang.String, java.util.Locale)}傪巊梡偟偰偔偩偝偄丅
     */
    public Transition getTransition(String application, String service)
        throws ServicePropertyException, TransitionException {

        return getTransition(application, service, null);
    }

    /**
     * 僩儔儞僕僔儑儞傪庢摼偟傑偡丅
     * 巜掕偝傟偨傾僾儕働乕僔儑儞ID丄僒乕價僗ID丄儘働乕儖偵奩摉偡傞僩儔儞僕僔儑儞傪庢摼偟傑偡丅
     * 奩摉偡傞僩儔儞僕僔儑儞偑懚嵼偟側偄応崌丄{@link DefaultTransition}傪曉偟傑偡丅
     *
     * @param application 傾僾儕働乕僔儑儞
     * @param service 僒乕價僗
     * @param locale 儘働乕儖
     * @return 僩儔儞僕僔儑儞
     * @throws ServicePropertyException 僒乕價僗僾儘僷僥傿偺庢摼帪偵椺奜偑敪惗
     * @throws TransitionException 僩儔儞僕僔儑儞庢摼帪偵椺奜偑敪惗
     * @since 4.2
     */
    public Transition getTransition(
        String application,
        String service,
        Locale locale)
        throws ServicePropertyException, TransitionException {

        String name = null;
        Object transitionObject = null;
        Transition transition = null;

        // 巜掕偝傟偨傾僾儕働乕僔儑儞偲僒乕價僗偐傜僩儔儞僕僔儑儞傪惗惉
        name =
            this.servicePropertyHandler.getTransitionName(
                application,
                service,
                locale);
        if (name == null) {
            transition = new DefaultTransition();
        } else {
            try {
                transitionObject = Class.forName(name).newInstance();
            } catch (Exception e) {
                String message = null;
                try {
                    message =
                        ResourceBundle
                            .getBundle("jp.co.intra_mart.framework.base.service.i18n")
                            .getString("ServiceManager.FailedToCreateTransition");
                } catch (MissingResourceException ex) {
                }
                throw new TransitionException(
                    message
                        + " : transition class = "
                        + name
                        + ", application = "
                        + application
                        + ", service = "
                        + service
                        + ", locale = "
                        + locale,
                    e);
            }
            if (transitionObject instanceof Transition) {
                transition = (Transition)transitionObject;
            } else {
                String message = null;
                try {
                    message =
                        ResourceBundle
                            .getBundle("jp.co.intra_mart.framework.base.service.i18n")
                            .getString("ServiceManager.TransitionExtended");
                } catch (MissingResourceException ex) {
                }
                throw new TransitionException(
                    message
                        + " : transition class = "
                        + name
                        + ", application = "
                        + application
                        + ", service = "
                        + service
                        + ", locale = "
                        + locale);
            }
        }

        // 僩儔儞僕僔儑儞偺奺庬忣曬偺愝掕
        transition.setServiceManager(this);
        transition.setApplication(application);
        transition.setService(service);

        return transition;
    }

    /**
     * 尰嵼偺儕僋僄僗僩偵懳偡傞傾僾儕働乕僔儑儞ID傪庢摼偟傑偡丅
     *
     * @param request 儕僋僄僗僩
     * @param response 儗僗億儞僗
     * @return 尰嵼偺儕僋僄僗僩偵懳偡傞傾僾儕働乕僔儑儞ID
     * @throws ServicePropertyException 傾僾儕働乕僔儑儞ID庢摼帪偵椺奜偑敪惗
     * @since 4.2
     */
    public String getApplication(
        HttpServletRequest request,
        HttpServletResponse response)
        throws ServicePropertyException {
    	
    	String application = null;
    	String baseString;
        String servletPath = request.getServletPath();
        String pathInfo = request.getPathInfo();
        if (pathInfo == null) {
        	if(servletPath.charAt(0) == '/') {
                baseString = servletPath.substring(1, servletPath.lastIndexOf('.'));
        	} else {
                baseString = servletPath.substring(0, servletPath.lastIndexOf('.'));
        	}
        } else {
            baseString = pathInfo;
        }
        String[] infoString = baseString.split(ServiceServlet.REQUEST_SEPARATOR, -1);
        
        if(infoString.length == 0) {
        	return null;
        }
        
		if(NameUtil.isValidName(infoString[0])) {
			application = infoString[0];
		}
		return application;
    }

    /**
     * 尰嵼偺儕僋僄僗僩偵懳偡傞僒乕價僗ID傪庢摼偟傑偡丅
     *
     * @param request 儕僋僄僗僩
     * @param response 儗僗億儞僗
     * @return 尰嵼偺儕僋僄僗僩偵懳偡傞僒乕價僗ID
     * @throws ServicePropertyException 僒乕價僗ID庢摼帪偵椺奜偑敪惗
     * @since 4.2
     */
    public String getService(
        HttpServletRequest request,
        HttpServletResponse response)
        throws ServicePropertyException {
    	
    	String service = null;
    	String baseString;
        String servletPath = request.getServletPath();
        String pathInfo = request.getPathInfo();
        if (pathInfo == null) {
        	if(servletPath.charAt(0) == '/') {
                baseString = servletPath.substring(1, servletPath.lastIndexOf('.'));
        	} else {
                baseString = servletPath.substring(0, servletPath.lastIndexOf('.'));
        	}
        } else {
            baseString = pathInfo;
        }
        
        String[] infoString = baseString.split(ServiceServlet.REQUEST_SEPARATOR, -1);
        if(infoString.length < 2) {
        	return null;
        }
		if(NameUtil.isValidName(infoString[1])) {
			service = infoString[1];
		}
		return service;
    }

    /**
     * 尰嵼偺儕僋僄僗僩偵懳偡傞儘働乕儖傪庢摼偟傑偡丅
     * 儘働乕儖偺庢摼偼埲壓偺桪愭弴埵偵廬偄傑偡丅
     * <OL>
     * <LI>僙僢僔儑儞撪偺{@link ServicePropertyHandler#getLocaleAttributeName()}偱庢摼偝傟傞懏惈柤偱搊榐偝傟偨儘働乕儖
     * <LI>{@link ServicePropertyHandler#getClientLocale()}偱庢摼偝傟傞儘働乕儖
     * <LI>{@link javax.servlet.ServletRequest#getLocale()}偱庢摼偝傟傞儘働乕儖
     * <LI>{@link java.util.Locale#getDefault()}偱庢摼偝傟傞儘働乕儖
     * </OL>
     *
     * @param request 儕僋僄僗僩
     * @param response 儗僗億儞僗
     * @return 儘働乕儖
     * @throws ServicePropertyException 僒乕價僗僾儘僷僥傿偺庢摼帪偵椺奜偑敪惗
     * @since 4.2
     */
    public Locale getLocale(
        HttpServletRequest request,
        HttpServletResponse response)
        throws ServicePropertyException {

        Locale locale = null;

        // 僙僢僔儑儞撪偺儘働乕儖傪庢摼
        HttpSession session = request.getSession(false);
        if (session != null) {
            String localeAttribute =
                getServicePropertyHandler().getLocaleAttributeName();
            locale = (Locale)session.getAttribute(localeAttribute);
        }

        // ServicePropertyHandler.getClientLocale()偱儘働乕儖傪庢摼
        if (locale == null) {
            locale = getServicePropertyHandler().getClientLocale();
        }

        // ServletRequest.getLocale()偱儘働乕儖傪庢摼
        if (locale == null) {
            locale = request.getLocale();
        }

        // Locale.getDefault()偱儘働乕儖傪庢摼
        if (locale == null) {
            locale = Locale.getDefault();
        }
        return locale;
    }

    /**
     * 尰嵼偺儕僋僄僗僩偵懳偡傞僄儞僐乕僨傿儞僌傪庢摼偟傑偡丅
     * 僄儞僐乕僨傿儞僌偺庢摼偼埲壓偺桪愭弴埵偵廬偄傑偡丅
     * <OL>
     * <LI>僙僢僔儑儞撪偺{@link ServicePropertyHandler#getEncodingAttributeName()}偱庢摼偝傟傞懏惈柤偱搊榐偝傟偨僄儞僐乕僨傿儞僌
     * <LI>{@link ServicePropertyHandler#getClientEncoding()}偱庢摼偝傟傞僄儞僐乕僨傿儞僌
     * <LI>{@link javax.servlet.ServletRequest#getCharacterEncoding()}偱庢摼偝傟傞僄儞僐乕僨傿儞僌
     * <LI>null
     * </OL>
     *
     * @param request 儕僋僄僗僩
     * @param response 儗僗億儞僗
     * @return 僄儞僐乕僨傿儞僌
     * @throws ServicePropertyException 僒乕價僗僾儘僷僥傿偺庢摼帪偵椺奜偑敪惗
     * @since 4.2
     */
    public String getEncoding(
        HttpServletRequest request,
        HttpServletResponse response)
        throws ServicePropertyException {

        String encoding = null;

        // 僙僢僔儑儞偐傜僄儞僐乕僨傿儞僌傪庢摼
        HttpSession session = request.getSession(false);
        if (session != null) {
            String encodingAttribute =
                getServicePropertyHandler().getEncodingAttributeName();
            encoding = (String)session.getAttribute(encodingAttribute);
        }

        // 僒乕價僗僾儘僷僥傿僴儞僪儔偐傜僄儞僐乕僨傿儞僌傪庢摼
        if (encoding == null) {
            encoding = getServicePropertyHandler().getClientEncoding();
        }

        // ServletRequest.getCharacterEncoding偱僄儞僐乕僨傿儞僌傪庢摼
        if (encoding == null) {
            encoding = request.getCharacterEncoding();
        }

        return encoding;
    }

    /**
     * 僒乕價僗僼儗乕儉儚乕僋傪屇傃弌偡偨傔偺奼挘巕傪庢摼偟傑偡丅<BR>
     * {@link #SERVICE_EXTESION_KEY}傪僉乕偲偟偨僔僗僥儉僾儘僷僥傿傪専嶕偟丄
     * 懚嵼偟側偄応崌偼{@link #DEFAULT_SERVICE_EXT}傪曉媝偟傑偡丅
     *
     * @return 僒乕價僗僼儗乕儉儚乕僋傪屇傃弌偡偨傔偺奼挘巕 
     * @since 5.0
     */
    public String getExtesion() throws ServiceManagerException {
    	return System.getProperty(SERVICE_EXTENSION_KEY, DEFAULT_SERVICE_EXTENSION);
    }
}

⌨️ 快捷键说明

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