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

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.PropertyResources
All Implemented Interfaces:
Serializable, Resources

public class PropertyResources
extends CollectionResourcesBase

Resources에 대한 구현 클래스이다. PropertyResources 클래스는 Locale과 1:1로 대응되는 프로퍼티 파일의 집합을 래핑한다. 각 프로퍼티 파일은 '베이스 URL + 해당 도큐먼트의 메시지에 적용될 Locale을 반영하는 name suffix'을 갖는다. 리소스는 프로퍼티 파일내의 계층구조에서 java.util.ResourceBundle.getBundle().과 동일한 방식으로 lookup된다.

생성자에 전달되는 베이스 URL은 프로퍼티 파일 그룹의 베이스 네임을 포함해야 한다. 예를 들어 configuration URL이 http://localhost/foo/Bar로 전달되면 en_US 로케일에 대한 리소스는 http://localhost/foo/Bar_en_US.properties로 저장될 것이다. 디폴트 리소스는 http://localhost/foo/Bar.properties로 저장된다.

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
PropertyResources(String name, String base)
           명시된 논리명과 베이스 URL을 기반으로 새로운 Resources 인스턴스를 생성한다.
 
Method Summary
protected  Map<Object,Object> getLocaleMap(String baseUrl, Locale locale)
           명시된 베이스 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

PropertyResources

public PropertyResources(String name,
                         String base)

명시된 논리명과 베이스 URL을 기반으로 새로운 Resources 인스턴스를 생성한다.

Parameters:
name - 새로운 인스턴스의 논리명
base - 리소스의 키와 값을 포함하는 프로퍼티 파일 집합의 베이스 URL
Method Detail

getLocaleMap

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

명시된 베이스 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 인스턴스에 대한 베이스 URL
locale - name-value 매핑에 필요한 Locale


Copyright © 2014. All Rights Reserved.