Java Reference
In-Depth Information
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Batch Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
From the beginning of the web.xml file shown in Listing 6-21, you have the display name and
description for your application. After that, you configure the location of the base Spring context
configuration. In this case, you're using one that is included in the spring-batch-admin-resources-
1.2.0.RELEASE jar file, webapp-config.xml . This file contains the beans required for Spring Batch Admin
to run and also provides a facility for you to override and extend any of the components you wish.
The next two elements, which configure hiddenHttpMethodFilter , are used as a workaround for
browsers that don't support all of the standard HTTP methods. 2 Because Spring Batch Admin exposes a
number of features via a RESTful API, it uses this filter to support a common technique for indicating the
HTTP method being invoked via a request header.
You configure ContextLoaderListener next to bootstrap Spring as in any normal Spring-based web
application. Finally, you have the servlet that does the heavy lifting for the Spring Batch Admin
application. As with most Spring-based web applications, you use
org.springframework.web.servlet.DispatcherServlet to direct requests to beans as configured. In this
case, Spring Batch Admin comes with a configuration (again found in the spring-batch-admin-resources
-1.2.0.RELEASE.jar ) servlet-config.xml that contains the required mappings.
The last piece of the Spring Batch Admin puzzle is to move launch-context.xml . You may be
wondering why you need to move it. The reason is that the Spring Batch Admin application has an
embedded configuration for a number of beans that you've already configured by default ( JobExplorer ,
JobRepository , a datasource, and so on). However, it also provides you the ability to override those
configurations by placing the overriding configurations in the <WAR_ROOT>/META-
INF/spring/batch/override directory of your war file. In this case, the easy way to handle the overrides
you want is to move launch-context.xml from the <PROJECT_ROOT>/src/main/resources directory to the
<PROJECT_ROOT>/src/main/resources/META-INF/spring/batch/override directory. When Spring Batch
Admin launches, it uses your configurations over the defaults provided.
All that is left is to build your war file and deploy it to Tomcat just as you did previously. Using the
mvn clean install command, you end up with a war file that you can drop into Tomcat's webapps
directory and start Tomcat. With Tomcat running, fire up a browser and navigate to
http://localhost:8080/deleteFiles to see the administration application as shown in Figure 6-2.
2 Most modern browsers only support HTTP POST and GET , but true RESTful implementations require the
support of PUT and DELETE as well.
 
Search WWH ::




Custom Search