Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
I have some Spring Java config files I'm looking at. The main configuration file is
The WebConfig.java file is:
The DataConfig.java file is:
and the RootConfig.java file is:
Could someone explain the RootConfig.java file to me, specifically what the static class WebPackage is doing. I know RegexPatternTypeFilter is used to set up a simple filter for matching on a regex expression, but what is happening here when this class is just created and it's .match(...) method is not being obviously called anywhwere? Thanks in advance.
If the code is from a book (like Spring In Action), I think you should quote that it is so, to be fair to the book owners.
Anyway, the @ComponentScan have the excludeFilters, and excludeFilters uses that WebPackage.class.
WebPackage is a custom filter.
Basically anything that matches below, is excluded from the component scanning.
Hi John,
Yes, this is from Spring In Action Volume 4. What you say makes sense. The version I quoted is from the downloadable source code. The version of this file printed in the text does the same thing, only without the WebPackage class definition, it just uses an excludeFilter definition based on annotation and class. When I substituted that file for the one in the download, things still worked fine. I guess when you component scan for the root config you have to be sure not to include any definitions in the DispatcherServlet config. Thanks much John.
The root config thing is shared by all lower configs. I mean, the root application context created from it, is inherited by all application contexts in the application.
There is only 1 root application context in the application. You usually put there only stuff that is used in entire application.
The web stuff is not used in entire application but by the web stuff only (like web layer, controllers; but not used for example by JMS layer services). That is why the coder of that sample code, excluded it from the root context, which is inherited by all lower contexts.
In the WebConfig in the sample code, that spitter.web is component-scanned in it, and therefore beans in the spitter.web are registered in the web application context.
All this magic starts at below:
Replace the word "snake" with "danger noodle" in all tiny ads.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth