Example usage for org.springframework.batch.core.step.tasklet TaskletStep afterPropertiesSet

List of usage examples for org.springframework.batch.core.step.tasklet TaskletStep afterPropertiesSet

Introduction

In this page you can find the example usage for org.springframework.batch.core.step.tasklet TaskletStep afterPropertiesSet.

Prototype

@Override
    public void afterPropertiesSet() throws Exception 

Source Link

Usage

From source file:org.springframework.batch.core.step.item.SimpleStepFactoryBean.java

/**
 * Create a {@link Step} from the configuration provided.
 * /*from w  w  w .j  av a  2s. c  om*/
 * @see FactoryBean#getObject()
 */
public final Object getObject() throws Exception {
    TaskletStep step = new TaskletStep(getName());
    applyConfiguration(step);
    step.afterPropertiesSet();
    return step;
}

From source file:org.springframework.data.hadoop.admin.util.HadoopWorkflowUtils.java

/**
 * create and register Spring Batch job//from   w ww  . j a va  2 s.c  o m
 * 
 * @param context root application context
 * @param artifacts workflow artifacts which include workflow descriptor and class loader information.
 * @throws Exception
 */
public static void createAndRegisterSpringBatchJob(ApplicationContext context,
        final WorkflowArtifacts artifacts) throws SpringHadoopAdminWorkflowException {
    if (context == null) {
        logger.warn("root applicaton context is null");
        throw new SpringHadoopAdminWorkflowException("root applicaton context is null");
    }
    String workflowDescriptor = getWorkflowDescriptor(artifacts);
    logger.info("create spring batch job:" + workflowDescriptor + ", classloader:"
            + artifacts.getWorkflowClassLoader());

    final FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext();
    ctx.setClassLoader(artifacts.getWorkflowClassLoader());
    ctx.setConfigLocation(HadoopWorkflowUtils.fileURLPrefix + workflowDescriptor);

    try {
        SimpleJob job = new SimpleJob(generateSpringBatchJobName(artifacts));
        TaskletStep step = new TaskletStep(springHadoopTaskName);
        SimpleSpringHadoopTasklet tasklet = new SimpleSpringHadoopTasklet();
        tasklet.setContext(ctx);
        step.setTasklet(tasklet);
        JobRepository jobRepository = context.getBean(JobRepository.class);
        DataSourceTransactionManager transactionManager = context.getBean("transactionManager",
                DataSourceTransactionManager.class);
        step.setTransactionManager(transactionManager);
        step.setJobRepository(jobRepository);
        step.afterPropertiesSet();
        job.addStep(step);
        JobRegistry jobRegistry = context.getBean("jobRegistry", JobRegistry.class);
        job.setJobRepository(jobRepository);
        job.afterPropertiesSet();
        JobFactory jobFactory = new ReferenceJobFactory(job);
        jobRegistry.register(jobFactory);
    } catch (Exception e) {
        logger.warn("create and register Spring Batch Job failed");
        throw new SpringHadoopAdminWorkflowException("create and register Spring Batch Job failed", e);
    }
}