25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 8 ■ Give Advice to Your <strong>Spring</strong> Application<br />

}<br />

}<br />

}<br />

for(Object arg:args)<br />

log.debug("@@@@(THROWS) Argument passed:" + arg);<br />

log.debug("@@@(THORWS) Error: " + ex.getMessage());<br />

Listing 8-12 shows the implementation of the afterThrowing method that has the method, the arguments of the<br />

method, the object that is being adviced, and the exception that occurred as parameters.<br />

Next, let’s modify your XML configuration file (see Listing 8-13) by adding the ThrowsLoggingModule class and<br />

making a reference to the bean on the interceptorNames within the engineProxy bean.<br />

Listing 8-13. mydocuments-aop-context.xml<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

throwsLogging<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

And again if you run the unit test (see Listing 8-5) with<br />

gradle :ch08:test<br />

you will get following output:<br />

2014-02-23 21:01:01,860 DEBUG [main] Using <strong>Spring</strong> AOP:<br />

2014-02-23 21:01:01,924 DEBUG [main] @@@(THROWS) Method called: findByLocation<br />

2014-02-23 21:01:01,924 DEBUG [main] @@@@(THROWS) Argument passed:/some/path/<br />

2014-02-23 21:01:01,924 DEBUG [main] @@@(THORWS) Error: findByLocation not yet implemented.<br />

2014-02-23 21:01:01,924 ERROR [main] findByLocation not yet implemented.<br />

103

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!