Annotation of java/classes/org/w3c/jigsaw/servlet/ServletProps.java, revision 1.12
1.1 bmahe 1: // ServletProps.java
1.12 ! ylafon 2: // $Id: ServletProps.java,v 1.11 2007/02/11 10:50:01 ylafon Exp $
1.1 bmahe 3: // (c) COPYRIGHT MIT and INRIA, 1998.
4: // Please first read the full copyright statement in file COPYRIGHT.html
5: package org.w3c.jigsaw.servlet;
6:
1.12 ! ylafon 7: import org.w3c.jigsaw.config.PropertySet;
1.9 ylafon 8: import org.w3c.jigsaw.http.httpd;
9: import org.w3c.tools.resources.Attribute;
10: import org.w3c.tools.resources.AttributeRegistry;
11: import org.w3c.tools.resources.BooleanAttribute;
12: import org.w3c.tools.resources.FileAttribute;
13: import org.w3c.tools.resources.IntegerAttribute;
14: import org.w3c.tools.resources.LongAttribute;
15: import org.w3c.tools.resources.StringAttribute;
16:
1.1 bmahe 17: /**
1.12 ! ylafon 18: * @author Benoît Mahé (bmahe@w3.org)
! 19: * @version $Revision: 1.11 $
1.1 bmahe 20: */
21: public class ServletProps extends PropertySet {
1.12 ! ylafon 22:
1.1 bmahe 23: /**
1.3 bmahe 24: * Name of the property indicating the servlet log file.
25: * This property indicates the name of the servlet log file to use.
1.12 ! ylafon 26: * <p>This property defaults to the <code>servlets</code> file in
1.3 bmahe 27: * the server log directory.
28: */
1.12 ! ylafon 29: protected static String SERVLET_LOG_FILE_P =
! 30: "org.w3c.jigsaw.servlet.servlet-log-file";
1.3 bmahe 31:
32: /**
33: * Name of the property indicating the max number of session loaded
34: * in memory.
35: */
1.12 ! ylafon 36: protected static String SERVLET_TIMEOUT =
! 37: "org.w3c.jigsaw.servlet.timeout";
1.8 bmahe 38:
39: /**
1.12 ! ylafon 40: * Name of the property indicating the max number
1.10 ylafon 41: * for single thread model servlet instance pool size limitation, tk, 20.10.2001
42: */
1.12 ! ylafon 43: protected static String SERVLET_INSTANCEMAX =
! 44: "org.w3c.jigsaw.servlet.instancemax";
! 45:
1.10 ylafon 46: /**
1.8 bmahe 47: * Name of the property indicating the max number of session loaded
48: * in memory.
49: */
1.12 ! ylafon 50: protected static String SERVLET_MAX_SESSION =
! 51: "org.w3c.jigsaw.servlet.max-sessions";
1.3 bmahe 52:
53: /**
54: * Name of the property indicating the max idle time of session.
55: */
1.12 ! ylafon 56: protected static String SERVLET_SESSION_IDLE =
! 57: "org.w3c.jigsaw.servlet.sessions-max-idle-time";
1.3 bmahe 58:
59: /**
60: * Name of the property indicating the max idle time of session.
61: */
1.12 ! ylafon 62: protected static String SERVLET_SESSION_SWEEP =
! 63: "org.w3c.jigsaw.servlet.sessions-sweep-delay";
1.3 bmahe 64:
65: /**
1.7 bmahe 66: * Name of the property indicating the session cookie name.
67: */
1.12 ! ylafon 68: protected static String SERVLET_COOKIE_NAME =
! 69: "org.w3c.jigsaw.servlet.session.cookie.name";
1.7 bmahe 70:
71: /**
72: * The default Session Cookie name.
73: */
74: protected static String DEFAULT_COOKIE_NAME = "JIGSAW-SESSION-ID";
75:
76: /**
77: * Name of the property indicating the session cookie domain.
78: */
1.12 ! ylafon 79: protected static String SERVLET_COOKIE_DOMAIN =
! 80: "org.w3c.jigsaw.servlet.session.cookie.domain";
1.7 bmahe 81:
82: /**
83: * Name of the property indicating the session cookie maxage.
84: */
1.12 ! ylafon 85: protected static String SERVLET_COOKIE_MAXAGE =
! 86: "org.w3c.jigsaw.servlet.session.cookie.maxage";
1.7 bmahe 87:
88: /**
89: * Name of the property indicating the session cookie path.
90: */
1.12 ! ylafon 91: protected static String SERVLET_COOKIE_PATH =
! 92: "org.w3c.jigsaw.servlet.session.cookie.path";
1.7 bmahe 93:
94: /**
95: * Name of the property indicating the session cookie comment.
96: */
1.12 ! ylafon 97: protected static String SERVLET_COOKIE_COMMENT =
! 98: "org.w3c.jigsaw.servlet.session.cookie.comment";
1.7 bmahe 99:
100: /**
101: * Name of the property indicating the session cookie secure flag.
102: */
1.12 ! ylafon 103: protected static String SERVLET_COOKIE_SECURE =
! 104: "org.w3c.jigsaw.servlet.session.cookie.secure";
1.7 bmahe 105:
106: /**
1.3 bmahe 107: * Name of the servlet PropertySet.
108: */
109: protected static String SERVLET_PROPS_NAME = "Servlets";
110:
111: /**
1.1 bmahe 112: * Attribute index - The index for our servlet log file attribute.
113: */
1.12 ! ylafon 114: protected static int ATTR_SERVLET_LOG_FILE = -1;
1.1 bmahe 115:
116: /**
117: * Attribute index - The index for our servlet session max idle time.
118: */
119: protected static int ATTR_MAX_IDLE_TIME = -1;
120:
121: /**
1.8 bmahe 122: * Attribute index - The index for our servlet timeout
123: */
124: protected static int ATTR_SERVLET_TIMEOUT = -1;
125:
126: /**
1.10 ylafon 127: * Attribute index - The index for for single thread model servlet instance pool size limitation, tk, 20.10.2001
128: */
129: protected static int ATTR_SERVLET_INSTANCEMAX = -1;
1.12 ! ylafon 130:
1.10 ylafon 131: /**
1.12 ! ylafon 132: * Attribute index - The index for our servlet session max number in
1.1 bmahe 133: * memory.
134: */
135: protected static int ATTR_SESSIONS_MAX = -1;
136:
1.2 bmahe 137: /**
138: * Attribute index - The index for our servlet session sweep delay.
139: */
140: protected static int ATTR_SESSIONS_SWEEP = -1;
141:
1.7 bmahe 142: /**
143: * Attribute index - The index for our session cookie name.
144: */
145: protected static int ATTR_SESSIONS_COOKIE_NAME = -1;
146:
147: /**
148: * Attribute index - The index for our session cookie path.
149: */
150: protected static int ATTR_SESSIONS_COOKIE_PATH = -1;
151:
152: /**
153: * Attribute index - The index for our session cookie domain.
154: */
155: protected static int ATTR_SESSIONS_COOKIE_DOMAIN = -1;
156:
157: /**
158: * Attribute index - The index for our session cookie comment.
159: */
160: protected static int ATTR_SESSIONS_COOKIE_COMMENT = -1;
161:
162: /**
163: * Attribute index - The index for our session cookie maxage.
164: */
165: protected static int ATTR_SESSIONS_COOKIE_MAXAGE = -1;
166:
167: /**
168: * Attribute index - The index for our session cookie secure.
169: */
170: protected static int ATTR_SESSIONS_COOKIE_SECURE = -1;
171:
172:
1.1 bmahe 173: static {
1.12 ! ylafon 174: Class<?> cls = null;
! 175: Attribute a = null;
1.1 bmahe 176:
1.12 ! ylafon 177: try {
! 178: cls = Class.forName("org.w3c.jigsaw.servlet.ServletProps");
! 179: } catch (Exception ex) {
! 180: ex.printStackTrace();
! 181: System.exit(1);
! 182: }
! 183: // The servlet log file:
! 184: a = new FileAttribute(SERVLET_LOG_FILE_P,
! 185: null,
! 186: Attribute.EDITABLE);
! 187: ATTR_SERVLET_LOG_FILE = AttributeRegistry.registerAttribute(cls, a);
! 188: // The servlet session max idle time:
! 189: a = new LongAttribute(SERVLET_SESSION_IDLE,
! 190: new Long(1800000),
! 191: Attribute.EDITABLE);
! 192: ATTR_MAX_IDLE_TIME = AttributeRegistry.registerAttribute(cls, a);
! 193: // The servlet timeout:
! 194: a = new LongAttribute(SERVLET_TIMEOUT,
! 195: new Long(1800000),
! 196: Attribute.EDITABLE);
! 197: ATTR_SERVLET_TIMEOUT = AttributeRegistry.registerAttribute(cls, a);
! 198: // The servlet instancemax, added for single thread model servlet instance pool size limitation, tk, 20.10.2001
! 199: a = new IntegerAttribute(SERVLET_INSTANCEMAX,
! 200: new Integer(0),
! 201: Attribute.EDITABLE);
! 202: ATTR_SERVLET_INSTANCEMAX = AttributeRegistry.registerAttribute(cls, a);
! 203: // The servlet sessions max number in memory:
! 204: a = new IntegerAttribute(SERVLET_MAX_SESSION,
! 205: new Integer(1024),
! 206: Attribute.EDITABLE);
! 207: ATTR_SESSIONS_MAX = AttributeRegistry.registerAttribute(cls, a);
! 208: // The servlet sessions sweep delay:
! 209: a = new IntegerAttribute(SERVLET_SESSION_SWEEP,
! 210: new Integer(30000),
! 211: Attribute.EDITABLE);
! 212: ATTR_SESSIONS_SWEEP = AttributeRegistry.registerAttribute(cls, a);
! 213: // The session cookie name
! 214: a = new StringAttribute(SERVLET_COOKIE_NAME,
! 215: DEFAULT_COOKIE_NAME,
! 216: Attribute.EDITABLE);
! 217: ATTR_SESSIONS_COOKIE_NAME =
! 218: AttributeRegistry.registerAttribute(cls, a);
! 219: // The session cookie path
! 220: a = new StringAttribute(SERVLET_COOKIE_PATH,
! 221: "/",
! 222: Attribute.EDITABLE);
! 223: ATTR_SESSIONS_COOKIE_PATH =
! 224: AttributeRegistry.registerAttribute(cls, a);
! 225: // The session cookie domain
! 226: a = new StringAttribute(SERVLET_COOKIE_DOMAIN,
! 227: null,
! 228: Attribute.EDITABLE);
! 229: ATTR_SESSIONS_COOKIE_DOMAIN =
! 230: AttributeRegistry.registerAttribute(cls, a);
! 231: // The session cookie comment
! 232: a = new StringAttribute(SERVLET_COOKIE_COMMENT,
! 233: "Jigsaw Server Session Tracking Cookie",
! 234: Attribute.EDITABLE);
! 235: ATTR_SESSIONS_COOKIE_COMMENT =
! 236: AttributeRegistry.registerAttribute(cls, a);
! 237: // The session cookie maxage
! 238: a = new IntegerAttribute(SERVLET_COOKIE_MAXAGE,
! 239: new Integer(-1),
! 240: Attribute.EDITABLE);
! 241: ATTR_SESSIONS_COOKIE_MAXAGE =
! 242: AttributeRegistry.registerAttribute(cls, a);
! 243: // The session cookie secure flag
! 244: a = new BooleanAttribute(SERVLET_COOKIE_SECURE,
! 245: Boolean.FALSE,
! 246: Attribute.EDITABLE);
! 247: ATTR_SESSIONS_COOKIE_NAME =
! 248: AttributeRegistry.registerAttribute(cls, a);
1.1 bmahe 249: }
250:
1.4 bmahe 251: private static String title = "Servlet properties";
1.9 ylafon 252:
1.4 bmahe 253: private JigsawHttpSessionContext sessionContext = null;
254:
1.6 bmahe 255: /**
256: * Returns the max idle time for a session.
1.12 ! ylafon 257: *
1.6 bmahe 258: * @return The max idle time in milli seconds.
259: */
1.1 bmahe 260: public long getSessionsMaxIdleTime() {
1.12 ! ylafon 261: return ((Long)
! 262: getValue(ATTR_MAX_IDLE_TIME, new Long(1800000))).longValue();
1.1 bmahe 263: }
264:
1.6 bmahe 265: /**
266: * Returns the max number of session in memory.
1.12 ! ylafon 267: *
1.6 bmahe 268: * @return The max number of session.
269: */
1.1 bmahe 270: public int getMaxSessionsNumber() {
1.12 ! ylafon 271: return ((Integer)
! 272: getValue(ATTR_SESSIONS_MAX, new Integer(1024))).intValue();
1.1 bmahe 273: }
274:
1.6 bmahe 275: /**
276: * Returns the delay between two sessions idle time check.
1.12 ! ylafon 277: *
1.6 bmahe 278: * @return the delay between two sessions idle time check in milli seconds.
279: */
1.2 bmahe 280: public int getSessionsSweepDelay() {
1.12 ! ylafon 281: return ((Integer)
! 282: getValue(ATTR_SESSIONS_SWEEP, new Integer(30000))).intValue();
1.2 bmahe 283: }
284:
1.6 bmahe 285: /**
286: * Returns the session context.
1.12 ! ylafon 287: *
1.6 bmahe 288: * @return A JigsawHttpSessionContext instance.
289: */
1.1 bmahe 290: public JigsawHttpSessionContext getSessionContext() {
1.12 ! ylafon 291: if (sessionContext == null)
! 292: sessionContext = new JigsawHttpSessionContext(server, this);
! 293: return sessionContext;
1.1 bmahe 294: }
295:
296: /**
297: * Get this property set title.
1.12 ! ylafon 298: *
1.1 bmahe 299: * @return A String encoded title.
300: */
301:
302: public String getTitle() {
1.12 ! ylafon 303: return title;
1.3 bmahe 304: }
305:
306: ServletProps(httpd server) {
1.12 ! ylafon 307: super(SERVLET_PROPS_NAME, server);
1.1 bmahe 308: }
1.9 ylafon 309:
1.1 bmahe 310: }
Webmaster