comparison 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
comparison
equal deleted inserted replaced
7:fe6a64545552 8:65ff6fcfee0c
1 /**
2 *
3 */
4 package de.intevation.gnv.action.sessionmodel;
5
6 import javax.servlet.http.HttpServletRequest;
7
8 import org.apache.log4j.Logger;
9
10 import de.intevation.gnv.artifactdatabase.client.DefaultArtifactDatabaseClient;
11
12 /**
13 * @author Tim Englich <tim.englich@intevation.de>
14 *
15 */
16 public class SessionModelFactory {
17
18 public final static String SESSION_MODEL_ID = "de.intevation.gnv.action.sessionmodel.SessionModel.ID";
19 /**
20 * the logger, used to log exceptions and additonaly information
21 */
22 private static Logger log = Logger.getLogger(SessionModelFactory.class);
23
24
25 /**
26 * The singleton Instance of this Factory.
27 */
28 private static SessionModelFactory instance = null;
29
30 /**
31 * Constructor
32 */
33 private SessionModelFactory() {
34 super();
35 }
36
37 /**
38 * This Method provides an singleton Instance of this Class.
39 * @return an singleton Instance of this Class
40 */
41 public static SessionModelFactory getInstance(){
42 if (instance == null){
43 instance = new SessionModelFactory();
44 }
45 return instance;
46 }
47
48
49 /**
50 * Getting the ArtifactDatabaseClient
51 * @return the ArtifactDatabaseClient
52 */
53 public SessionModel getSessionModel(HttpServletRequest request){
54 synchronized (this.getClass()) {
55 SessionModel sm = null;
56 if (request.getSession().getAttribute(SESSION_MODEL_ID)!= null){
57 sm = (SessionModel)request.getSession().getAttribute(SESSION_MODEL_ID);
58 ;
59 }else{
60 sm = new DefaultSessionModel();
61 request.getSession().setAttribute(SESSION_MODEL_ID, sm);
62 }
63
64 return sm;
65 }
66 }
67
68 }

http://dive4elements.wald.intevation.org