com.faunos.skwish.ext.http
Class MappedUriProvider

java.lang.Object
  extended by com.faunos.skwish.ext.http.MappedUriProvider
All Implemented Interfaces:
Provider

public class MappedUriProvider
extends Object
implements Provider

A filter on a skwish service provider that maps input URIs to output URIs. This only exposes a read-only interface.

Note this implementation breaks the Provider contract in one minor way: SegmentStores returned by this provider do not have the correct uri property; you can't use that URI on this provider to get back the same SegmentStore.

Concurrency characteristics

All the methods exposed by this class are thread-safe--so long as the contained instance is also thread safe. Concurrent updates result in undefined behavior (some updates may miss), but an instance itself is [designed to be] never be internally inconsistent state. Also, the implementation does not block, unless the contained instance does (usually the case).

SegmentStores are cached internally in an attempt to avoid file system path resolution (implemented in the base provider).

Author:
Babak Farhang

Constructor Summary
MappedUriProvider()
          Constructs a default instance that uses the default provider.
MappedUriProvider(Provider inner)
          Constructs an instance that wraps the given inner instance.
 
Method Summary
 String getBaseUri()
          Returns the base URI.
 Map<String,String> getUriMappings()
          Returns the mapped URIs.
 SegmentStore loadInstance(String uri)
          Loads the store at the given uri by first retrieving the URI's mapped value and then invoking the loadInstance method on the contained instance.
 void map(String src, String dtn)
          Adds the given mapping.
 void setBaseUri(String baseUri)
          Sets the base URI for the mapping.
 void setUriMappings(Map<String,String> mappings)
          Sets the URI mappings.
 SegmentStore writeNewInstance(String uri)
          Not implemented.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MappedUriProvider

public MappedUriProvider()
Constructs a default instance that uses the default provider.

See Also:
SegmentStore.getProvider()

MappedUriProvider

public MappedUriProvider(Provider inner)
Constructs an instance that wraps the given inner instance.

Method Detail

getUriMappings

public Map<String,String> getUriMappings()
Returns the mapped URIs. The returned map is read-only.


setUriMappings

public void setUriMappings(Map<String,String> mappings)
Sets the URI mappings.


map

public void map(String src,
                String dtn)
Adds the given mapping. Note, using the setUriMappings(Map) method is much more efficient if many mappings need to be configured.

Parameters:
src - the input URI
dtn - the mapped value for the URI

setBaseUri

public void setBaseUri(String baseUri)
Sets the base URI for the mapping. The base uri, if any, is stripped the argument passed in to loadInstance(String) before it is mapped. This allows the root of the application to be set independent of the finer grain mappings.

Parameters:
baseUri -

getBaseUri

public String getBaseUri()
Returns the base URI. A null return value indicates that none is set.


loadInstance

public SegmentStore loadInstance(String uri)
                          throws IOException
Loads the store at the given uri by first retrieving the URI's mapped value and then invoking the loadInstance method on the contained instance. If the given uri is not mapped to a value, then a NotFoundException is thrown.

Specified by:
loadInstance in interface Provider
Throws:
IOException
See Also:
setBaseUri(String)

writeNewInstance

public SegmentStore writeNewInstance(String uri)
                              throws IOException
Not implemented.

Specified by:
writeNewInstance in interface Provider
Throws:
UnsupportedOperationException
IOException


SourceForge.net Logo