Java Reference
In-Depth Information
(POM) in this project is preconfigured to create a jar file, with CommandLineJobRunner defined as the main
class by default. For this example, you update the POM to use the Batch class from Listing 5-11 as the
main method for your jar. Listing 5-14 shows the snippet that needs to be updated.
Listing 5-14. Maven Jar Plug-in Configured to Run Batch
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<index>false</index>
<manifest>
<mainClass>com.apress.springbatch.chapter5.Batch</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestFile>
${project.build.outputDirectory}/META-INF/MANIFEST.MF
</manifestFile>
</archive>
</configuration>
</plugin>
With the POM updated, you can use the same command you have in the past to launch the
program: java -jar metadata-0.0.1-SNAPSHOT.jar.
Notice that when you run the program, the output is quite different. This time, no job runs. Instead,
you see Spring bootstrap and register the job helloWorldJob from the helloWorld.xml file, as shown in
Listing 5-16.
Listing 5-16. The registration of the helloWorld job.
2010-12-16 21:17:41,390 DEBUG com.apress.springbatch.chapter5.Batch.main()
[org.springframework.batch.core.configuration.support.DefaultJobLoader] - <Registering job:
helloWorldJob1 from context: file:/Users/mminella/Documents/SpringBatch/Chapter5/batch-
test/target/classes/jobs/helloWorld.xml>
With the Batch process running, you view the beans exposed via JMX using Java's JConsole.
JConsole is a free Java monitoring and management tool provided with the JDK. It allows you to monitor
the JVM in a number of ways, including CPU utilization and memory allocation, and it lets you perform
management tasks including interacting with JMX beans. When you launch JConsole, you're presented
with a screen that asks you which Java process you would like to connect to, as shown in Figure 5-2.
 
 
Search WWH ::




Custom Search