org.apache.jetspeed.services.webpage
Class WebPageCache

java.lang.Object
  extended byorg.apache.jetspeed.services.webpage.WebPageCache

public class WebPageCache
extends java.lang.Object


Field Summary
static java.lang.String[] CACHEABLE_RESOURCES
          Determines if a resource is cacheable, dependent on the extension: defined in CACHEABLE_RESOURCES (gif, jpeg, jpg, png, js, css)
 
Constructor Summary
WebPageCache()
           
 
Method Summary
static byte[] getContentAndWrite(java.net.URLConnection con, ProxyRunData data)
          Retrieves the content from the proxied host for the requested.
static boolean getResourceFromCache(java.lang.String resource, long sid, java.lang.String base, java.lang.String host, ProxyRunData data)
          Given a cacheable web resource, writes the content of that resource to the servlet output stream.
static boolean isCacheableResource(java.lang.String resource)
           
static byte[] rewriteScript(java.net.URLConnection con, long sid, java.lang.String host, ProxyRunData data, java.lang.String resource, java.lang.String base)
          Retrieves the script content from the proxied host for the requested.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHEABLE_RESOURCES

public static java.lang.String[] CACHEABLE_RESOURCES
Determines if a resource is cacheable, dependent on the extension: defined in CACHEABLE_RESOURCES (gif, jpeg, jpg, png, js, css)

Constructor Detail

WebPageCache

public WebPageCache()
Method Detail

getResourceFromCache

public static boolean getResourceFromCache(java.lang.String resource,
                                           long sid,
                                           java.lang.String base,
                                           java.lang.String host,
                                           ProxyRunData data)
Given a cacheable web resource, writes the content of that resource to the servlet output stream. The first time that the resource is requested, the content is fetched from the proxied host. From then on, the resource content is served up from the cache.

Parameters:
resource - the resource that is being cached.
base - the proxied host's base URL.
host - the Proxy Server base URL.
data - the RunData for the request.
Returns:
boolean true if the resource was read from the cache, false if read from the server.

isCacheableResource

public static boolean isCacheableResource(java.lang.String resource)

getContentAndWrite

public static byte[] getContentAndWrite(java.net.URLConnection con,
                                        ProxyRunData data)
                                 throws java.io.IOException
Retrieves the content from the proxied host for the requested. Per cacheable resource, this is only called once. All further requests will return the cached content. The content is immediately written to the servlet's response output stream.

Parameters:
con - the HTTP connection to the proxied host.
Returns:
byte[] the resource content, which will be stored in the cache.
Throws:
java.io.IOException

rewriteScript

public static byte[] rewriteScript(java.net.URLConnection con,
                                   long sid,
                                   java.lang.String host,
                                   ProxyRunData data,
                                   java.lang.String resource,
                                   java.lang.String base)
                            throws java.io.IOException
Retrieves the script content from the proxied host for the requested. Per cacheable resource, this is only called once. All further requests will return the cached content. The content is first rewritten, rewriting all links found in the script back to the Proxy server. Then, the content is immediately written to the servlet's response output stream.

Parameters:
con - the HTTP connection to the proxied host.
Returns:
byte[] the resource content, which will be stored in the cache.
Throws:
java.io.IOException


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.