Annotation of java/classes/org/w3c/jigsaw/servlet/ServletDirectoryFrame.java, revision 1.5

1.1       bmahe       1: // ServletDirectoryFrame.java
1.5     ! bmahe       2: // $Id: ServletDirectoryFrame.java,v 1.4 1998/05/25 15:08:05 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:   }
1.5     ! bmahe      63: 
        !            64:     /**
        !            65:      * ServletContext implementation - Enumerate all servlets names
        !            66:      * within context.
        !            67:      */
        !            68: 
        !            69:     public Enumeration getServletNames() {
        !            70:        if (dresource != null)
        !            71:            return new ServletNamesEnumeration(this, 
        !            72:                               dresource.enumerateResourceIdentifiers());
        !            73:        else
        !            74:            return new ServletNamesEnumeration(this, null);
        !            75:     }
1.1       bmahe      76: 
                     77:   /**
                     78:    * ServletContext implementation - Get server informations.
                     79:    */
                     80: 
                     81:   public String getServerInfo() {
                     82:     return resource.getServer().getSoftware();
                     83:   }
                     84: 
                     85:   /**
                     86:    * ServletContext implementation - Get an attribute value.
                     87:    * We map this into the ServletWrapper attributes, without
                     88:    * support for name clashes though.
                     89:    * @param name The attribute name.
                     90:    */
                     91: 
                     92:   public Object getAttribute(String name) {
                     93:     if ( definesAttribute(name) )
                     94:       return getValue(name, null);
                     95:     else if (resource.definesAttribute(name))
                     96:       return resource.getValue(name, null);
                     97:     return null;
                     98:   }
                     99: 
                    100:   /**
                    101:    * We add a <em>context</em> attribute to all our children.
                    102:    * The <em>context</em> attribute is any object implementing the
                    103:    * ServletContext interface.
                    104:    */
                    105: 
                    106:   protected void updateDefaultChildAttributes(Hashtable attrs) {
1.3       bmahe     107:       attrs.put("servlet-context", 
                    108:                new JigsawServletContext(getFrameReference()));
1.1       bmahe     109:   }
                    110: 
                    111: }

Webmaster