Results 1 to 6 of 6

Thread: Dynamic Job Creation in Spring-Batch-How to set bean's property value at runtime

Threaded View

  1. #1

    Question Dynamic Job Creation in Spring-Batch-How to set bean's property value at runtime

    Hi Everyone,

    I am new to spring batch and I have a requirement as mentioned below

    Requirement :

    I have a UI,where the client can enter property details of a Email Action,File Mover Action or File Copy Action,etc.
    The client will drag the actions(ex.Email Action,File Mover Action) elements(rectangle box in UI) from the front-end and
    enter the properties and do a save.For example,for a File Copy Action element,the user can enter the below:
    -- host,file_name,input_location,output_location.
    Once the client save the details,we have to generate a Job.xml and execute it in Spring-Batch

    snapshot of our Job.xml is like below:
    ** Where the value="{...}" will come from UI or database

    <beans ...>
    .......
    ......
    <bean id="copyFile" class="com.email.FileCopyActionTasklet" >
    <property name="host" value="{host}"/>
    <property name="file_name" value="{file_name}"/>
    <property name="input_location" value="{input_location}"/>
    <property name="output_location" value="{body_msg}"/>

    </bean>
    <bean id="dynamicJobParameters" class="com.springbatch.DynamicJobParameters" />
    <batch:job id="copyJobId" job-repository="jobRepository" incrementer="dynamicJobParameters">
    <batch:step id="step0">
    <batch:tasklet ref="copyFile" transaction-manager="jobRepository-transactionManager" />
    </batch:step>
    </batch:job>
    </beans>

    Could anybody please help me out ,how can I achieve this.We have to set the property value at runtime.

    Please let me also know which below approach shall I take :

    1.
    GenericApplicationContext genericContext = new GenericApplicationContext();
    XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(genericContext );
    xmlReader.loadBeanDefinitions(new FileSystemResource("Job.xml");
    genericContext.refresh();

    Or

    2.the one posted that was posted earlier in this forum :

    Dynamic Job Creation

    Thanks in Advance

    Shyam
    Last edited by shyambaishya; Jul 31st, 2012 at 08:04 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •