simple.http.serve
Class FactoryContext

java.lang.Object
  extended by simple.http.serve.FileContext
      extended by simple.http.serve.FactoryContext
All Implemented Interfaces:
Context
Direct Known Subclasses:
CacheContext

public class FactoryContext
extends FileContext

e The FactoryContext is a context implementation that can be used to serve dynamic Content objects. This uses a ContentFactory implementation to produce instances from the getInstance method. This should be used if content other than static files needs to be served from the context. Also, this can be used as a caching implementation by using the FileContentFactory object for static files.

Author:
Niall Gallagher
See Also:
CacheContext

Field Summary
protected  ContentFactory factory
          This is used to acquire Content implementations.
 
Fields inherited from class simple.http.serve.FileContext
base, format, indexer, locator
 
Constructor Summary
FactoryContext(ContentFactory factory)
          Constructor for the FactoryContext.
FactoryContext(ContentFactory factory, java.io.File base)
          Constructor for the FactoryContext.
FactoryContext(ContentFactory factory, java.io.File base, java.io.File path)
          Constructor for the FactoryContext.
FactoryContext(ContentFactory factory, java.io.File base, java.io.File[] list)
          Constructor for the FactoryContext.
 
Method Summary
 Content getContent(java.lang.String target)
          This creates instances of the Content object using the issued ContentFactory.
 
Methods inherited from class simple.http.serve.FileContext
getBasePath, getContentType, getDirectory, getFile, getFormat, getIndex, getLocale, getLocator, getName, getPath, getProperties, getRealPath, getRequestPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

protected ContentFactory factory
This is used to acquire Content implementations.

Constructor Detail

FactoryContext

public FactoryContext(ContentFactory factory)
Constructor for the FactoryContext. This will produce dynamic Content implementations. The objects produced by the getContent method are created using a ContentFactory. This loads all configuration files from the current working directory.

Parameters:
factory - used to produce dynamic content objects

FactoryContext

public FactoryContext(ContentFactory factory,
                      java.io.File base)
Constructor for the FactoryContext. This will produce dynamic Content implementations. The objects produced by the getContent method are created using a ContentFactory. This loads all files and configuration from the specified path.

Parameters:
base - the OS specific base path for this instance
factory - used to produce dynamic content objects

FactoryContext

public FactoryContext(ContentFactory factory,
                      java.io.File base,
                      java.io.File path)
Constructor for the FactoryContext. This will produce dynamic Content implementations. The objects produced by the getContent method are created using a ContentFactory. This loads all files from the specified base path. Configuration can be loaded from the file range provided.

Parameters:
base - the OS specific base path for this instance
factory - used to produce dynamic content objects
path - this is the directory used for configuration

FactoryContext

public FactoryContext(ContentFactory factory,
                      java.io.File base,
                      java.io.File[] list)
Constructor for the FactoryContext. This will produce dynamic Content implementations. The objects produced by the getContent method are created using a ContentFactory. This loads all files from the specified base path. Configuration can be loaded from the file range provided.

Parameters:
base - the OS specific base path for this instance
factory - used to produce dynamic content objects
list - this is the range searched for configuration
Method Detail

getContent

public Content getContent(java.lang.String target)
                   throws java.io.IOException
This creates instances of the Content object using the issued ContentFactory. This will initially attempt to acquire the content instance using the provided factory. However, if this fails the super class method is used.

Specified by:
getContent in interface Context
Overrides:
getContent in class FileContext
Parameters:
target - the request URI used to reference the resource
Returns:
this returns the specified resource wrapped in the Content interface
Throws:
java.io.IOException - this is thrown if there is an I/O problem