Attempt to refactor NFL so that it can be run from a command line launcher in Eclipse instead of a unit test
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
<config>src/main/resources/jobs/adhocLoopJob.xml</config>
|
||||
<config>src/main/resources/jobs/infiniteLoopJob.xml</config>
|
||||
<config>src/main/resources/data-source-context-init.xml</config>
|
||||
<config>src/main/resources/jobs/nfljob.xml</config>
|
||||
<config>src/main/resources/jobs/xmlStaxJob.xml</config>
|
||||
</configs>
|
||||
<configSets>
|
||||
@@ -131,7 +130,6 @@
|
||||
<incomplete>false</incomplete>
|
||||
<configs>
|
||||
<config>src/main/resources/data-source-context.xml</config>
|
||||
<config>src/main/resources/jobs/nfljob.xml</config>
|
||||
<config>src/main/resources/simple-container-definition.xml</config>
|
||||
</configs>
|
||||
</configSet>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/execution/src/main/java/org/springframework/batch/execution/bootstrap/BatchCommandLineLauncher.java"/>
|
||||
<listEntry value="/execution/src/main/java/org/springframework/batch/execution/bootstrap/support/BatchCommandLineLauncher.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
@@ -9,10 +9,7 @@
|
||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;core&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;classpathContainer path=&quot;org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.classpathContainer"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;execution&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;infrastructure&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<booleanAttribute key="org.eclipse.jdt.debug.ui.CONSIDER_INHERITED_MAIN" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.debug.ui.INCLUDE_EXTERNAL_JARS" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.springframework.batch.execution.bootstrap.BatchCommandLineLauncher"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="jobs/simpleTaskletJob.xml jobConfiguration"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.springframework.batch.execution.bootstrap.support.BatchCommandLineLauncher"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="samples"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.STOP_IN_MAIN" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Djob.configuration.path=jobs/nflJob.xml -Djob.name=nfljob"/>
|
||||
</launchConfiguration>
|
||||
|
||||
172
samples/src/main/resources/jobs/nflJob.xml
Normal file
172
samples/src/main/resources/jobs/nflJob.xml
Normal file
@@ -0,0 +1,172 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
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">
|
||||
|
||||
<bean
|
||||
class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
|
||||
<property name="jobConfigurationRegistry"
|
||||
ref="jobConfigurationRegistry" />
|
||||
</bean>
|
||||
|
||||
<bean id="nfljob"
|
||||
class="org.springframework.batch.core.configuration.JobConfiguration">
|
||||
<property name="restartable" value="true" />
|
||||
<property name="startLimit" value="100" />
|
||||
<property name="steps">
|
||||
<list>
|
||||
<bean id="playerload"
|
||||
class="org.springframework.batch.execution.step.simple.SimpleStepConfiguration">
|
||||
<property name="commitInterval" value="100"></property>
|
||||
<property name="startLimit" value="100" />
|
||||
<property name="saveRestartData" value="true" />
|
||||
<property name="allowStartIfComplete" value="false" />
|
||||
<property name="tasklet">
|
||||
<bean
|
||||
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
|
||||
<property name="itemProvider">
|
||||
<bean
|
||||
class="org.springframework.batch.sample.item.provider.NflPlayerItemProvider">
|
||||
<property name="inputSource"
|
||||
ref="playerFileInputSource" />
|
||||
<property name="fieldSetMapper">
|
||||
<bean
|
||||
class="org.springframework.batch.sample.mapping.NflPlayerMapper" />
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="itemProcessor">
|
||||
<bean
|
||||
class="org.springframework.batch.sample.item.processor.NflPlayerItemProcessor">
|
||||
<property name="nflPlayerDao">
|
||||
<bean
|
||||
class="org.springframework.batch.sample.dao.SqlNflPlayerDao">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="gameLoad"
|
||||
class="org.springframework.batch.execution.step.simple.SimpleStepConfiguration">
|
||||
<property name="commitInterval" value="100" />
|
||||
<property name="startLimit" value="100" />
|
||||
<property name="saveRestartData" value="true" />
|
||||
<property name="tasklet">
|
||||
<bean
|
||||
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
|
||||
<property name="itemProvider">
|
||||
<bean
|
||||
class="org.springframework.batch.item.provider.FlatFileItemProvider">
|
||||
<property name="source"
|
||||
ref="gameFileInputSource" />
|
||||
<property name="mapper">
|
||||
<bean
|
||||
class="org.springframework.batch.sample.mapping.NflGameMapper" />
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="itemProcessor">
|
||||
<bean
|
||||
class="org.springframework.batch.item.processor.OutputSourceItemProcessor">
|
||||
<property name="outputSource">
|
||||
<bean
|
||||
class="org.springframework.batch.sample.dao.SqlNflGameDao">
|
||||
<property name="dataSource"
|
||||
ref="dataSource" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="playerSummarization"
|
||||
class="org.springframework.batch.execution.step.simple.SimpleStepConfiguration">
|
||||
<property name="commitInterval" value="100" />
|
||||
<property name="startLimit" value="100" />
|
||||
<property name="saveRestartData" value="true" />
|
||||
<property name="tasklet">
|
||||
<bean
|
||||
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
|
||||
<property name="itemProvider">
|
||||
<bean
|
||||
class="org.springframework.batch.item.provider.InputSourceItemProvider">
|
||||
<property name="inputSource"
|
||||
ref="playerSummarizationSource" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="itemProcessor">
|
||||
<bean
|
||||
class="org.springframework.batch.item.processor.OutputSourceItemProcessor">
|
||||
<property name="outputSource">
|
||||
<bean
|
||||
class="org.springframework.batch.sample.dao.SqlNflPlayerSummaryDao">
|
||||
<property name="dataSource"
|
||||
ref="dataSource" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="playerFileInputSource"
|
||||
class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource">
|
||||
<property name="resource">
|
||||
<bean
|
||||
class="org.springframework.core.io.ClassPathResource">
|
||||
<constructor-arg value="data/nfljob/input/player.csv" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="tokenizer">
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.support.transform.DelimitedLineTokenizer">
|
||||
<property name="names"
|
||||
value="ID,lastName,firstName,position,birthYear,debutYear" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="gameFileInputSource"
|
||||
class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource">
|
||||
<property name="resource">
|
||||
<bean
|
||||
class="org.springframework.core.io.ClassPathResource">
|
||||
<constructor-arg value="data/nfljob/input/games.csv" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="tokenizer">
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.support.transform.DelimitedLineTokenizer">
|
||||
<property name="names"
|
||||
value="id,year,team,week,opponent,completes,attempts,passingYards,passingTd,interceptions,rushes,rushYards,receptions,receptionYards,totalTd" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="playerSummarizationSource"
|
||||
class="org.springframework.batch.io.sql.SqlCursorInputSource">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="mapper">
|
||||
<bean
|
||||
class="org.springframework.batch.sample.mapping.NflPlayerSummaryMapper" />
|
||||
</property>
|
||||
<property name="sql">
|
||||
<value>
|
||||
SELECT games.player_id, games.year, SUM(COMPLETES),
|
||||
SUM(ATTEMPTS), SUM(PASSING_YARDS), SUM(PASSING_TD),
|
||||
SUM(INTERCEPTIONS), SUM(RUSHES), SUM(RUSH_YARDS),
|
||||
SUM(RECEPTIONS), SUM(RECEPTIONS_YARDS), SUM(TOTAL_TD)
|
||||
from games, players where players.player_id =
|
||||
games.player_id group by games.player_id, games.year
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
21
samples/src/main/resources/log4j.properties
Normal file
21
samples/src/main/resources/log4j.properties
Normal file
@@ -0,0 +1,21 @@
|
||||
### direct log messages to stdout ###
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||
|
||||
### set log levels - for more verbose logging change 'info' to 'debug' ###
|
||||
|
||||
log4j.rootLogger=info, stdout
|
||||
|
||||
### enable the following line if you want to track down connection ###
|
||||
### leakages when using DriverManagerConnectionProvider ###
|
||||
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
|
||||
|
||||
### enable spring
|
||||
log4j.logger.org.springframework=error
|
||||
log4j.logger.org.springframework.batch.sample=info
|
||||
|
||||
### debug your specific package or classes with the following example
|
||||
log4j.logger.org.springframework.batch.sample.module.OrderDataProvider=debug
|
||||
log4j.logger.org.springframework.batch.container.common.module.process.support.DefaultXmlDataProvider=debug
|
||||
@@ -23,6 +23,7 @@ import java.sql.SQLException;
|
||||
|
||||
import org.springframework.batch.io.file.FieldSet;
|
||||
import org.springframework.batch.io.file.FieldSetInputSource;
|
||||
import org.springframework.batch.item.ResourceLifecycle;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.jdbc.core.JdbcOperations;
|
||||
import org.springframework.jdbc.core.RowCallbackHandler;
|
||||
@@ -51,7 +52,7 @@ public class FixedLengthImportJobFunctionalTests extends AbstractLifecycleSpring
|
||||
*/
|
||||
protected void validatePostConditions() {
|
||||
|
||||
inputSource.open();
|
||||
((ResourceLifecycle) inputSource).open();
|
||||
|
||||
jdbcTemplate.query("SELECT ID, ISIN, QUANTITY, PRICE, CUSTOMER FROM trade ORDER BY id", new RowCallbackHandler() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user