Source Code Cross Referenced for ServletDirectoryFrame.java in  » Web-Server » Jigsaw » org » w3c » jigsaw » servlet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Jigsaw » org.w3c.jigsaw.servlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // ServletDirectoryFrame.java
002:        // $Id: ServletDirectoryFrame.java,v 1.23 2001/11/12 14:02:51 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigsaw.servlet;
007:
008:        import java.io.File;
009:        import java.net.URLStreamHandlerFactory;
010:        import java.util.Enumeration;
011:        import java.util.Hashtable;
012:
013:        import javax.servlet.Servlet;
014:        import javax.servlet.ServletContext;
015:
016:        import org.w3c.jigsaw.http.httpd;
017:        import org.w3c.util.ObservableProperties;
018:        import org.w3c.tools.resources.FramedResource;
019:        import org.w3c.tools.resources.InvalidResourceException;
020:        import org.w3c.tools.resources.Resource;
021:        import org.w3c.tools.resources.ResourceReference;
022:        import org.w3c.jigsaw.frames.HTTPFrame;
023:
024:        import javax.servlet.http.HttpSessionContext;
025:
026:        /**
027:         *  @author Alexandre Rafalovitch <alex@access.com.au>
028:         *  @author Anselm Baird-Smith <abaird@w3.org>
029:         *  @author Benoit Mahe <bmahe@w3.org>
030:         */
031:
032:        public class ServletDirectoryFrame extends HTTPFrame {
033:
034:            /**
035:             * The servlet Context.
036:             */
037:            protected ServletContext servletContext = null;
038:
039:            /**
040:             * The Session Context.
041:             */
042:            protected HttpSessionContext sessionContext = null;
043:
044:            /**
045:             * Register the resource and add ServletProperties in httpd.
046:             * @param resource The resource to register.
047:             */
048:            public void registerResource(FramedResource resource) {
049:                super .registerResource(resource);
050:                if (getServletProps() == null) {
051:                    synchronized (this .getClass()) {
052:                        httpd s = (httpd) getServer();
053:                        if (s != null) {
054:                            // Register the property sheet if not done yet:
055:                            ObservableProperties props = s.getProperties();
056:                            s.registerPropertySet(new ServletProps(s));
057:                        }
058:                    }
059:                }
060:            }
061:
062:            /**
063:             * ServletContext implementation - Lookup a given servlet.
064:             */
065:            public Servlet getServlet(String name) {
066:                if (dresource != null) {
067:                    ResourceReference rr = dresource.lookup(name);
068:                    if (rr != null) {
069:                        try {
070:                            Resource resource = rr.lock();
071:                            if (resource instanceof  ServletWrapper)
072:                                return ((ServletWrapper) resource).getServlet();
073:                        } catch (InvalidResourceException ex) {
074:                            return null;
075:                        } finally {
076:                            rr.unlock();
077:                        }
078:                    }
079:                }
080:                return null;
081:            }
082:
083:            /**
084:             * Lookup a given servlet without accessing it.
085:             * @return true if and only if loading was successful
086:             */
087:            public boolean isServletLoaded(String name) {
088:                if (dresource != null) {
089:                    ResourceReference rr = dresource.lookup(name);
090:                    if (rr != null) {
091:                        try {
092:                            Resource resource = rr.lock();
093:                            if (resource instanceof  ServletWrapper)
094:                                return ((ServletWrapper) resource)
095:                                        .isServletLoaded();
096:                        } catch (InvalidResourceException ex) {
097:                            return false;
098:                        } finally {
099:                            rr.unlock();
100:                        }
101:                    }
102:                }
103:                return false;
104:            }
105:
106:            /**
107:             * ServletContext implementation - Enumerate all servlets within context.
108:             */
109:
110:            public Enumeration getServlets() {
111:                if (dresource != null)
112:                    return new ServletEnumeration(this , dresource
113:                            .enumerateResourceIdentifiers());
114:                else
115:                    return new ServletEnumeration(this , null);
116:            }
117:
118:            /**
119:             * ServletContext implementation - Enumerate all servlets names
120:             * within context.
121:             */
122:
123:            public Enumeration getServletNames() {
124:                if (dresource != null)
125:                    return new ServletNamesEnumeration(this , dresource
126:                            .enumerateResourceIdentifiers());
127:                else
128:                    return new ServletNamesEnumeration(this , null);
129:            }
130:
131:            /**
132:             * ServletContext implementation - Get server informations.
133:             */
134:
135:            public String getServerInfo() {
136:                return getServer().getSoftware();
137:            }
138:
139:            /**
140:             * ServletContext implementation - Get an attribute value.
141:             * We map this into the ServletWrapper attributes, without
142:             * support for name clashes though.
143:             * @param name The attribute name.
144:             */
145:
146:            public Object getAttribute(String name) {
147:                if (definesAttribute(name))
148:                    return getValue(name, null);
149:                else if (resource.definesAttribute(name))
150:                    return resource.getValue(name, null);
151:                return null;
152:            }
153:
154:            protected HttpSessionContext getHttpSessionContext() {
155:                if (sessionContext == null) {
156:                    ServletProps sprops = getServletProps();
157:                    if (sprops != null)
158:                        sessionContext = sprops.getSessionContext();
159:                }
160:                return (HttpSessionContext) sessionContext;
161:            }
162:
163:            protected ServletProps getServletProps() {
164:                httpd server = (httpd) getServer();
165:                return (ServletProps) server
166:                        .getPropertySet(ServletProps.SERVLET_PROPS_NAME);
167:            }
168:
169:            protected ServletContext getServletContext() {
170:                if (servletContext == null) {
171:                    servletContext = new JigsawServletContext(
172:                            getFrameReference(), getServer().getProperties());
173:                    File tmp = new File(getServer().getTempDirectory(), String
174:                            .valueOf(resource.getURLPath().hashCode()));
175:                    tmp.mkdirs();
176:                    servletContext.setAttribute(JigsawServletContext.TEMPDIR_P,
177:                            tmp);
178:                }
179:                return (ServletContext) servletContext;
180:            }
181:
182:            /**
183:             * We add a <em>context</em> attribute to all our children.
184:             * The <em>context</em> attribute is any object implementing the
185:             * ServletContext interface.
186:             */
187:
188:            protected void updateDefaultChildAttributes(Hashtable attrs) {
189:                attrs.put("servlet-context", getServletContext());
190:                attrs.put("session-context", getHttpSessionContext());
191:            }
192:
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.