Announcement Announcement Module
Collapse
No announcement yet.
How to access the jobParameters inside itemReader Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to access the jobParameters inside itemReader

    I have a factory-method: getTickerJobQuery providing a dynamic sql input to the JdbcCursorItemReader.

    How could I get hold of the jobParameters, - and provide them as input to either the JdbcCursorItemReader, - or to the getTickerJobQuery?

    Or suggest another approach..

    Geir

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:p="http://www.springframework.org/schema/p"
           xmlns:context="http://www.springframework.org/schema/context"
           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-2.0.xsd
    		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
    		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
    		http://www.springframework.org/schema/context
                http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    
        <description>This file defines the job for the ticker process.</description>
        <context:component-scan base-package="no.aftenposten.accountbalancer.batch.itemwriter"/>
    
        <import resource="classpath:/springAccountBalancerCore-configurer.xml"/>
    
        <bean id="tickerSequence" parent="simpleJob">
            <property name="jobRepository" ref="simpleJobRepository"/>
            <property name="steps">
                <list>
                    <bean id="tickerStep" parent="simpleStep">
                        <property name="itemReader" ref="jdbcTickerJobItemReader"/>
                        <property name="itemWriter" ref="tickerJobItemWriter"/>
                        <property name="commitInterval" value="1000"/>
                    </bean>
                </list>
            </property>
        </bean>
    
        <bean id="tickerJobItemWriter"
              class="no.aftenposten.accountbalancer.batch.itemwriter.TickerJobItemWriter">
            <property name="accountingManager" ref="accountingManagerImpl"/>
            <property name="accountingDao" ref="accountingJdbcDao"/>
            <property name="productLineDao" ref="productLineHibernateDao"/>
            <property name="subscriptionDao" ref="subscriptionHibernateDao"/>
        </bean>
    
        <bean id="jdbcTickerJobItemReader" class="org.springframework.batch.item.database.JdbcCursorItemReader">
            <property name="dataSource" ref="pulsDataSource"/>
            <property name="mapper">
                <bean class="no.aftenposten.accountbalancer.batch.mapper.SubscriptionLineMapper"/>
            </property>
            <property name="sql">
                <bean factory-bean="queryFactory" factory-method="getTickerJobQuery"/>
            </property>
        </bean>
    </beans>

  • #2
    Just make it a StepExecutionListener:

    http://static.springframework.org/sp...n.html#d0e3811

    You can then call stepExecution.getJobParameters()

    Comment


    • #3
      I have a problem with the StepExecutionListener is called after the ItemReader is initialized. How could I make use of jobParameters retrieved via the StepExecutionListener in the ItemReader?

      Geir

      Comment


      • #4
        Can the values from the JobParameters not be set via the PreparredStatementSetter?

        Comment

        Working...
        X