org.apache.shindig.gadgets.http
Class DefaultInvalidationService

java.lang.Object
  extended by org.apache.shindig.gadgets.http.DefaultInvalidationService
All Implemented Interfaces:
InvalidationService

public class DefaultInvalidationService
extends Object
implements InvalidationService

Default implementation of the invalidation service. No security checks are applied when invalidating Urls. Invalidation marks are added to HttpResponse objects which are then cached. We do an exact equality check on the invalidation marks rather than trying to do something timestamp based. This implementation uses an invalidate-on-read technique. HttpResponses are 'marked' with a globally unique sequence value assigned to the users in who's context the signed/oauth request was made. When that same request is repeated later we ensure that the mark on the cached response is consistent with the current mark for the request. When the content for a user is invalidated a new unique sequence value is assigned to them and all the marks on cached content associated with that user will become invalid. This technique is reliable if the lifetime of the HttpCache is tied to the invalidation cache and when the invalidation cache is canonical. A non-canonical invalidation cache can be used but cached responses must become invalid if an invalidation entry is missing.


Field Summary
static String CACHE_NAME
           
protected  Cache<String,Long> invalidationEntries
           
 
Fields inherited from interface org.apache.shindig.gadgets.http.InvalidationService
INVALIDATION_HEADER
 
Constructor Summary
DefaultInvalidationService(HttpCache httpCache, CacheProvider cacheProvider)
           
 
Method Summary
 void invalidateApplicationResources(Set<Uri> uris, SecurityToken token)
          Invalidate a set of cached resources that are part of the application specification itself.
 void invalidateUserResources(Set<String> opensocialIds, SecurityToken token)
          Invalidate all fetched content that was signed on behalf of the specified set of users.
 boolean isValid(HttpRequest request, HttpResponse response)
          Is the specified HttpResponse still valid.
 HttpResponse markResponse(HttpRequest request, HttpResponse response)
          Mark the HttpResponse prior to caching it so that subsequent calls to isValid can detect if it has been invalidated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHE_NAME

public static final String CACHE_NAME
See Also:
Constant Field Values

invalidationEntries

protected final Cache<String,Long> invalidationEntries
Constructor Detail

DefaultInvalidationService

@Inject
public DefaultInvalidationService(HttpCache httpCache,
                                         CacheProvider cacheProvider)
Method Detail

invalidateApplicationResources

public void invalidateApplicationResources(Set<Uri> uris,
                                           SecurityToken token)
Description copied from interface: InvalidationService
Invalidate a set of cached resources that are part of the application specification itself. This includes gadget specs, manifests and message bundles

Specified by:
invalidateApplicationResources in interface InvalidationService
Parameters:
uris - of content to invalidate
token - identifying the calling application

invalidateUserResources

public void invalidateUserResources(Set<String> opensocialIds,
                                    SecurityToken token)
Invalidate all fetched content that was signed on behalf of the specified set of users.

Specified by:
invalidateUserResources in interface InvalidationService
Parameters:
opensocialIds -
token -

isValid

public boolean isValid(HttpRequest request,
                       HttpResponse response)
Description copied from interface: InvalidationService
Is the specified HttpResponse still valid. If the request is signed or authenticated has its content been invalidated by a call to invalidateUserResource subsequent to the response being cached.

Specified by:
isValid in interface InvalidationService

markResponse

public HttpResponse markResponse(HttpRequest request,
                                 HttpResponse response)
Description copied from interface: InvalidationService
Mark the HttpResponse prior to caching it so that subsequent calls to isValid can detect if it has been invalidated.

Specified by:
markResponse in interface InvalidationService


Copyright © 2007-2012. All Rights Reserved.