Java 类org.springframework.batch.core.launch.support.CommandLineJobRunner 实例源码

项目:nyla    文件:CommandLineTimestampJobRunner.java   
/**
 * 
 * @param args
 * @throws Exception
 */
public static void main(String[] args)
throws Exception
{
    if(args.length < 2)
    {
        throw new RequiredException("Usage: java "+CommandLineTimestampJobRunner.class.getName()+" job.xml jobid");
    }

    String[] commandLineArgs = new String[args.length+1];

    Date start = Calendar.getInstance().getTime();

    String timestamp = Text.formatDate(timestampFormat, start);

    System.arraycopy(args, 0, commandLineArgs, 0, args.length);

    commandLineArgs[args.length] = new StringBuilder().append(timestampParameterName).append("=").append(timestamp).toString();

    try
    {
        //Test Service Factory creation
        ServiceFactory.getInstance();

        CommandLineJobRunner.main(commandLineArgs);
    }
    catch (Exception e)
    {
        throw handleJobException(e);

    }

}
项目:springbatch-showcase    文件:Main.java   
public static void main(String[] args) throws Exception {
    CommandLineJobRunner.main(
            new String[]{"org/yggd/springbatch/showcase/repository/repositoryConfig.xml",
                    "repositoryJob", "aaa=hoge"});
}
项目:springbatch-showcase    文件:JavaConfigMain.java   
/**
 * エントリポイント
 *
 * @param args 引数
 */
public static void main(String[] args) throws Exception {
    CommandLineJobRunner.main(
            new String[]{JavaConfig.class.getName(), "firstJob", "aaa=hoge"}
    );
}
项目:spring-batch-experiments    文件:CommandLineJobRunnterTest.java   
@Test
public void run() throws Exception {

    final Queue<Integer> exitCode = new ArrayBlockingQueue<Integer>(1);
    CommandLineJobRunner.presetSystemExiter(new SystemExiter() {
        @Override
        public void exit(int status) {
            exitCode.add(status);
        }
    });

    CommandLineJobRunner.main(new String[]{
        JOB_CONTEXT,
        "importProductsJob"
    });
    assertThat(exitCode.poll().intValue()).isEqualTo(0);

    CommandLineJobRunner.main(new String[]{
        JOB_CONTEXT,
        "importProductsJob",
        "exit.status=COMPLETED"
    });
    assertThat(exitCode.poll().intValue()).isEqualTo(0);

    CommandLineJobRunner.main(new String[]{
        JOB_CONTEXT,
        "importProductsJob",
        "exit.status=FAILED"
    });
    assertThat(exitCode.poll().intValue()).isEqualTo(1);

    CommandLineJobRunner.main(new String[]{
        JOB_CONTEXT,
        "importProductsJob",
        "exit.status=COMPLETED WITH SKIPS"
    });
    assertThat(exitCode.poll().intValue()).isEqualTo(3);

    CommandLineJobRunner.main(new String[]{
        JOB_CONTEXT,
        "importProductsJob",
        "exit.status=ANYTHING"
    });
    assertThat(exitCode.poll().intValue()).isEqualTo(2);
}
项目:springbatch-showcase    文件:XmlConfigMain.java   
/**
 * XMLのBean定義ファイルから起動
 *
 * @param args 引数
 */
public static void main(String[] args) throws Exception {
    CommandLineJobRunner.main(new String[]{"org/yggd/springbatch/showcase/firststep/beanDefinition.xml", "firstJob", "aaa=hoge"});
}