concept web controller in category spring

appears as: web controller, The web controller, web controllers
Spring Batch in Action

This is an excerpt from Manning's book Spring Batch in Action.

A job starts in response to an event. You’ll always use the JobLauncher interface and JobParameters class, but the event can come from anywhere: a system scheduler like cron that runs periodically, a script that launches a Spring Batch process, an HTTP request to a web controller that launches the job, and so on. Chapter 4 covers different scenarios to trigger the launch of your Spring Batch jobs.

Now that the repository connects the application and Spring Batch, let’s see how to leverage this information in the web controller.

Listing 11.16. Communicating the status of an import with the web controller

The web controller delegates the retrieval of the ProductImport to the repository. If everything goes well, the system sends the ProductImport object to the response-rendering mechanism. Remember that the repository throws an EmptyResultDataAccessException if there’s no import for the given ID. Such an exception triggers the exception-handling mechanism in Spring MVC, which calls the noImportFound method (annotated with @ExceptionHandler). The noImportFound method sends back a 404 (NOT FOUND) status code, following REST semantics.