Package dk.netarkivet.viewerproxy
Class NotifyingURIResolver
- java.lang.Object
-
- java.util.Observable
-
- dk.netarkivet.viewerproxy.NotifyingURIResolver
-
- All Implemented Interfaces:
URIResolver
,URIResolverHandler
public class NotifyingURIResolver extends 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
Constructors Constructor Description NotifyingURIResolver(URIResolver ur, URIObserver uo)
Initialise the wrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
lookup(Request request, Response response)
Passes the uri to the current wrapped resolver and notifies the observer of the result.void
setURIResolver(URIResolver anUR)
Sets the current URIResolver wrapped.-
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
-
-
-
-
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 resolveruo
- The URI Observer to notify on each url.- Throws:
ArgumentNotValid
- if either argument is null.
-
-
Method Detail
-
setURIResolver
public void setURIResolver(URIResolver anUR)
Sets the current URIResolver wrapped.- Specified by:
setURIResolver
in interfaceURIResolverHandler
- Parameters:
anUR
- 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 interfaceURIResolver
- Parameters:
request
- A given requestresponse
- A given response- Returns:
- the response code from the wrapped class
- See Also:
URIResolver.lookup(Request, Response)
-
-