HISPACTA Hell

Monday, July 27, 2009

Spring load order: applicationContext vs. dispatcher-servlet

I've forgotten this more times that I care to admit, so let me just write it down in my own words to get it to sink in:

* an applicationContext.xml is "global" for all beans except for BeanFactoryPostProcessor / BeanPostProcessor (s) - like “PropertyPlaceholderConfigurer” for example. These guys apply ONLY to beans in its own context.

* each servlet defined by a dispatcher-servlet.xml represents a child application context that inherits the beans from the parent (root) app context.

Here...this guy says it better than I do:

http://blog.dotkam.com/2008/07/09/spring-web-application-context-visibility/

Thursday, July 09, 2009

Command line find & replace

Thanks to http://schestowitz.com/Software/Search_and_Replace/, I re-remebered how to find and replace across a suite of files (either recursively or just within a directory).


find . -maxdepth 1 -type f -name '*.html' -print |
while read filename
do
(
sed 's/old/new/i;' $filename >$filename.xxxxx
mv $filename.xxxxx $filename # replace output files with original
)
done


You can rock it with just an "ls" instead of a "find", etc.

So for example I help Anh out by changing a ton of YAML test case definition files that needed updating after a big schema change:

ls |
while read filename;
do (
sed 's/pdf_document/document_path/g;' $filename >$filename.xxx;
mv $filename.xxx $filename;
)
done