How to

Quick Start

  1. GlueSDK 다운로드 (Welcome -> '솔루션 패키지 다운로드' 부분 참고)

  2. 예제 Application 작성 (sample.zip 제공)

예제 Application 작성

Eclipse에서 Java Project 를 생성합니다. 그리고 다음 6개 파일을 생성합니다. 실행시 필요한 라이브러리는 GlueSDK를 사용합니다.

  • applicationContext.xml : 필수
    <?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.0.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"/>
    </beans>
    
  • ehcache.xml : EhCache 설정파일 (JCS 교체 가능)
    <?xml version="1.0" encoding="UTF-8"?>
    <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false" name="__DEFAULT__">
        <cache name="_default-region" maxElementsInMemory="500" eternal="true" />
        <cache name="_service-region" maxElementsInMemory="500" eternal="true" />
    </ehcache>
    
  • logback.xml : Logback 설정파일 (Log4j 교체 가능)
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
            <encoder>
                <pattern>[%thread] %-5level %logger - %msg%n</pattern>
            </encoder>
        </appender>
        <logger name="com.poscoict">
            <level value="debug" />
        </logger>
        <logger name="org.springframework">
            <level value="info" />
        </logger>
        <root level="warn">
            <appender-ref ref="CONSOLE" />
        </root>
    </configuration>
    
  • hello-service.xml : 기본 실행단위 (Glue Service)
    <?xml version="1.0" encoding="UTF-8"?>
    <service name="hello-service" initial="HelloActivity" xmlns="http://www.poscoict.com/glueframework/service">
        <activity name="HelloActivity" class="sample.activity.HelloActivity">
            <transition name="success" value="end"/>
        </activity>
    </service>
    
  • HelloActivity.java : Sample Activity
    package sample.activity;
    
    import com.poscoict.glueframework.biz.activity.GlueActivity;
    import com.poscoict.glueframework.biz.control.GlueBizControlConstants;
    import com.poscoict.glueframework.context.GlueContext;
    
    public class HelloActivity extends GlueActivity<GlueContext>
    {
        @Override
        public String runActivity( GlueContext ctx )
        {
            System.out.println( "ServiceName : " + ctx.get( GlueBizControlConstants.SERVICE_NAME ) );
            System.out.println( "This is '" + this.getName() + "' activity" );
    
            Object input = ctx.get( "input" );
            System.out.println( "data : " + input );
    
            Object output = "Hello " + input + "!!!";
            ctx.put( "result", output );
    
            return GlueBizControlConstants.SUCCESS;
        }
    }
    
  • Test.java : 테스트용
    package test;
    
    import com.poscoict.glueframework.biz.control.GlueBizControlConstants;
    import com.poscoict.glueframework.biz.control.GlueBizController;
    import com.poscoict.glueframework.biz.control.GlueBizProvider;
    import com.poscoict.glueframework.context.GlueContext;
    import com.poscoict.glueframework.context.GlueDefaultContext;
    
    public class Test
    {
        public static void main( String[] args )
        {
            GlueContext ctx = new GlueDefaultContext();
            ctx.put( GlueBizControlConstants.SERVICE_NAME, "hello-service" );
            ctx.put( "input", "Glue" );
    
            GlueBizController controller = GlueBizProvider.getController();
            controller.doAction( ctx );
    
            System.out.println( ctx.get( "result" ) );
        }
    }
    
필요 library

초간단 hello-service 실행시 필요한 library 목록은 다음과 같다.

glue-core-4.2.3-RELEASE.jar
glue-schema-4.2.3-RELEASE.jar
license-api-1.1.0.jar
xmlbeans-2.4.0.jar
stax-api-1.0.1.jar
ehcache-core-2.6.6.jar
slf4j-api-1.7.2.jar
logback-classic-1.0.13.jar
logback-core-1.0.13.jar
jcl-over-slf4j-1.6.6.jar
spring-beans-3.2.8.RELEASE.jar
spring-context-3.2.8.RELEASE.jar
spring-core-3.2.8.RELEASE.jar
spring-expression-3.2.8.RELEASE.jar
예제 Application 실행
[main] INFO  com.poscoict.glueframework.context.GlueStaticContext - glueframework version : 4.2.3-RELEASE
[main] INFO  com.poscoict.glueframework.context.GlueStaticContext - EDUCATION
[main] WARN  com.poscoict.glueframework.context.GlueStaticContext - Check Java Option 'CONFIG_PATH'
[main] INFO  org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@f73c1: startup date [Tue Aug 12 16:10:19 GMT+09:00 2014]; root of context hierarchy
[main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [applicationContext.xml]
[main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1ec8909: defining beans [serviceManager,serviceLoader,cacheManager]; root of factory hierarchy
[main] WARN  com.poscoict.glueframework.biz.control.GlueBizControllerImpl - running in EDUCATION MODE : 1
[main] INFO  com.poscoict.glueframework.biz.control.GlueBizControllerImpl - ServiceName:[hello-service] StartTime[Tue Aug 12 16:10:20 GMT+09:00 2014]
[main] WARN  com.poscoict.glueframework.cache.ehcache.GlueEhCacheManager - CacheManager does not exist for [__DEFAULT__]
[main] DEBUG com.poscoict.glueframework.cache.ehcache.GlueEhCacheManager - Default CacheManager is created and returned : [__DEFAULT__]
[main] DEBUG com.poscoict.glueframework.biz.control.GlueServiceLoader - Loading service file : /C:/eclipse/workspace-glue-4-sample/sample-parent/sample-hello/target/classes/service%5chello-service.xml
[main] INFO  com.poscoict.glueframework.biz.control.GlueService - ActivityName:[hello-service][HelloActivity] StartTime[Tue Aug 12 16:10:21 GMT+09:00 2014]
ServiceName : hello-service
This is 'HelloActivity' activity
data : Glue
[main] INFO  com.poscoict.glueframework.biz.control.GlueService - ActivityName:[hello-service][HelloActivity] EndTime[Tue Aug 12 16:10:21 GMT+09:00 2014] RunTime[1]
[main] INFO  com.poscoict.glueframework.biz.control.GlueBizControllerImpl - ServiceName:[hello-service] EndTime[Tue Aug 12 16:10:21 GMT+09:00 2014] RunTime:[1120]
Hello Glue!!!