Annotation of java/classes/org/w3c/jigsaw/servlet/ServletDirectoryFrame.java, revision 1.3
1.1 bmahe 1: // ServletDirectoryFrame.java
1.3 ! bmahe 2: // $Id: ServletDirectoryFrame.java,v 1.2 1998/02/09 17:03:21 bmahe Exp $
1.1 bmahe 3: // (c) COPYRIGHT MIT and INRIA, 1996.
4: // Please first read the full copyright statement in file COPYRIGHT.html
5:
6: package org.w3c.jigsaw.servlet;
7:
8: import java.io.*;
9: import java.net.*;
10: import java.util.*;
11:
12: import javax.servlet.*;
13:
14: import org.w3c.tools.resources.store.*;
15: import org.w3c.tools.resources.*;
16: import org.w3c.jigsaw.frames.*;
17:
18: /**
19: * @author Alexandre Rafalovitch <alex@access.com.au>
20: * @author Anselm Baird-Smith <abaird@w3.org>
1.3 ! bmahe 21: * @author Benoit Mahe <bmahe@w3.org>
1.1 bmahe 22: */
23:
1.3 ! bmahe 24: public class ServletDirectoryFrame extends HTTPFrame {
1.1 bmahe 25:
26: public File getDirectory() {
27: if (dresource != null)
28: return dresource.getDirectory();
29: return null;
30: }
31:
32: /**
33: * ServletContext implementation - Lookup a given servlet.
34: */
35:
36: public Servlet getServlet(String name) {
37: if (dresource != null) {
38: ResourceReference rr = dresource.lookup(name);
39: try {
40: Resource resource = rr.lock();
41: if (resource instanceof ServletWrapper)
42: return ((ServletWrapper) resource).getServlet();
43: } catch (InvalidResourceException ex) {
44: return null;
45: } finally {
46: rr.unlock();
47: }
48: }
49: return null;
50: }
51:
52: /**
53: * ServletContext implementation - Enumerate all servlets within context.
54: */
55:
56: public Enumeration getServlets() {
57: if (dresource != null)
58: return new ServletEnumeration(this,
59: dresource.enumerateResourceIdentifiers());
60: else
61: return new ServletEnumeration(this, null);
62: }
63:
64: /**
65: * ServletContext implementation - Get server informations.
66: */
67:
68: public String getServerInfo() {
69: return resource.getServer().getSoftware();
70: }
71:
72: /**
73: * ServletContext implementation - Get an attribute value.
74: * We map this into the ServletWrapper attributes, without
75: * support for name clashes though.
76: * @param name The attribute name.
77: */
78:
79: public Object getAttribute(String name) {
80: if ( definesAttribute(name) )
81: return getValue(name, null);
82: else if (resource.definesAttribute(name))
83: return resource.getValue(name, null);
84: return null;
85: }
86:
87: /**
88: * We add a <em>context</em> attribute to all our children.
89: * The <em>context</em> attribute is any object implementing the
90: * ServletContext interface.
91: */
92:
93: protected void updateDefaultChildAttributes(Hashtable attrs) {
1.3 ! bmahe 94: // attrs.put("servlet-context", this);
! 95: attrs.put("servlet-context",
! 96: new JigsawServletContext(getFrameReference()));
1.1 bmahe 97: }
98:
99: }
Webmaster