Try to do the real work in the IResource#respond() (accessing the database and retrieving the image) and make calling the constructor cheap, then you should not have any bottlenecks at all.
Am 14.12.2011 um 18:59 schrieb Bertrand Guay-Paquet: > Hi, > > I am using resource references for the first time to implement fetching > images from a DB. The URLs will be of the following form: > "/resources/dbImages/DB_ID.png" where DB_ID is an identifier to retrieve the > image from the DB. > > I'm using the article at > http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/ as a guide > and have a couple of questions. > > 1. What is the purpose of the equals() override in the class ImageResource? I > don't understand the explanation given in the article... Also, I put a > breakpoint in my own resource class' equals() method and it never hits! > > 2. Can I use part of the "resources" namespace or is that asking for trouble > since Wicket can use it however it likes? > > 3. When using getRequestCycle().urlFor(new MyResourceReference(), > imageParameters), the following happens: > at line 216 in ResourceMapper#addCachingDecoration(Url, PageParameters) : > final IResource resource = resourceReference.getResource(); > > with a comment right above that says "// TODO is calling getResource() a > potential performance bottleneck?" > > I am concerned that each time a url to my image resource reference is > created, the DB will be hit, simply for getting the Url! It will then maybe > be hit a second time afterwards if the client doesn't have the image in > cache. Am I completely off-base here? Is there another way to manage > resources so this doesn't happen? > > Thanks, > Bertrand > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org