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


java.lang.Object
   sunlabs.brazil.filter.FilterHandler

FilterHandler
public class FilterHandler implements Handler(Code)
The FilterHandler captures the output of some Handler and then applies an number of sunlabs.brazil.filter.Filter Filters to change that output before it is returned to the client.

This handler provides one of the core services now associated with the Brazil Server: the ability to dynamically rewrite web content obtained from an arbitrary source.

For instance, the FilterHandler can be used as a proxy for a PDA. The wrapped Handler would go to the web to obtain the requested pages on behalf of the PDA. Then, a Filter would examine all "text/html" pages and rewrite the pages so they fit into the PDA's 200 pixel wide screen. Another Filter would examine all requested images and dynamically dither them to reduce the wireless bandwidth consumed by the PDA.

The following configuration parameters are used to initialize this Handler:

prefix
Only URLs beginning with this string will be candidates for filtering. The default is "/".
handler
The name of the Handler whose output will be captured and then filtered. This is called the "wrapped handler".
filters
A list of Filter names. The filters are applied in the specified order to the output of the wrapped handler.
exitOnError
If set, the server's initFailure will set any of the filters fail to initialize. No handler prefix is required.
A sample set of configuration parameters illustrating how to use this handler follows:
 handler=filter
 port=8081
 filter.class=sunlabs.brazil.filter.FilterHandler
 filter.handler=proxy
 filter.filters=noimg
 proxy.class=sunlabs.brazil.proxy.ProxyHandler
 noimg.class=sunlabs.brazil.filter.TemplateFilter
 noimg.template=sunlabs.brazil.template.NoImageTemplate
 
These parameters set up a proxy server running on port 8081. As with a normal proxy, this proxy server forwards all HTTP requests to the target machine, but it then examines all HTML pages before they are returned to the client and strips out all <img> tags. By applying different filters, the developer could instead build a server
  • to automatically dither embedded images down to grayscale (instead of simply stripping them all out)
  • to apply pattern recognition techniques to strip out only the advertisements
  • to examine and change arbitrary URLs on the page
  • to extract the content from an HTML page and dynamically combine it with another file to produce a different look-and-feel.

author:
   Stephen Uhler (stephen.uhler@sun.com)
author:
   Colin Stevens (colin.stevens@sun.com)
version:
   1.17 01/01/14


Field Summary
public  Filter[]filters
    
public  Handlerhandler
    
 Stringprefix
    
 StringurlPrefix
    


Method Summary
public  booleaninit(Server server, String prefix)
     Start the handler and filter classes.
public  booleanrespond(Request request)
     Responds to an HTTP request by the forwarding the request to the wrapped Handler and filtering the output of that Handler before sending the output to the client.

At several stages, the Filters are given a chance to short-circuit this process:

  • Each Filter is given a chance to examine the request before it is sent to the Handler.

Field Detail
filters
public Filter[] filters(Code)



handler
public Handler handler(Code)



prefix
String prefix(Code)



urlPrefix
String urlPrefix(Code)





Method Detail
init
public boolean init(Server server, String prefix)(Code)
Start the handler and filter classes.



respond
public boolean respond(Request request) throws IOException(Code)
Responds to an HTTP request by the forwarding the request to the wrapped Handler and filtering the output of that Handler before sending the output to the client.

At several stages, the Filters are given a chance to short-circuit this process:

  • Each Filter is given a chance to examine the request before it is sent to the Handler. The Filter may decide to change the request's properties. A Filter may even return some content to the client now, in which case, neither the Handler nor any further Filters are invoked at all.
  • After the Handler has generated the response headers, but before it has generated any content, each Filter is asked if it would be interested in filtering the content. If no Filter is, then the subsequent content from the Handler will be sent directly to the client.
  • On the other hand, if any Filter is interested in filtering the content, then the output of the Handler will be sent to each of the interested Filters in order. The output of each interested Filter is sent to the next one; the output of the final Filter is sent to the client. At this point, any one of the invoked Filters can decide to reject the content completely, instead of rewriting it.

Parameters:
  request - The HTTP request to be forwarded to one of the sub-servers. true if the request was handled and contentwas generated, false otherwise.
throws:
  IOException - if there was an I/O error while sending the response tothe client.



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.