Source Code Cross Referenced for VirtualHostFrame.java in  » Web-Server » Jigsaw » org » w3c » jigsaw » frames » 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.frames 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // VirtualHostFrame.java
002:        // $Id: VirtualHostFrame.java,v 1.13 2000/09/05 17:06:49 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1998.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigsaw.frames;
007:
008:        import org.w3c.tools.resources.Attribute;
009:        import org.w3c.tools.resources.AttributeRegistry;
010:        import org.w3c.tools.resources.StringAttribute;
011:        import org.w3c.tools.resources.ContainerResource;
012:        import org.w3c.tools.resources.FramedResource;
013:        import org.w3c.tools.resources.InvalidResourceException;
014:        import org.w3c.tools.resources.LookupResult;
015:        import org.w3c.tools.resources.LookupState;
016:        import org.w3c.tools.resources.ProtocolException;
017:        import org.w3c.tools.resources.ResourceReference;
018:        import org.w3c.jigsaw.http.Request;
019:
020:        /**
021:         * For Virtual Hosting.
022:         */
023:        public class VirtualHostFrame extends HTTPFrame {
024:
025:            /**
026:             * Attribute index - The default root (for unknown hosts)
027:             */
028:            protected static int ATTR_FOLLOWUP = -1;
029:
030:            static {
031:                Class c = null;
032:                Attribute a = null;
033:
034:                try {
035:                    c = Class.forName("org.w3c.jigsaw.frames.VirtualHostFrame");
036:                } catch (Exception ex) {
037:                    ex.printStackTrace();
038:                    System.exit(1);
039:                }
040:                // Register our default root:
041:                a = new StringAttribute("followup", null, Attribute.EDITABLE);
042:                ATTR_FOLLOWUP = AttributeRegistry.registerAttribute(c, a);
043:            }
044:
045:            protected ResourceReference followup = null;
046:
047:            /**
048:             * Get the name of the resource used as a followup.
049:             * @return A String giving the name of the resource to be used as the
050:             * default.
051:             */
052:
053:            public String getFollowup() {
054:                return getString(ATTR_FOLLOWUP, null);
055:            }
056:
057:            public void registerResource(FramedResource resource) {
058:                super .registerOtherResource(resource);
059:            }
060:
061:            /**
062:             * Lookup the followup resource.
063:             * @return The loaded resource for the current followup.
064:             */
065:
066:            public synchronized ResourceReference lookupFollowup() {
067:                if (followup == null) {
068:                    String name = getFollowup();
069:                    if (name != null) {
070:                        followup = getServer().loadRoot(name);
071:                    }
072:                    if (followup == null) {
073:                        getServer().errlog(
074:                                getIdentifier() + "[" + getClass().getName()
075:                                        + "]: " + "unable to restore \"" + name
076:                                        + "\" " + " from root store.");
077:                    }
078:                }
079:                return followup;
080:            }
081:
082:            /**
083:             * Lookup the target resource when associated with an unknown resource.
084:             * @param ls The current lookup state
085:             * @param lr The result
086:             * @return true if lookup is done.
087:             * @exception ProtocolException If an error relative to the protocol occurs
088:             */
089:            protected boolean lookupOther(LookupState ls, LookupResult lr)
090:                    throws ProtocolException {
091:                // Try to lookup on the host header:
092:                ResourceReference vrroot = null;
093:                ContainerResource root = null;
094:
095:                root = (ContainerResource) getResource();
096:                Request r = (Request) ls.getRequest();
097:                if (r != null) {
098:                    String host = r.getURL().getHost();
099:                    String protocol = r.getURL().getProtocol();
100:                    if (host == null) {
101:                        host = r.getHost();
102:                        if (host != null) {
103:                            // must strip the port if different from 80!
104:                            if (host.endsWith(":80") && protocol.equals("http")) {
105:                                host = host.substring(0, host
106:                                        .lastIndexOf(":80"));
107:                            }
108:                            // and the same for https (443)
109:                            if (host.endsWith(":443")
110:                                    && protocol.equals("https")) {
111:                                host = host.substring(0, host
112:                                        .lastIndexOf(":443"));
113:                            }
114:                        }
115:                    } else {
116:                        int port = r.getURL().getPort();
117:                        if (port != -1) {
118:                            if ((protocol.equals("http") && (port != 80))
119:                                    || (protocol.equals("https") && (port != 443))) {
120:                                host = host + ":" + port;
121:                            }
122:                        }
123:                    }
124:                    if (host != null) {
125:                        vrroot = root.lookup(host.toLowerCase());
126:                    }
127:                }
128:                if (vrroot == null) {
129:                    vrroot = lookupFollowup();
130:                }
131:                // Check for what we got:
132:                if (vrroot == null) {
133:                    return super .lookupOther(ls, lr);
134:                }
135:                try {
136:                    lr.setTarget(vrroot);
137:                    FramedResource resource = (FramedResource) vrroot.lock();
138:                    boolean done = (resource != null) ? resource.lookup(ls, lr)
139:                            : false;
140:                    if (!done) {
141:                        lr.setTarget(null);
142:                    }
143:                    // because the vroot eats the lookup state components
144:                    // we have to return true.
145:                    // Should not be continued by the caller.
146:                    return true;
147:                } catch (InvalidResourceException ex) {
148:                    return false;
149:                } finally {
150:                    vrroot.unlock();
151:                }
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.