Class DefaultHttpDataFactory
- java.lang.Object
-
- org.jboss.netty.handler.codec.http.multipart.DefaultHttpDataFactory
-
- All Implemented Interfaces:
HttpDataFactory
public class DefaultHttpDataFactory extends java.lang.Object implements HttpDataFactory
Default factory giving Attribute and FileUpload according to constructor Attribute and FileUpload could be :
- MemoryAttribute, DiskAttribute or MixedAttribute
- MemoryFileUpload, DiskFileUpload or MixedFileUpload
according to the constructor.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
checkSize
private long
maxSize
static long
MAXSIZE
Proposed default MAXSIZE = -1 as UNLIMITEDprivate long
minSize
static long
MINSIZE
Proposed default MINSIZE as 16 KB.private java.util.Map<HttpRequest,java.util.List<HttpData>>
requestFileDeleteMap
Keep all HttpDatas until cleanAllHttpDatas() is called.private boolean
useDisk
-
Constructor Summary
Constructors Constructor Description DefaultHttpDataFactory()
HttpData will be in memory if less than default size (16KB).DefaultHttpDataFactory(boolean useDisk)
HttpData will be always on Disk if useDisk is True, else always in Memory if False.DefaultHttpDataFactory(long minSize)
HttpData will be on Disk if the size of the file is greater than minSize, else it will be in memory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkHttpDataSize(HttpData data)
Utility methodvoid
cleanAllHttpDatas()
Remove all InterfaceHttpData from virtual File storage from clean list for all requestsvoid
cleanRequestHttpDatas(HttpRequest request)
Remove all InterfaceHttpData from virtual File storage from clean list for the requestAttribute
createAttribute(HttpRequest request, java.lang.String name)
Attribute
createAttribute(HttpRequest request, java.lang.String name, java.lang.String value)
FileUpload
createFileUpload(HttpRequest request, java.lang.String name, java.lang.String filename, java.lang.String contentType, java.lang.String contentTransferEncoding, java.nio.charset.Charset charset, long size)
private java.util.List<HttpData>
getList(HttpRequest request)
void
removeHttpDataFromClean(HttpRequest request, InterfaceHttpData data)
Remove the given InterfaceHttpData from clean list (will not delete the file, except if the file is still a temporary one as setup at construction)void
setMaxLimit(long max)
To set a max size limitation on fields.
-
-
-
Field Detail
-
MINSIZE
public static final long MINSIZE
Proposed default MINSIZE as 16 KB.- See Also:
- Constant Field Values
-
MAXSIZE
public static final long MAXSIZE
Proposed default MAXSIZE = -1 as UNLIMITED- See Also:
- Constant Field Values
-
useDisk
private final boolean useDisk
-
checkSize
private final boolean checkSize
-
minSize
private long minSize
-
maxSize
private long maxSize
-
requestFileDeleteMap
private final java.util.Map<HttpRequest,java.util.List<HttpData>> requestFileDeleteMap
Keep all HttpDatas until cleanAllHttpDatas() is called.
-
-
Constructor Detail
-
DefaultHttpDataFactory
public DefaultHttpDataFactory()
HttpData will be in memory if less than default size (16KB). No limit setup. The type will be Mixed.
-
DefaultHttpDataFactory
public DefaultHttpDataFactory(boolean useDisk)
HttpData will be always on Disk if useDisk is True, else always in Memory if False. No limit setup.
-
DefaultHttpDataFactory
public DefaultHttpDataFactory(long minSize)
HttpData will be on Disk if the size of the file is greater than minSize, else it will be in memory. The type will be Mixed. No limit setup.
-
-
Method Detail
-
setMaxLimit
public void setMaxLimit(long max)
Description copied from interface:HttpDataFactory
To set a max size limitation on fields. Exceeding it will generate an ErrorDataDecoderException. A value of -1 means no limitation (default).- Specified by:
setMaxLimit
in interfaceHttpDataFactory
-
getList
private java.util.List<HttpData> getList(HttpRequest request)
- Returns:
- the associated list of Files for the request
-
createAttribute
public Attribute createAttribute(HttpRequest request, java.lang.String name)
- Specified by:
createAttribute
in interfaceHttpDataFactory
- Parameters:
request
- associated request- Returns:
- a new Attribute with no value
-
checkHttpDataSize
private void checkHttpDataSize(HttpData data)
Utility method- Parameters:
data
-
-
createAttribute
public Attribute createAttribute(HttpRequest request, java.lang.String name, java.lang.String value)
- Specified by:
createAttribute
in interfaceHttpDataFactory
- Parameters:
request
- associated request- Returns:
- a new Attribute
-
createFileUpload
public FileUpload createFileUpload(HttpRequest request, java.lang.String name, java.lang.String filename, java.lang.String contentType, java.lang.String contentTransferEncoding, java.nio.charset.Charset charset, long size)
- Specified by:
createFileUpload
in interfaceHttpDataFactory
- Parameters:
request
- associated requestsize
- the size of the Uploaded file- Returns:
- a new FileUpload
-
removeHttpDataFromClean
public void removeHttpDataFromClean(HttpRequest request, InterfaceHttpData data)
Description copied from interface:HttpDataFactory
Remove the given InterfaceHttpData from clean list (will not delete the file, except if the file is still a temporary one as setup at construction)- Specified by:
removeHttpDataFromClean
in interfaceHttpDataFactory
- Parameters:
request
- associated request
-
cleanRequestHttpDatas
public void cleanRequestHttpDatas(HttpRequest request)
Description copied from interface:HttpDataFactory
Remove all InterfaceHttpData from virtual File storage from clean list for the request- Specified by:
cleanRequestHttpDatas
in interfaceHttpDataFactory
- Parameters:
request
- associated request
-
cleanAllHttpDatas
public void cleanAllHttpDatas()
Description copied from interface:HttpDataFactory
Remove all InterfaceHttpData from virtual File storage from clean list for all requests- Specified by:
cleanAllHttpDatas
in interfaceHttpDataFactory
-
-