com.faunos.util.net.http
Interface ResponseFactoryConfig

All Known Implementing Classes:
Caroon, ResponseFactorySwitch, SkwishHttpServer

public interface ResponseFactoryConfig

An interface for thread-safe, ResponseFactory configuration. Allows HTTP URIs to be mapped to different response factories. Updates are atomic.

ResponseFactory instances are mapped to a given URI by finding the longest registered URI that is a prefix to the given URI. If found, then the response is delegated to the factory mapped from that prefix URI; otherwise, the response is NOT FOUND (404).

Concurrency Characteristics

Implementations have well defined behavior under multiple readers concurrent with a single updating thread.

Author:
Babak Farhang

Method Summary
 ResponseFactory addMapping(String path, ResponseFactory factory)
          Adds the given URI path-to-factory mapping to the current mappings and returns the previous mapped factory, if any.
 void addMappings(Map<String,ResponseFactory> mappings)
          Adds the given URI path-to-factory mappings to the current mappings.
 ResponseFactory getMapping(String path)
          Returns the ResponseFactory mapped to the specified path, or null, if nothing is mapped to that path.
 SortedMap<String,ResponseFactory> getMappings()
          Returns a read-only snapshot of the current path-to-factory mappings.
 ResponseFactory removeMapping(String path)
          Removes the mapping for specified path and returns the old mapped ResponseFactory, if any; null otherwise.
 void setMappings(Map<String,ResponseFactory> mappings)
          Sets the URI path-to-factory mappings.
 

Method Detail

setMappings

void setMappings(Map<String,ResponseFactory> mappings)
Sets the URI path-to-factory mappings.


addMappings

void addMappings(Map<String,ResponseFactory> mappings)
Adds the given URI path-to-factory mappings to the current mappings.


addMapping

ResponseFactory addMapping(String path,
                           ResponseFactory factory)
Adds the given URI path-to-factory mapping to the current mappings and returns the previous mapped factory, if any.


removeMapping

ResponseFactory removeMapping(String path)
Removes the mapping for specified path and returns the old mapped ResponseFactory, if any; null otherwise. To atomically remove multiple mappings, use getMappings() in combination with setMappings(Map).


getMapping

ResponseFactory getMapping(String path)
Returns the ResponseFactory mapped to the specified path, or null, if nothing is mapped to that path.


getMappings

SortedMap<String,ResponseFactory> getMappings()
Returns a read-only snapshot of the current path-to-factory mappings.



SourceForge.net Logo