Idea of obtaining a session is strategized


public interface ISessionSupport
{
   public HttpSession getSession(HttpServletRequest request
                                , HttpServletResponse response)
         throws AspireServletException;

}

Obtaining an implementation


<request name="ISessionSupport">
	<classname>com.ai.servlets.HorizontalSessionSupport1</classname>
	<type>FriendSession|UserSession|AnnonymousSession|JointSession</type>
	<session-expiry-page>url</session-expiry-page>
	<expiration-timeout/>
</request>

Working with IHttpEvents

Idea of http events


public interface IHttpEvents
{
   public static String NAME="IHttpEvents";
   
   public void applicationStart() throws AspireServletException;
   
   public void applicationStop() throws AspireServletException;
   
   public void sessionStart(HttpSession session, 
   			HttpServletRequest request, 
			HttpServletResponse response) throws AspireServletException;
			
   public void sessionStop() throws AspireServletException;
   
   public void beginRequest(HttpServletRequest request, 
   			HttpServletResponse response) throws AspireServletException;
			
   public void endRequest(HttpServletRequest request, 
   				HttpServletResponse response) throws AspireServletException;
				
   public void userLogin(String username, HttpSession session, 
   			HttpServletRequest request, 
			HttpServletResponse response) throws AspireServletException;
			
   public void userChange(String oldUser, 
   			String newUser, 
			HttpSession session, 
			HttpServletRequest request, 
			HttpServletResponse response) throws AspireServletException;
}

Loading a user profile when login takes place


public class MyUserLoginEvent extends DefaultHttpEvents
{
   public void userLogin(String username,  HttpSession session, 
   		HttpServletRequest request, HttpServletResponse response)
        throws AspireServletException
   {
      AppObjects.log("Info:user loggedin event");

      Hashtable args = new Hashtable();
      args.put("aspire_session",session);
      args.put("profile_user",username);
      try
      {
         AppObjects.getObject(AspireConstants.SESSION_SUPPORT_NEW_USER_SESSION_LOADER,args);
      }
      catch(RequestExecutionException x)
      {
         throw new AspireServletException("Error:" + x.getRootCause(), x);
      }
   }//eof-function
}//eof-class

Specifying http events


<request name="IHttpEvents">
	<classname>EventDeMultiplexer</classname>
	<eventHandlers>UserLoginEventRequest</eventHandlers>
</request>

<request name="UserLoginEventRequest">
	<classname>MyUserLoginEvent</classname>
</request>

References

1. General Introduction to other Server side Patterns in this series

2. OSCON 2004 Summary page for Server side patterns session

3. Abstract Page Data Pattern: Code Examples