img
<!-- Enable JSR-303 Bean Validation API -->
<bean id="validator" class="org.springframework.validation.beanvalidation
.LocalValidatorFactoryBean"/>
<!-- List of words to be replaced by Obscenities Filter -->
<util:list id="obscenities">
<value>crap</value>
</util:list>
</beans>
In Listing 21-7, the LTW-related configuration is highlighted in bold. First, the <aop:aspectj-
autoproxy> tag instructs Spring to support AspectJ-style AOP configuration and to create Spring-based
AOP proxies behind the scene. Second, the <context:load-time-weaver> tag enables the LTW feature of
the Spring Framework for weaving the classes with a special class loader.
Then, we need to copy the Spring Framework's instrument support of the Tomcat class loader to the
web container's library folder. For Tomcat, the file name is org.springframework.instrument.tomcat-
3.1.0.RELEASE.jar; it can be found either in the download package of the Spring Framework or at
Maven Central. Obtain the library and copy it to the lib folder of the Tomcat server. For example, on my
PC, Tomcat is located at C:\apache-tomcat-7.0.25, so I will copy the JAR file into the folder C:\apache-
tomcat-7.0.25\lib.
One bit of good news for STS users is that for tc Server, the library will be there as you create new tc
Server instances. Figure 21-17 shows the folder for the tc Server instance called springblog, which was
created for deploying the sample application.
Figure 21-17. The Spring LTW library for Tomcat
Next, we need to provide information to Tomcat about the LTW mechanism we will use in the
SpringBlog application. We can either do it in the tc Server's configuration or create related
configuration files within the SpringBlog project. In the sample application, we created the related
configuration files in the project so that we don't need to modify the server's configuration.
In the folder /src/main/webapp/META-INF, you will see the files context.xml and aop.xml, with the
content shown in Listings 21-8 and 21-9, respectively.
Listing 21-8. The context.xml File
<Context path="/springblog">
<Loader
loaderClass="org.springframework.instrument.classloading.tomcat
.TomcatInstrumentableClassLoader"
useSystemClassLoaderAsParent="false" />
</Context>
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home