| 목차 >> Layout Manager  +- GlueMessageLayout ----+- Reuse Activity  | 
이번 장에서는 문자열 Data를 처리하는 Layout Manager를 다룹니다. 고정길이의 문자열이 순서대로 이어진 형태의 문자열을 처리하니다.
다음은 문자열(message)를 해석하기 위한 포맷 정보입니다.
| 순서 | 항목명 | 길이 | type | 
|---|---|---|---|
| 1 | MSG유형 | 8 | string | 
| 2 | 부서번호 | 2 | number, 소수점없음 | 
| 3 | 부서명 | 14 | string | 
| 4 | 부서위치 | 13 | string | 
| 5 | 구분 | 1 | string | 
다음은 예제용 message 입니다.
MSGFW00190HumanResource seoul C
MSGFW00190HumanResource pangyo U
MSGFW00190 D
GlueMessageLayout 은 Message 생성 및 파싱 처리를 위한 MessageLayoutManager입니다. GlueMessageLayout 에서 제공하는 메소드는 Java Doc을 참고합니다. (GlueAPI)
| 그림 : GlueMessageLayout | 
그림과 같이 MessageLayoutManager은 2가지 구현체를 제공하고 있습니다. XML 기반인 GlueXmlMessageLayout과 DB기반인 GlueDBMessageLayout입니다.
MessageLayoutManager도 CacheManager처럼 applicationContext.xml에 다음과 같이 정의해서 activity layer에서 사용할 수 있습니디.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
    <bean id="serviceManager" class="com.poscoict.glueframework.biz.control.GlueServiceManagerImpl">
        <property name="cacheManager" ref="cacheManager" />
        <property name="serviceLoader" ref="serviceLoader" />
    </bean>
    <bean id="cacheManager" class="com.poscoict.glueframework.cache.ehcache.GlueEhCacheManager"/>
    <bean id="serviceLoader"  class="com.poscoict.glueframework.biz.control.GlueServiceLoader"/>
    <bean id="layoutManager" class=" . . ."/>
</beans>
다음은 layoutManager(applicationContext.xml에 bean으로 등록)를 이용해 문자열data 를 message 객체로 파싱하는 예제입니다.
public class ParseActivity extends GlueActivity<GlueContext>
{
    @Override
    public String runActivity( GlueContext ctx )
    {
        String managerBeanId = "layoutManager";
        String msgString = "MSGFW00190HumanResource seoul        C";
        String msgId="MSGFW001";
        GlueMessageLayout manager = GlueStaticContext.getBeanFactory().getBeanObject( managerBeanId, GlueMessageLayout.class );
        GlueMessage message = manager.makeMessageParsing( manager.getAttributes( msgId ), msgString );
        ctx.setMessage( message );
        return GlueBizControlConstants.SUCCESS;
    }
}
다음은 layoutManager(applicationContext.xml에 bean으로 등록)를 이용해 message 객체를 문자열data로 변환하는 예제입니다.
public class CreateMessageActivity extends GlueActivity<GlueContext>
{
    @Override
    public String runActivity( GlueContext ctx )
    {
        String msgId="MSGFW001";
        GlueMessage messageObj = new GlueMESMessageImpl();
        messageObj.setTCID( msgId );
        messageObj.setObject( "MSG_ID", msgId );
        messageObj.setObject( "DEPTNO", "90" );
        messageObj.setObject( "TYPE", "D" );
        String managerBeanId = "layoutManager";
        GlueMessageLayout manager = GlueStaticContext.getBeanFactory().getBeanObject( managerBeanId, GlueMessageLayout.class );
        String message = manager.makeMessageString(manager.getAttributes( msgId ), messageObj);
        ctx.put( "result", message );
        return GlueBizControlConstants.SUCCESS;
    }
}
MessageLayoutManager를 사용한 reuse Activity는 다음과 같은 것이 제공되고 있습니다.