dk.netarkivet.viewerproxy
Class NotifyingURIResolver

java.lang.Object
  extended by java.util.Observable
      extended by dk.netarkivet.viewerproxy.NotifyingURIResolver
All Implemented Interfaces:
URIResolver, URIResolverHandler

public class NotifyingURIResolver
extends java.util.Observable
implements URIResolver, URIResolverHandler

A wrapper class for URI resolver, which also notifies an URIObserver about all URIs visited and their response codes.


Field Summary
 
Fields inherited from interface dk.netarkivet.viewerproxy.URIResolver
NOT_FOUND
 
Constructor Summary
NotifyingURIResolver(URIResolver ur, URIObserver uo)
          Initialise the wrapper.
 
Method Summary
 int lookup(Request request, Response response)
          Passes the uri to the current wrapped resolver and notifies the observer of the result.
 void setURIResolver(URIResolver ur)
          Sets the current URIResolver wrapped.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotifyingURIResolver

public NotifyingURIResolver(URIResolver ur,
                            URIObserver uo)
Initialise the wrapper. Accepts the class to wrap and the observer to notify.

Parameters:
ur - The Wrapped URI resolver
uo - The URI Observer to notify on each url.
Throws:
ArgumentNotValid - if either argument is null.
Method Detail

setURIResolver

public void setURIResolver(URIResolver ur)
Sets the current URIResolver wrapped.

Specified by:
setURIResolver in interface URIResolverHandler
Parameters:
ur - URI resolver to wrap.
Throws:
ArgumentNotValid - if argument is null.

lookup

public int lookup(Request request,
                  Response response)
Passes the uri to the current wrapped resolver and notifies the observer of the result.

Specified by:
lookup in interface URIResolver
Parameters:
request - A given request
response - A given response
Returns:
the response code from the wrapped class
See Also:
URIResolver.lookup(Request, Response)