Project Wonder 2.0

er.extensions
Class ERXWOResponseCache

java.lang.Object
  extended byer.extensions.ERXWOResponseCache

public class ERXWOResponseCache
extends Object

The response cache is a way to cache WOResponse output from a DirectAction for a given set of cache keys. You can specify the headers, formValues and cookies to take into account. Your DirectAction class must implement the ERXWOResponseCache.Cacheable interface and should look like this:



 public class DirectAction extends WODirectAction implements ERXWOResponseCache.Cacheable {
    static {
        ERXWOResponseCacheKeyPolicy.sharedInstance().createPolicyEntryForClass(DirectAction.class, 
            new NSArray(new Object[] {"default", "cached"}), 
            NSArray.EmptyArray, NSArray.EmptyArray, NSArray.EmptyArray);
    }
    public DirectAction(WORequest aRequest) {
        super(aRequest);
    }

    public WOActionResults notCachedAction() {
        return pageWithName("NotCached");
    }

    public WOActionResults cachedAction() {
        return pageWithName("Cached");
    }

    public WOActionResults defaultAction() {
        return pageWithName("Main");
    }
}
You must also set the default er.extensions.ERXWOResponseCache.Enabled=true for the cache to get used.


Nested Class Summary
static interface ERXWOResponseCache.Cacheable
           
static interface ERXWOResponseCache.Policy
           
 
Field Summary
protected  Map cache
           
protected  Boolean isEnabled
           
static String NO_CACHE_KEY
          Header key you can set in the response when creating an error page you don't want to get cached.
protected  ERXWOResponseCache.Policy policy
           
protected static ERXWOResponseCache sharedInstance
          Holds a reference to the shared instance
 
Constructor Summary
ERXWOResponseCache()
           
 
Method Summary
 boolean actionNameIsCachableForClass(Class actionClass, String actionName)
           
 WOResponse cachedResponseForRequest(Class actionClass, String actionName, WORequest request)
           
 void cacheResponseForRequest(Class actionClass, String actionName, WORequest request, WOResponse response)
           
 void flushCache()
           
 boolean hasPolicy()
           
 boolean isEnabled()
           
 ERXWOResponseCache.Policy policy()
           
 void setIsEnabled(boolean enabled)
           
 void setPolicy(ERXWOResponseCache.Policy policy)
           
static ERXWOResponseCache sharedInstance()
          Gets the shared instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sharedInstance

protected static ERXWOResponseCache sharedInstance
Holds a reference to the shared instance


NO_CACHE_KEY

public static String NO_CACHE_KEY
Header key you can set in the response when creating an error page you don't want to get cached.


cache

protected Map cache

policy

protected ERXWOResponseCache.Policy policy

isEnabled

protected Boolean isEnabled
Constructor Detail

ERXWOResponseCache

public ERXWOResponseCache()
Method Detail

sharedInstance

public static ERXWOResponseCache sharedInstance()
Gets the shared instance

Returns:
the shared instance

isEnabled

public boolean isEnabled()

setIsEnabled

public void setIsEnabled(boolean enabled)

policy

public ERXWOResponseCache.Policy policy()

setPolicy

public void setPolicy(ERXWOResponseCache.Policy policy)

hasPolicy

public boolean hasPolicy()

actionNameIsCachableForClass

public boolean actionNameIsCachableForClass(Class actionClass,
                                            String actionName)

flushCache

public void flushCache()

cachedResponseForRequest

public WOResponse cachedResponseForRequest(Class actionClass,
                                           String actionName,
                                           WORequest request)

cacheResponseForRequest

public void cacheResponseForRequest(Class actionClass,
                                    String actionName,
                                    WORequest request,
                                    WOResponse response)

Last updated: Do, Dez 9, 2004 • 12:46 PM CET

Copyright © 2002 – 2004 Project Wonder.