Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Spring Framework 2 ISBN: 978-0-470-10161-2
This is the forum to discuss the Wrox book Beginning Spring Framework 2 by Thomas Van de Velde, Bruce Snyder, Christian Dupuis, Sing Li, Anne Horton, Naveen Balani; ISBN: 9780470101612
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Spring Framework 2 ISBN: 978-0-470-10161-2 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 29th, 2009, 09:25 AM
tok tok is offline
Registered User
 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error in Chapter 12, AOP code?

I can't get the idea of the AOP example code in page 367.

Code:
public PixUser lookup(ProceedingJoinPoint call, String userName) {
  log.debug(“Advising method: ‚“ +   call.getSignature().toShortString());
  PixUser user = (PixUser) cache.get(userName);
  if (user != null) {
    user = call.proceed();
  }
  cache.put(user.getUserName());
  return user;
}
I presume the idea is first look the cache for the user object by userName and if not found there, fetch user with the target method and put it in the cache. To me it seem this code does the opposite: if the user IS FOUND in the cache (user != null) then the target method is called (call.procees()) and user is fetched from the database. And regardless of the user was in the cache or not, it is put there again.

Instead, shouldn't it be like this

Code:
  PixUser user = (PixUser) cache.get(userName);
  if (user == null) {
    user = call.proceed();
    cache.put(user.getUserName());
  }
  return user;
Or did I understand it all wrong?
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
aop source code missing ccp2p BOOK: Beginning Spring Framework 2 ISBN: 978-0-470-10161-2 0 March 7th, 2008 11:50 AM
Chapter 12 Code Behind Problem locknload7 BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 March 30th, 2005 10:34 AM
Chapter 12 code error rsteph7 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 34 August 18th, 2004 01:53 PM



All times are GMT -4. The time now is 10:44 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.