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