Mercurial > dive4elements > gnv-client
diff gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModelFactory.java @ 8:65ff6fcfee0c
Some Basic Stuff for WebProjects
gnv/trunk@84 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Mon, 14 Sep 2009 13:56:03 +0000 |
parents | |
children | 4405f31bbc30 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModelFactory.java Mon Sep 14 13:56:03 2009 +0000 @@ -0,0 +1,68 @@ +/** + * + */ +package de.intevation.gnv.action.sessionmodel; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.log4j.Logger; + +import de.intevation.gnv.artifactdatabase.client.DefaultArtifactDatabaseClient; + +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public class SessionModelFactory { + + public final static String SESSION_MODEL_ID = "de.intevation.gnv.action.sessionmodel.SessionModel.ID"; + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(SessionModelFactory.class); + + + /** + * The singleton Instance of this Factory. + */ + private static SessionModelFactory instance = null; + + /** + * Constructor + */ + private SessionModelFactory() { + super(); + } + + /** + * This Method provides an singleton Instance of this Class. + * @return an singleton Instance of this Class + */ + public static SessionModelFactory getInstance(){ + if (instance == null){ + instance = new SessionModelFactory(); + } + return instance; + } + + + /** + * Getting the ArtifactDatabaseClient + * @return the ArtifactDatabaseClient + */ + public SessionModel getSessionModel(HttpServletRequest request){ + synchronized (this.getClass()) { + SessionModel sm = null; + if (request.getSession().getAttribute(SESSION_MODEL_ID)!= null){ + sm = (SessionModel)request.getSession().getAttribute(SESSION_MODEL_ID); + ; + }else{ + sm = new DefaultSessionModel(); + request.getSession().setAttribute(SESSION_MODEL_ID, sm); + } + + return sm; + } + } + +}