|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.http.serve.CacheContentFactory
public class CacheContentFactory
The CacheContentFactory
is used to create a factory
that can be used to create and cache files as instances of the
Content
interface. This is useful when a hot spot
cache is required for frequently referenced files. The defaults
for the file cache use a maximum file size of eight kilobytes.
This factory object can limit the items stored within the cache by file size. This ensures that the resources consumed by the file cache can be restricted. Also the concurrency parameters for the cache can be specified as regions and region limits.
CacheContext
,
TimeCache
Field Summary | |
---|---|
protected TimeCache |
cache
This is used to cache the content objects created. |
protected int |
size
This is the maximum allowed size for a cached file. |
Constructor Summary | |
---|---|
protected |
CacheContentFactory()
Constructor for the CacheContentFactory object. |
|
CacheContentFactory(int size)
Constructor for the CacheContentFactory object. |
|
CacheContentFactory(int size,
int regions,
int limit)
Constructor for the CacheContentFactory object. |
Method Summary | |
---|---|
protected Content |
getContent(Context context,
java.lang.String target)
This is used to create the Content instances. |
protected Content |
getContent(Context context,
java.lang.String target,
int timeout)
This method allows a size to be specified for the maximum buffer size. |
Content |
getInstance(Context context,
java.lang.String target)
This implementation of the getInstance method will
cache the created Content object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected TimeCache cache
protected int size
Constructor Detail |
---|
protected CacheContentFactory()
CacheContentFactory
object.
This object provides caching for any context implementation
that makes heavy use of Content
objects. Caching
done by this object ensures that the content objects are kept
in memory for at least one minute, to change this behaviour
this object can be subclassed and use different settings.
public CacheContentFactory(int size)
CacheContentFactory
object.
This object provides caching for any context implementation
that makes heavy use of Content
objects. Caching
done by this object ensures that the content objects are kept
in memory for at least one minute, to change this behaviour
this object can be subclassed and use different settings.
size
- this is the maximum allow file size to cachepublic CacheContentFactory(int size, int regions, int limit)
CacheContentFactory
object.
This object provides caching for any context implementation
that makes heavy use of Content
objects. Caching
done by this object ensures that the content objects are kept
in memory for at least one minute, to change this behaviour
this object can be subclassed and use different settings.
size
- this is the maximum allow file size to cacheregions
- this is the number of locks the cache useslimit
- this is the maximum capacity of each LRU listMethod Detail |
---|
public Content getInstance(Context context, java.lang.String target) throws ContentException
getInstance
method will
cache the created Content
object. This is done
to increase the performance of the Context
for
objects that are requested frequently. The size of the file
that is cached is dependant on the construction parameters.
If the file referenced is greater than the specified maximum then a one kilobyte buffer is cached for that file as is used to transfer the contents of the file to the output stream.
getInstance
in interface ContentFactory
target
- the request URI for the content requiredcontext
- this is the context used to locate the file
Content
instance
ContentException
- this is thrown if there is an error
locating the specified file, or creating the objectprotected Content getContent(Context context, java.lang.String target, int timeout) throws java.io.IOException
This implementation of the getContent
method will
cache the created Content
object. This is done
to increase the performance of the Context
for
objects that are requested frequently. The buffer size that
can be specified provides a guide for how much memory should
be taken up with the content cached object.
context
- this is the object used to locate the filetarget
- this is the request URI that identifies the filetimeout
- the number of milliseconds to cache the file
java.io.IOException
- this is thrown if the file resource does
not exist or cannot be accessedprotected Content getContent(Context context, java.lang.String target) throws java.io.IOException
Content
instances. The
getInstance
method can be used by subclasses that
want to introduce dynamic Content
objects. This
enables the getContent
method to cache the
resulting instances without having to know what types they are.
By default the CacheContentFactory
produces objects
that will write static content as it appears on the underlying
file system. This uses the specified size to ensure that the
buffers used by the content are not larger than the maximum.
context
- this is the object used to locate the filetarget
- this is the request URI that identifies the file
java.io.IOException
- this is thrown if the file resource does
not exist or cannot be accessed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |