전자정부프레임워크

 

설정 값 변경

 

context-common.xml

<pre>

    <!-- 국제화 Message 설정 -->
    <bean id="messageSource" class="egovframework.com.cmm.util.EgovWildcardReloadableResourceBundleMessageSource">
        <property name="egovBasenames">
            <list>
                <value>classpath*:egovframework/message/com/**/*</value>
                <value>classpath:/egovframework/rte/fdl/idgnr/messages/idgnr</value>
                <value>classpath:/egovframework/rte/fdl/property/messages/properties</value>
                <value>classpath:/egovframework/egovProps/globals</value>
                <value>classpath:/egovframework/egovProps/**/*</value>
                <value>classpath*:egovframework/egovProps/message/com/**/*</value>
            </list>
        </property>
         <property name="cacheMillis" value="3000"/>
        <property name="cacheSeconds">
            <value>60</value>
        </property>
    </bean>
 

 

</pre>

 

 

 

 

/egovframework/egovProps/  권한 설정 

 

http://www.egovframe.go.kr/wiki/doku.php?id=egovframework:rte3:fdl:property_service

Property Service 는 시스템의 설치 환경에 관련된 정보나, 잦은 정보의 변경이 요구되는 경우 외부에서 그 정보를 관리하게 함으로써 시스템의 유연성을 높이기 위해서 제공하는 것으로 Spring Bean 설정 파일에 관리하고자 하는 정보를 입력(Bean 설정 파일 사용) 하거나 외부 파일에 정보 입력 후에 Bean 설정 파일에서 그 파일 위치를 입력하여 이용(외부 설정 파일 사용)할 수 있다.

2. Bean 설정 파일 사용

간단하게 설정하고자 할 때 사용할 수 있는 방법으로 별도의 외부파일을 두지 않고 Spring Bean 설정 파일을 이용할 수 있다. 하지만 어플리케이션 운영 중에 Property 정보 변경은 불가능 하고 변경처리 시 어플리케이션을 재기동해야 한다. 사용하기 위해서는 bean property의 Name에 properties라고 입력하고 map entry의 key에 관리하고자 하는 키, value에 관리하고자 하는 값을 입력하여 설정한다.

Configuration

   <bean name="propertyService" class="egovframework.rte.fdl.property.impl.EgovPropertyServiceImpl" 
         destroy-method="destroy">
      <property name="properties">
         <map>
            <entry key="AAAA" value="1234"/>
         </map>
      </property>			
   </bean>

- propertyService Bean을 추가할 경우 messageSource Bean도 함께 설정해 주어야 한다. 
- 아래의 코드를 추가 설정한다.

messageSource

<bean id="messageSource"
	class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
	<property name="basenames">
		<list>
			<value>classpath:/message/message-common</value>
			<value>classpath:/egovframework/rte/fdl/idgnr/messages/idgnr</value>
			<value>classpath:/egovframework/rte/fdl/property/messages/properties</value>
		</list>
	</property>
	<property name="cacheSeconds">
		<value>60</value>
	</property>
</bean>

Sample Source

@Resource(name="propertyService")
protected EgovPropertyService propertyService ;
 
@Test
public void testPropertiesService() throws Exception {
   assertEquals("1234",propertyService.getString("AAAA"));
}

제공유형별 설정/사용 방법

제공유형설정 방법사용 방법

Stringkey=“A” value=“ABC”propertyService.getString(“A”)

booleankey=“B” value=“true”propertyService.getBoolean(“B”)

intkey=“C” value=“123”propertyService.getInt(“C”)

longkey=“D” value=“123”propertyService.getLong(“D”)

shortkey=“E” value=“123”propertyService.getShort(“E”)

floatkey=“F” value=“123”propertyService.getFloat(“F”)

Vectorkey=“G” value=“123,456”propertyService.getVector(“G”)

3. 외부 설정 파일 사용

별도의 Property 파일을 만들어서 사용하는 방법으로 Spring Bean 설정 파일에는 파일의 위치를 입력하여 이용할 수 있다. 외부 설정 파일에 기재된 프로퍼티 내용은 어플리케이션 운영 중에 추가 및 변경 가능하다.

Configuration

   <bean name="propertyService" class="egovframework.rte.fdl.property.impl.EgovPropertyServiceImpl" 
         destroy-method="destroy">
      <property name="extFileName">
         <set>
            <map>
               <entry key="encoding" value="UTF-8"/>
               <entry key="filename" value="file:./src/**/refresh-resource.properties"/>
            </map>
            <value>classpath*:properties/resource.properties</value>
         </set>
      </property>			
   </bean>
  • MAP을 이용해서 encoding 정보를 입력하는 방법과 파일 위치만을 기재하는 방법 두가지 설정방법 있음

properties 파일

AAAA=1234

Sample Source

@Resource(name="propertyService")
protected EgovPropertyService propertyService ;
 
@Test
public void testPropertiesService() throws Exception {
   assertEquals("1234",propertyService.getString("AAAA"));
}

실시간 갱신 방법

  1. 외부파일에 기재된 property 내용을 수정한다.

  2. propertyService.refreshPropertyFiles()를 호출한다.

 

 

 

 

 

about author

PHRASE

Level 60  라이트

내 몸은 하나의 작은 천지라. 기쁨과 노함으로 허물이 없게 하며, 좋고 싫어함에 법도가 있도록 하면 이것이 곧 천지의 이치에 순응하는 공부가 될 것이니라. 천지는 하나의 거룩한 부모라. 백성들로 하여금 원망이 없게 하며 모든 사물에 근심이 없도록 하면 이 또한 화목을 돈독하게 하는 기상이니라. -채근담

댓글 ( 7)

댓글 남기기

작성

전자정부프레임워크 목록    more