org.apache.myfaces.component.html.util
Class StreamingResourceLoader

java.lang.Object
  extended by org.apache.myfaces.component.html.util.StreamingResourceLoader
All Implemented Interfaces:
ResourceLoader

public class StreamingResourceLoader
extends Object
implements ResourceLoader

Serve component-specific resources that MUST be embedded in the HEAD of an html page.

Currently, there is only one case where resources must be in the document head: inline CSS or links to CSS stylesheets.

When using the StreamingAddResource class, a single link is output in the document HEAD for each page which embeds the name of this class in the url. This causes the browser to make a GET request to that link url when rendering the page; the tomahawk extensions filter sees the embedded ResourceLoader class name and creates an instance of this class to handle the request.

Note that for other resources the StreamingAddResources class generates urls that embed the standard MyFacesResourceLoader url, ie this class does not handle serving of resources other than the ones that MUST be in the head section.

The url also embeds a "request id" which is unique for each page served. This id is then used as a key into a global-scoped cache. The data there was inserted during the previous request, and is deleted as soon as it is served up by this class.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.myfaces.renderkit.html.util.ResourceLoader
ResourceLoader.ClosedSocketException
 
Constructor Summary
StreamingResourceLoader()
           
 
Method Summary
 void serveResource(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String resourceUri)
          Called by AddResource to render external resource data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamingResourceLoader

public StreamingResourceLoader()
Method Detail

serveResource

public void serveResource(javax.servlet.ServletContext context,
                          javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response,
                          String resourceUri)
                   throws IOException
Description copied from interface: ResourceLoader
Called by AddResource to render external resource data

Specified by:
serveResource in interface ResourceLoader
Parameters:
context - TODO
request - the request
response - the response to write the resource content to
resourceUri - contains the uri part after the uri which is used to identify the resource loader
Throws:
IOException


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.