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


java.lang.Object
   sunlabs.brazil.handler.DynamicConfigHandler

DynamicConfigHandler
public class DynamicConfigHandler implements Handler(Code)
The DynamicConfigHandler allows the user to change the configuration of the server and its handlers on the fly. This handler can therefore be used to swap in and out functionality, for example, by dynamically adding a new AuthHandler to add a new form of authentication to a running server.

This handler uses a special set of URLs to allow a new set of configuration properties to be uploaded. The new configuration replaces the old configuration.

The name of another Handler is supplied when this DynamicConfigHandler is initialized. This Handler is the helper or sub-handler for the DynamicConfigHandler. When the DynamicConfigHandler receives a regular HTTP request (that matches the URL prefix described below), it redirects that request to the respond method of the sub-handler.

The uploaded configuration properties are kept in a separate properties object from the server's properties. The server's properties are in fact not accessible from the sub-handler; the sub-handler can only access and/or change the properties owned by the DynamicConfigHandler.

This handler uses the following configuration properties:

handler
The name of the initial sub-handler that this DynamicConfigHandler will use to process requests. When new properties are uploaded, the sub-handler will be replaced with whatever is specified in the newly uploaded handler property.
prefix
Only URLs beginning with this string will be redirected to the sub-handler. This property belongs to the DynamicConfigHandler and is not changed when new properties are uploaded. The default is "/".
config
URLs beginning with this prefix can be used to upload or download new configuration properties to this handler, which will also dynamically change which sub-handler is installed. This property belongs to the DynamicConfigHandler and is not changed when new properties are uploaded. The default is "/config/".

Properties may be uploaded by sending them as "name=value" pairs in the body of a POST or in the "?" query parameters. The URL for uploading properties is "config/set".

The current set of properties may be retrieved from this handler by sending the URL "config/get"

A sample set of configuration parameters illustrating how to use this handler follows:
 handler=sunlabs.brazil.server.ChainHandler
 port=8081
 log=5
 handlers=dyn cgi
 dyn.class=sunlabs.brazil.server.DynamicConfigHandler
 dyn.prefix=/sparky/
 dyn.config=/config-sparky/
 dyn.handler=chain
 chain.class=sunlabs.brazil.server.ChainHandler
 chain.handlers=foo baz garply
 foo.class=sunlabs.brazil.handler.HomeDirHandler
 foo.home=/home/users/
 baz.class=sunlabs.brazil.handler.FileHandler
 garply.class=sunlabs.brazil.handler.NotFoundHandler
 garply.root="/errors/"
 garply.fileName="nofile.html"
 cgi.class = sunlabs.brazil.handler.CgiHandler
 .
 .
 .
 
These parameters set up a normal Server on port 8081, running a ChainHandler which dispatches to a DynamicConfigHandler and a CgiHandler.

The DynamicConfigHandler will listen for HTTP requests beginning with "/sparky/" and dispatch to its dynamically generated list of handlers, and listen for requests beginning with "/config-sparky/" to dynamically change that set of handlers.

To give this DynamicConfigHandler something to do, an initial set of handlers is provided with the same prefix ("dyn") as the DynamicConfigHandler itself. The prefix is stripped off those properties and the revised set of properties is passed to the DynamicConfigHandler to initialize its dynamically configurable world.
author:
   Colin Stevens (colin.stevens@sun.com)
version:
   1.5, 00/12/11



Field Summary
 StringconfigPrefix
    
 Handlerhandler
    
 Stringname
    
 Stringprefix
    
 Propertiesprops
    
 Serverserver
    
 StringurlPrefix
    


Method Summary
public  booleaninit(Server server, String prefix)
     Initializes this DynamicConfigHandler by loading the initial handler.
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.

Field Detail
configPrefix
String configPrefix(Code)



handler
Handler handler(Code)



name
String name(Code)



prefix
String prefix(Code)



props
Properties props(Code)



server
Server server(Code)



urlPrefix
String urlPrefix(Code)





Method Detail
init
public boolean init(Server server, String prefix)(Code)
Initializes this DynamicConfigHandler by loading the initial handler. An initial handler does not need to be defined, however, since the handler configuration can be downloaded later.
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. false if the initial handler was specified butcould not be initialized, true otherwise.



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.