kr.co.hit.live.resources.impl
Class XMLResources

java.lang.Object
  extended by kr.co.hit.live.resources.impl.ResourcesBase
      extended by kr.co.hit.live.resources.impl.CollectionResourcesBase
          extended by kr.co.hit.live.resources.impl.XMLResources
All Implemented Interfaces:
Serializable, Resources

public class XMLResources
extends CollectionResourcesBase

XMLResources 클래스는 Resources에 대한 구현 클래스이다. '기본(base) URL + 각 도큐먼트의 메세지에 적용될 Locale을 반영하는 name suffix' 유형의 XML 도큐먼트들은 이 클래스로 래핑된다. 리소스는 계층적인 XML 도큐먼트내에서 java.util.ResourceBundle.getBundle().을 사용하여 동일한 방식으로 lookup된다.

생성자에 전달되는 기본(base) URL은 XML 도큐먼트 그룹의 base name을 포함해야 한다. 예를 들어, configuration URL이 http://localhost/foo/Bar로 전달되는 경우 en_US 로케일에 해당하는 리소스는 URL http://localhost/foo/Bar_en_US.xml 로 저장되며, 디폴트 리소스는 http://localhost/foo/Bar.xml로 저장된다.

요구되는 XML 도큐먼트의 구조는 매우 단순하다.

 <?xml version="1.0" encoding="euc-kr"?>
 <resources>
     <resource id="error.login.InvalidPassword" ><![CDATA[잘못된 ID 또는 패스워드입니다.]] >< /resource>
     <resource id="errors.required" ><![CDATA[{0}가 필요합니다.]]>< /resource>
     <resource id="errors.email" ><![CDATA[{0}는 유효하지 않은 이메일 주소입니다.]] >< /resource>
 </resources>
 

Since:
3.0
Version:
$Revision: 1.1 $ $Date: 2006/09/26 08:20:08 $
Author:
김광영
See Also:
Serialized Form

Field Summary
 
Fields inherited from class kr.co.hit.live.resources.impl.CollectionResourcesBase
defaultLocale
 
Fields inherited from class kr.co.hit.live.resources.impl.ResourcesBase
LIVE_RESOURCES_KEY_PREFIX
 
Fields inherited from interface kr.co.hit.live.resources.Resources
LAST_MODIFIED_KEY
 
Constructor Summary
XMLResources(String name, String base)
           명시된 논리명(logical name)과 기본(base) 리소스 URL을 기반으로 Resources인스턴스를 생성한다.
 
Method Summary
protected  Map<Object,Object> getLocaleMap(String baseUrl, Locale locale)
           특정 base URL과 Locale에 해당하는 name-value 의 매핑내용을 Map으로 리턴한다.
 
Methods inherited from class kr.co.hit.live.resources.impl.CollectionResourcesBase
destroy, getKeys, getLocaleList, getLocaleMap, getLocaleSuffix, getObject, lastModified, lastModified
 
Methods inherited from class kr.co.hit.live.resources.impl.ResourcesBase
getBase, getBytes, getInputStream, getName, getReader, getString, init, isReturnNull, setReturnNull
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLResources

public XMLResources(String name,
                    String base)

명시된 논리명(logical name)과 기본(base) 리소스 URL을 기반으로 Resources인스턴스를 생성한다.

Parameters:
name - 새로운 인스턴스의 논리명(Logical name)
base - 리소스 키와 값을 포함하는 프로퍼티 파일의 그룹에 대한 기본(base) URL
Method Detail

getLocaleMap

protected Map<Object,Object> getLocaleMap(String baseUrl,
                                          Locale locale)

특정 base URL과 Locale에 해당하는 name-value 의 매핑내용을 Map으로 리턴한다. 명시된 Locale에 해당하는 매핑정보가 정의되어있지 않은 경우, 빈(empty) Map을 리턴한다.

실질적인 서브클래스들은 이 메소드를 오버라이드(override)하여 적절한 룩업(lookup)을 수행한다. 일반적으로 구현은 명시된 base URL과 Locale를 기반으로 절대 URL을 생성하여 명시된 리소스 파일을 조회하고 Map 구조로 파싱한다.

이전에 조회된 Map들에 대한 caching은 이 메소드의 caller에 의해 수행되어야 한다. 따라서 이 메소드는 특정 리소스에 대한 조회와 적절한 로드(load)를 항상 시도해야 한다.

Specified by:
getLocaleMap in class CollectionResourcesBase
Parameters:
baseUrl - 해당 Resources 인스턴스에 대한 리소스 파일의 Base URL
locale - name-value 매핑에 요구되는 Locale


Copyright © 2014. All Rights Reserved.