Java Doc for MultiHostHandler.java in  » Web-Server » Brazil » sunlabs » brazil » server » 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 » Brazil » sunlabs.brazil.server 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   sunlabs.brazil.server.MultiHostHandler

MultiHostHandler
public class MultiHostHandler implements Handler(Code)
The MultiHostHandler allows the user to handle a set of host names that are all running on the same IP address. This handler looks at the "Host:" and redispatches the request to the appropriate sub-server.

Only the main server is actually listening to the port on the specified IP address. The sub-servers are not running in separate threads. Indeed, they are not "running" at all. They exist merely as a convenient bag to hold each of the server-specific configuration parameters.

The respond method of the main handler for the appropriate sub-server is called directly from the respond method of this handler.

This handler uses the following configuration parameters:

servers
The list of prefixes for the other servers. Each server will be initialized from the main server.props with the specified prefix. In this way, the configuration parameters for all the sub-servers can be stored in the same Properties object.
prefix.host
Each server is started with a given prefix. The property prefix.host specifies the virtual hostname that the server will be expected to handle. If this property is not specified, the server's virtual hostname will just be prefix.
prefix.handler
The main handler for the server with the given prefix. If this property is not specified, it defaults to the FileHandler.
prefix.log
The log level for the server with the given prefix. If this property is not specified, it defaults to the log level of the parent server.
A sample set of configuration parameters illustrating how to use this handler follows:
 handler=host
 port=8081
 log=5
 host.class=sunlabs.brazil.server.MultiHostHandler
 host.servers=mars jupiter saturn
 mars.host=www.mars.com
 mars.log=2
 mars.handler=mars.file
 mars.file.class=sunlabs.brazil.server.FileHandler
 mars.file.root=public_html/mars
 jupiter.host=jupiter.planet.org
 jupiter.handler=sunlabs.brazil.server.FileHandler
 jupiter.root=public_html/jupiter
 saturn.host=saturn.planet.org
 saturn.handler=sunlabs.brazil.server.FileHandler
 saturn.root=public_html/saturn
 
These parameters set up a normal Server on port 8081, running a MultiHostHandler. The MultiHostHandler will create three additional servers that respond to the virtual hosts "www.mars.com", "jupiter.planet.org", and "saturn.planet.org". The "mars" server will have a Server.prefix of "mars", so that all other configuration parameters that the "mars" server examines can begin with "mars" and be kept distinct from the "jupiter" and "saturn" parameters.

In fact, the main server and the three sub-servers will all share the same properties object, but can use their own individual prefixes to keep their data separate.

NOTE: This handler is in the Server package because it depends on implementation details of the Server and Request classes, not because it represents essential or "core" functionallity.
author:
   Colin Stevens (colin.stevens@sun.com)
version:
   1.5, 00/12/11





Method Summary
public  booleaninit(Server server, String prefix)
     Initializes the servers for the virtual hosts.
public  booleanrespond(Request request)
     Responds to an HTTP request by examining the "Host:" request header and dispatching to the main handler of the server that handles that virtual host.



Method Detail
init
public boolean init(Server server, String prefix)(Code)
Initializes the servers for the virtual hosts. After creating and initializing each sub-server, the init method of the main handler for each sub-server is called.
Parameters:
  server - The HTTP server that created this handler.
Parameters:
  prefix - A prefix to prepend to all of the keys that thishandler uses to extract configuration information. true if at least one sub-server was found andcould be initialized, false otherwise.Diagnostic messages are logged for each sub-server started.



respond
public boolean respond(Request request) throws IOException(Code)
Responds to an HTTP request by examining the "Host:" request header and dispatching to the main handler of the server that handles that virtual host. If the "Host:" request header was not specified, or named a virtual host that was not initialized in init from the list of virtual hosts, this method returns without handling the request.
Parameters:
  request - The HTTP request to be forwarded to one of the sub-servers. true if the sub-server handled the message,false if it did not. false isalso returned if the "Host:" was unspecified or unknown.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.