May 6, 2009

Stereotype Annotations Cut Down XML Configuration in Spring

nnotations have been part of the Spring Model-View-Controller (MVC) Framework since Spring 2.0. In Spring, annotations can greatly reduce the amount of XML bean configuration and wiring needed. Given the many components of the Spring MVC environment (handler mapping, controller, view resolver, and view), XML configuration can turn unwieldy in

Writing a Parameterized SQL Query in EJB 3.0

protected EntityManager manager;…String ejbqlDelete = “delete from ClientTicket p where ” + “p.closed = :paramClosed and ” + “p.department = :paramDepartment and ” + “p.ticketUserID = :paramTicketUserID and ” + “p.ticketName = :paramTicketName”;int deletedEntities = manager.createQuery(ejbqlDelete). setParameter(“paramClosed”, Boolean.TRUE). setParameter( “paramDepartment”, adminid). setParameter( “paramTicketUserID”, userID ). setParameter( “paramTicketName”, delTicket ). executeUpdate();

A Fast and Easy Way to Take an ASP.NET Application Offline

ASP .NET has a fast and easy way to take an application offline using a reserved file called App_Offline.htm. When ASP.NET services any application request, if it finds a file named App_Offline.htm in the application’s root directory, it serves the contents of that file rather than the typical response. This

Algorithm to Switch Between RGB and HSB Color Values

First, declare some types: Type RGBColor Red As Byte Green As Byte Blue As ByteEnd TypeType HSBColor Hue As Double Saturation As Double Brightness As DoubleEnd Type Next, here’s a brief pseudocode explanation of the procedure used by the RGB-to-HSB algorithm: Set a Delta variable equal to [Max(r,g,b) – Min(r,g,b)]*

Avoid Object Instantiation Within Loops

Avoid defining new objects within loop structures. Doing so hampers performance significantly, due to object creation overhead. Instead, define objects outside the loop and then use them inside the loop. Moving object definitions out of your loops can often improve loop performance by nearly 100 percent. If you want to

Cache Dynamically Generated Images for Quick Page Response

If you have an image gallery with dynamically generated thumbnails, you should make sure to tell the browser to cache the thumbnails. If you don’t, the page will download each image every time the browser visits, which stresses the CPU unnecessarily and causes the page to take longer to load.