nextapp.echoservlet.filetransferui.spi
Interface MultipartUploadSPI

All Superinterfaces:
EchoServer.MultipartRequestWrapper
All Known Implementing Classes:
JakartaCommonsFileUploadProvider

public interface MultipartUploadSPI
extends EchoServer.MultipartRequestWrapper

This interface allows pluggable selection of the library to be used to parse the HttpServletRequest. Implementations are discovered through the usual JDK 1.3+ services mechanism (SPI).

Discovered instances are queried as to whether they are operative. Instances that are operative are filtered based on their support for disk caching and file upload size limits, if those were specified to matter. If more than one instance remains after filtering for these criteria, an implementation from outside the nextapp package hierarchy is selected randomly. If all implementations are from the nextapp package hierarchy, then one is selected randomly.


Method Summary
 MultipartUploadSPI copy()
          Returns a new instance of the implementation configured identically to the current instance.
 boolean operative()
          Implementations return whether they are able to handle calls to wrapRequest() and updateComponent().
 void setDiskCacheLocation(java.io.File directory)
          Sets the directory to be used for storing file uploads that exceed the memory cache threshold.
 void setFileUploadSizeLimit(int bytes)
          Sets the maximum size, in bytes, of file uploads to be accepted.
 void setMemoryCacheThreshold(int bytes)
          Sets the size, in bytes, that the file upload must exceed before being cached to disk.
 boolean supportsDiskCaching()
          Implementations return true if they support caching the uploaded file to disk.
 boolean supportsFileUploadSizeLimit()
          Implementations return true if they support limiting the size of the upload.
 void updateComponent(Connection conn, UploadSelect uploadSelect)
          Implementations use the information from the HttpServletRequest in the Connection to call the fileUpload() method of the UploadSelect component.
 
Methods inherited from interface nextapp.echoservlet.EchoServer.MultipartRequestWrapper
getWrappedRequest
 

Method Detail

operative

boolean operative()
Implementations return whether they are able to handle calls to wrapRequest() and updateComponent(). This allows an implementation to determine whether its supporting libraries are available.

Parameters:
request - request to be parsed
Returns:
true if the implementation is able to parse requests

supportsDiskCaching

boolean supportsDiskCaching()
Implementations return true if they support caching the uploaded file to disk. Implementations that return true must not throw UnsupportedOperationExceptions for the methods setMemoryCacheThreshold() and setDiskCacheLocation().

Returns:
true if the implementation is able to conserve memory by storing the uploaded file to disk

supportsFileUploadSizeLimit

boolean supportsFileUploadSizeLimit()
Implementations return true if they support limiting the size of the upload. Implementations that return true must not throw an UnsupportedOperationException for the method setFileUploadSizeLimit().

Returns:
true if the implmentation is able to terminate uploads larger than a specified size

updateComponent

void updateComponent(Connection conn,
                     UploadSelect uploadSelect)
                     throws java.io.IOException,
                            javax.servlet.ServletException
Implementations use the information from the HttpServletRequest in the Connection to call the fileUpload() method of the UploadSelect component.

Parameters:
conn - provides access to the HttpServletRequest
uploadSelect - component to be updated with the file upload information
Throws:
java.io.IOException - if the Connection or the HttpServletRequest throws an IOException during the operation
javax.servlet.ServletException - if Connection or the HttpServletRequest throws an IOException during the operation

setMemoryCacheThreshold

void setMemoryCacheThreshold(int bytes)
                             throws java.lang.UnsupportedOperationException
Sets the size, in bytes, that the file upload must exceed before being cached to disk. Some implementations that support disk caching may not support the storing of small uploads in memory. Such implementations should ignore calls to this method and not throw an UnsupportedOperationException.

Parameters:
bytes - maximum size of the file upload before it will be cached to disk
Throws:
java.lang.UnsupportedOperationException - if this implementation does not support disk caching

setDiskCacheLocation

void setDiskCacheLocation(java.io.File directory)
                          throws java.io.IOException,
                                 java.lang.UnsupportedOperationException
Sets the directory to be used for storing file uploads that exceed the memory cache threshold.

Parameters:
directory - location to store uploaded files
Throws:
java.io.IOException - if the directory does not exist or the File throws an IOException during this operation
java.lang.UnsupportedOperationException - if this implementation does not support disk caching

setFileUploadSizeLimit

void setFileUploadSizeLimit(int bytes)
                            throws java.lang.UnsupportedOperationException
Sets the maximum size, in bytes, of file uploads to be accepted. Uploads that exceed the specified size are terminated or handled in a manner that minimizes the risk of a Denial of Service attack against the application.

Parameters:
bytes - the size threshold after which a file upload is rejected
Throws:
java.lang.UnsupportedOperationException - if this implementation does not support limiting file upload sizes

copy

MultipartUploadSPI copy()
Returns a new instance of the implementation configured identically to the current instance. It is very important that the object returned is not this, but rather a newly instantiated object.

Returns:
a clone of this object