com.faunos.skwish.ext.http
Class SkwishHttpServer

java.lang.Object
  extended by com.faunos.util.net.HandletServer
      extended by com.faunos.util.net.http.HttpServer
          extended by com.faunos.util.net.http.Caroon
              extended by com.faunos.skwish.ext.http.SkwishHttpServer
All Implemented Interfaces:
ResponseFactoryConfig

public class SkwishHttpServer
extends Caroon

An HTTP server with convenience methods for setting up skwish stores and serving entries from them. Before the server can begin serving documents, it needs to know how it should resolve HTTP URIs to skwish SegmentStores.

How to configure

There are 2 steps involved in configuring the instance to serve skwish.

Create a skwish mount point

Invoke getSkwishMountPoint( httpUri, true) to mount skwish for all HTTP requests whose URIs are a subpath of httpUri. The returned mount point (SkwishHttpMountPoint) then allows one or more stores to mapped below it (next step). Thus each mount point represents a nexus of SegmentStores exposed over HTTP. More than one mount point may be defined on a server.

Map mount point sub-URIs to skwish store

After a SkwishHttpMountPoint has been defined, it needs to be told where and which segment stores it will serve. This is accomplished through the following methods:

It is permissible to update either the mount points or their mappings while the server is running.

Design note: this subclassing strategy for providing convenience methods on top of Caroon does not scale (does not allow mix-ins). Can't decide what refactoring route to take, at the time of this writing, but working on top of theResponseFactoryConfig interface seems the right way to go.
--BF

Author:
Babak Farhang
See Also:
HandletServer.start(), newInstance(int), newInstance(InetAddress, int, ExecutorService, Logger)

Field Summary
 
Fields inherited from class com.faunos.util.net.http.Caroon
factorySwitch
 
Fields inherited from class com.faunos.util.net.http.HttpServer
app
 
Fields inherited from class com.faunos.util.net.HandletServer
logger
 
Constructor Summary
SkwishHttpServer(InetAddress host, int port, ExecutorService exec)
           
SkwishHttpServer(InetAddress host, int port, ExecutorService exec, Logger logger)
           
SkwishHttpServer(int port)
           
 
Method Summary
 SkwishHttpMountPoint getSkwishMountPoint(String uri, boolean create)
          Returns the mount point at the given base uri.
static SkwishHttpServer newDebugInstance(InetAddress host, int port, ExecutorService exec, Logger logger)
          Returns a new instance for debugging purposes.
static SkwishHttpServer newDebugInstance(int port)
          Returns a new instance for debugging purposes.
static SkwishHttpServer newInstance(InetAddress host, int port, ExecutorService exec, Logger logger)
          Returns a new instance.
static SkwishHttpServer newInstance(int port)
          Returns a new instance with a cached thread pool and logger in this class's hierarchical namespace.
 SkwishHttpMountPoint newSkwishMountPoint(String uri)
          Creates and returns a new mount point with the given base uri.
 
Methods inherited from class com.faunos.util.net.http.Caroon
addMapping, addMappings, getMapping, getMappings, removeMapping, setMappings
 
Methods inherited from class com.faunos.util.net.http.HttpServer
newHandlet
 
Methods inherited from class com.faunos.util.net.HandletServer
inputChannel, isAlive, outputChannel, setProcessingHintThreshold, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SkwishHttpServer

public SkwishHttpServer(InetAddress host,
                        int port,
                        ExecutorService exec,
                        Logger logger)
                 throws IOException
Throws:
IOException

SkwishHttpServer

public SkwishHttpServer(InetAddress host,
                        int port,
                        ExecutorService exec)
                 throws IOException
Throws:
IOException

SkwishHttpServer

public SkwishHttpServer(int port)
                 throws IOException
Throws:
IOException
Method Detail

newSkwishMountPoint

public SkwishHttpMountPoint newSkwishMountPoint(String uri)
Creates and returns a new mount point with the given base uri. If there is an existing mount point at the given URI (or some other ResponseFactory mapped to that path), then that mount point is discarded and is replaced with the new return value.


getSkwishMountPoint

public SkwishHttpMountPoint getSkwishMountPoint(String uri,
                                                boolean create)
Returns the mount point at the given base uri. If not mount point is found at the given URI, and create is false, then null is returned; if create is true, and no mount point was found, then newSkwishMountPoint(String) is returned.


newInstance

public static SkwishHttpServer newInstance(int port)
                                    throws IOException
Returns a new instance with a cached thread pool and logger in this class's hierarchical namespace.

Parameters:
port - the port on which the HTTP server will be listening
Throws:
IOException

newInstance

public static SkwishHttpServer newInstance(InetAddress host,
                                           int port,
                                           ExecutorService exec,
                                           Logger logger)
                                    throws IOException
Returns a new instance.

Throws:
IOException

newDebugInstance

public static SkwishHttpServer newDebugInstance(int port)
                                         throws IOException
Returns a new instance for debugging purposes. The instance uses a cached thread pool and logger in this class's hierarchical namespace. The instance echoes all network I/O to std out.

Parameters:
port - the port on which the HTTP server will be listening
Throws:
IOException

newDebugInstance

public static SkwishHttpServer newDebugInstance(InetAddress host,
                                                int port,
                                                ExecutorService exec,
                                                Logger logger)
                                         throws IOException
Returns a new instance for debugging purposes. The instance echoes all network I/O to std out.

Throws:
IOException


SourceForge.net Logo