001    package hirondelle.web4j.request;
002    
003    import java.util.TimeZone;
004    import javax.servlet.http.HttpServletRequest;
005    
006    import hirondelle.web4j.util.WebUtil;
007    import hirondelle.web4j.Controller;
008    
009    /**
010     Retrieve the {@link TimeZone} stored in any scope under the key 
011     {@link hirondelle.web4j.Controller#TIME_ZONE}.
012     
013     <P>Upon startup, the {@link hirondelle.web4j.Controller} will read in the <tt>DefaultUserTimeZone</tt>
014     configured in <tt>web.xml</tt>, and place it in application scope under the key 
015     {@link hirondelle.web4j.Controller#TIME_ZONE}, as a {@link TimeZone} object.
016     
017     <P><em>If desired</em>, the application programmer can also store a user-specific 
018     {@link TimeZone} in session scope, <em>under the same key</em>. Thus, 
019     this class will first find the user-specific <tt>TimeZone</tt>, overriding the default 
020     <tt>TimeZone</tt> stored in application scope. 
021     
022     <P>If any other behavior is desired, then simply provide an alternate implementation of 
023     {@link TimeZoneSource}.
024    */
025    public final class TimeZoneSourceImpl implements TimeZoneSource {
026    
027      /** See class comment. */
028      public TimeZone get(HttpServletRequest aRequest){
029        return (TimeZone)WebUtil.findAttribute(Controller.TIME_ZONE, aRequest);
030      }
031      
032    }