Java Reference
In-Depth Information
There is one additional thing you need to do. This project has two artifacts: the normal jar file from
which you run jobs and a jar file that you launch for each of your slave JVMs. The only difference
between the two is the main class you use. By default, your jar files are created with the
CommandLineJobRunner defined as the main class, and this works fine for the jar file from which you
execute the job. However, in the other JVMs, you don't want to execute the job; instead, you want to
bootstrap Spring and register your listeners to be able to process any items that come their way. For this
other jar file, you create a main class that bootstraps Spring for you and then blocks so that it doesn't
shut down.
But what does this new jar file have to do with your POM file? Because the POM file specifies the
main class that your jar file is configured to execute, you want to make it more versatile for you to
generate the two jar files. To do this, you define two profiles: one for each of the two artifacts you
generate. You use these profiles to define the main class that's configured for each of the jar files you
generate. Creating these profiles consists of two steps: deleting the reference to the maven-jar-plugin in
the build section of the POM file, and then adding your profiles. One is named listener and is used to
build the jar file for your slave JVMs. The other is called batch , is the default profile, and configures the
jar file to use CommandLineJobRunner as the jar file's main class. Listing 11-25 shows the new profile
Listing 11-25. Maven Profiles Used to Generate Both Required Artifacts
Search WWH ::

Custom Search