Build

java 사용법에 따라 2가지로 packaging 할 수 있습니다.

Java Usage
  1. class 실행

    첫번째 java 사용법은 class를 실행하는 경우로서 아래와 같이 jar 파일을 생성합니다.

    • build.xml
      <project name="GlueSample" default="jar" basedir=".">
          <property file="build.properties"/>
          <target name="init">
              <mkdir dir="${basedir}/build"/>
              <mkdir dir="${basedir}/buildfile"/>
          </target>
          <target name="javac" depends="init">
              <javac srcdir="${basedir}/src" destdir="${basedir}/buildfile" encoding="UTF-8">
                  <classpath>
                      <pathelement location="${GlueSDK.dir}/lib/gluelib/glue-core-4.2.7-RELEASE.jar" />
                      <pathelement location="${GlueSDK.dir}/lib/gluelib/glue-schedule-4.2.7-RELEASE.jar" />
                      <!-- add here ... -->
                  </classpath>
              </javac>
          </target>
          <target name="jar" depends="javac">
              <jar destfile="${basedir}/build/sample1.jar">
                  <fileset dir="${basedir}/buildfile">
                      <patternset>
                          <include name="**/*.*"/>
                      </patternset>
                  </fileset>
                  <fileset dir="${basedir}/src">
                      <patternset>
                          <include name="applicationContext.xml"/>
                          <include name="ehcache.xml"/>
                          <include name="logback-test.xml"/>
                          <include name="layout/*.xml"/>
                          <include name="query/*.glue_sql"/>
                          <include name="service/*.xml"/>
                      </patternset>
                  </fileset>
              </jar>
          </target>
      </project>
      
    • build.propereties
      GlueSDK.dir=C:/eclipse/users/GlueSDK
      
  2. jarfile 실행

    두번째 java 사용법은 jarfile를 실행하는 경우로서 MANIFEST.MF 파일에 Main-ClassClass-Path 가 포함되어 있어야 합니다.
    Main-Class 는 다음 중 하나를 사용할 수 있습니다.

    • com.poscoict.app.job.GlueSimpleJob : 권장
    • com.posco.glue.cm.DefaultSchedulerJob : deprecated
    • com.posco.glue.cm.PoscoDefaultSchedulerJob : POSCO MLE 라이브러리를 사용하는 탄소강 표준모델에서만 허용.

    아래와 같이 jar 파일을 생성합니다.

    • build.xml
      <project name="GlueSample" default="user-application" basedir=".">
          <property file="build.properties"/>
          <target name="init">
              <mkdir dir="${basedir}/build"/>
              <mkdir dir="${basedir}/build/lib"/>
              <mkdir dir="${basedir}/buildfile"/>
          </target>
          <path id="class.path">
              <fileset dir="${GlueSDK.dir}/lib/gluelib" >
                  <include name="*.jar"/>
              </fileset>
              <fileset dir="${GlueSDK.dir}/lib/gluestd" >
                  <include name="*.jar"/>
              </fileset>
              <!-- add here .. -->
          </path>
          <pathconvert property="class-path" pathsep=" " dirsep="\">
              <path refid="class.path"/>
              <map from="${GlueSDK.dir}/lib/gluestd" to="lib"/>
              <map from="${GlueSDK.dir}/lib/gluelib" to="lib"/>
              <!-- add here .. -->
          </pathconvert>
          <target name="javac" depends="init">
              <javac srcdir="${basedir}/src" destdir="${basedir}/buildfile" encoding="UTF-8">
                  <classpath>
                      <pathelement location="${GlueSDK.dir}/lib/gluelib/glue-core-4.2.6-RELEASE.jar" />
                      <pathelement location="${GlueSDK.dir}/lib/gluelib/glue-schedule-4.2.6-RELEASE.jar" />
                      <!-- add here ... -->
                  </classpath>
              </javac>
          </target>
          <target name="user-application" depends="javac">
              <jar destfile="${basedir}/build/user-application.jar">
                  <manifest>
                      <attribute name="Main-Class" value="com.poscoict.app.job.GlueSimpleJob"/>
                      <attribute name="Class-Path" value="${class-path}" />
                  </manifest>
                  <fileset dir="${basedir}/buildfile">
                      <patternset>
                          <include name="**/*.*"/>
                      </patternset>
                  </fileset>
                  <fileset dir="${basedir}/src">
                      <patternset>
                          <include name="applicationContext.xml"/>
                          <include name="ehcache.xml"/>
                          <include name="**/*.xml"/>
                          <include name="**/*.glue_sql"/>
                      </patternset>
                  </fileset>
              </jar>
          </target>
      </project>
      
    • build.propereties
      GlueSDK.dir=C:/eclipse/users/GlueSDK
      

How to test

실행옵션과 JobData에 따라 다음과 같은 Java명령어를 통해 테스트가 가능합니다.
[args..] 부분의 첫번재 인자는 고정값 -1 으로 합니다.

set SCHEDULER_HOME=C:/scheduler-server
cd C:/scheduler-server/apps/
java -DCONFIG_PATH=C:/scheduler-server/conf -Dlog.file=C:/scheduler-server/logs/test.log -cp ./sample1.jar;./lib/*; com.poscoict.app.job.GlueSimpleJob -1 ServiceName=job001-service@S sleep-second=5@S
set SCHEDULER_HOME=C:/scheduler-server
cd C:/scheduler-server/apps/
java -DCONFIG_PATH=C:/scheduler-server/conf -Dlog.file=C:/scheduler-server/logs/test.log -cp ./sample2.jar;./lib/*; com.poscoict.app.job.GlueSimpleJob -1 className=sample.job.SamplePgm@S sleep-second=5@S
set SCHEDULER_HOME=C:/scheduler-server
cd C:/scheduler-server/apps/
java -DCONFIG_PATH=C:/scheduler-server/conf -Dlog.file=C:/scheduler-server/logs/test.log -jar user-appliction.jar -1 className=sample.job.SamplePgm@S sleep-second=5@S
set SCHEDULER_HOME=C:/scheduler-server
cd C:/scheduler-server/apps/
java -DCONFIG_PATH=C:/scheduler-server/conf -Dlog.file=C:/scheduler-server/logs/test.log -jar user-appliction.jar -1 ServiceName=job001-service@S sleep-second=5@S