Class DefaultHttpDataFactory
- java.lang.Object
-
- io.netty.handler.codec.http.multipart.DefaultHttpDataFactory
-
- All Implemented Interfaces:
HttpDataFactory
public class DefaultHttpDataFactory extends java.lang.Object implements HttpDataFactory
Default factory givingAttributeandFileUploadaccording to constructor.According to the constructor,
AttributeandFileUploadcan be:- MemoryAttribute, DiskAttribute or MixedAttribute
- MemoryFileUpload, DiskFileUpload or MixedFileUpload
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringbaseDirprivate java.nio.charset.Charsetcharsetprivate booleancheckSizeprivate booleandeleteOnExitprivate longmaxSizestatic longMAXSIZEProposed default MAXSIZE = -1 as UNLIMITEDprivate longminSizestatic longMINSIZEProposed default MINSIZE as 16 KB.private java.util.Map<HttpRequest,java.util.List<HttpData>>requestFileDeleteMapKeep allHttpDatas until cleaning methods are called.private booleanuseDisk
-
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 FalseDefaultHttpDataFactory(boolean useDisk, java.nio.charset.Charset charset)DefaultHttpDataFactory(long minSize)HttpData will be on Disk if the size of the file is greater than minSize, else it will be in memory.DefaultHttpDataFactory(long minSize, java.nio.charset.Charset charset)DefaultHttpDataFactory(java.nio.charset.Charset charset)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidcheckHttpDataSize(HttpData data)Utility methodvoidcleanAllHttpData()Remove all InterfaceHttpData from virtual File storage from clean list for all requestsvoidcleanAllHttpDatas()voidcleanRequestHttpData(HttpRequest request)Remove all InterfaceHttpData from virtual File storage from clean list for the requestvoidcleanRequestHttpDatas(HttpRequest request)AttributecreateAttribute(HttpRequest request, java.lang.String name)AttributecreateAttribute(HttpRequest request, java.lang.String name, long definedSize)AttributecreateAttribute(HttpRequest request, java.lang.String name, java.lang.String value)FileUploadcreateFileUpload(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)voidremoveHttpDataFromClean(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)voidsetBaseDir(java.lang.String baseDir)Override globalDiskAttribute.baseDirectoryandDiskFileUpload.baseDirectoryvalues.voidsetDeleteOnExit(boolean deleteOnExit)Override globalDiskAttribute.deleteOnExitTemporaryFileandDiskFileUpload.deleteOnExitTemporaryFilevalues.voidsetMaxLimit(long maxSize)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
-
charset
private java.nio.charset.Charset charset
-
baseDir
private java.lang.String baseDir
-
deleteOnExit
private boolean deleteOnExit
-
requestFileDeleteMap
private final java.util.Map<HttpRequest,java.util.List<HttpData>> requestFileDeleteMap
Keep allHttpDatas until cleaning methods are called. We need to useIdentityHashMapbecause different requests may be equal. SeeDefaultHttpRequest.hashCode()andDefaultHttpRequest.equals(java.lang.Object). Similarly, when removing data items, we need to check their identities because different data items may be equal.
-
-
Constructor Detail
-
DefaultHttpDataFactory
public DefaultHttpDataFactory()
HttpData will be in memory if less than default size (16KB). The type will be Mixed.
-
DefaultHttpDataFactory
public DefaultHttpDataFactory(java.nio.charset.Charset charset)
-
DefaultHttpDataFactory
public DefaultHttpDataFactory(boolean useDisk)
HttpData will be always on Disk if useDisk is True, else always in Memory if False
-
DefaultHttpDataFactory
public DefaultHttpDataFactory(boolean useDisk, java.nio.charset.Charset charset)
-
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.
-
DefaultHttpDataFactory
public DefaultHttpDataFactory(long minSize, java.nio.charset.Charset charset)
-
-
Method Detail
-
setBaseDir
public void setBaseDir(java.lang.String baseDir)
Override globalDiskAttribute.baseDirectoryandDiskFileUpload.baseDirectoryvalues.- Parameters:
baseDir- directory path where to store disk attributes and file uploads.
-
setDeleteOnExit
public void setDeleteOnExit(boolean deleteOnExit)
Override globalDiskAttribute.deleteOnExitTemporaryFileandDiskFileUpload.deleteOnExitTemporaryFilevalues.- Parameters:
deleteOnExit- true if temporary files should be deleted with the JVM, false otherwise.
-
setMaxLimit
public void setMaxLimit(long maxSize)
Description copied from interface:HttpDataFactoryTo set a max size limitation on fields. Exceeding it will generate an ErrorDataDecoderException. A value of -1 means no limitation (default).- Specified by:
setMaxLimitin interfaceHttpDataFactory
-
getList
private java.util.List<HttpData> getList(HttpRequest request)
- Returns:
- the associated list of
HttpDatafor the request
-
createAttribute
public Attribute createAttribute(HttpRequest request, java.lang.String name)
- Specified by:
createAttributein interfaceHttpDataFactory- Parameters:
request- associated request- Returns:
- a new Attribute with no value
-
createAttribute
public Attribute createAttribute(HttpRequest request, java.lang.String name, long definedSize)
- Specified by:
createAttributein interfaceHttpDataFactory- Parameters:
request- associated requestname- name of the attributedefinedSize- defined size from request for this attribute- Returns:
- a new Attribute with no value
-
checkHttpDataSize
private static void checkHttpDataSize(HttpData data)
Utility method
-
createAttribute
public Attribute createAttribute(HttpRequest request, java.lang.String name, java.lang.String value)
- Specified by:
createAttributein 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:
createFileUploadin 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:HttpDataFactoryRemove 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:
removeHttpDataFromCleanin interfaceHttpDataFactory- Parameters:
request- associated request
-
cleanRequestHttpData
public void cleanRequestHttpData(HttpRequest request)
Description copied from interface:HttpDataFactoryRemove all InterfaceHttpData from virtual File storage from clean list for the request- Specified by:
cleanRequestHttpDatain interfaceHttpDataFactory- Parameters:
request- associated request
-
cleanAllHttpData
public void cleanAllHttpData()
Description copied from interface:HttpDataFactoryRemove all InterfaceHttpData from virtual File storage from clean list for all requests- Specified by:
cleanAllHttpDatain interfaceHttpDataFactory
-
cleanRequestHttpDatas
public void cleanRequestHttpDatas(HttpRequest request)
- Specified by:
cleanRequestHttpDatasin interfaceHttpDataFactory
-
cleanAllHttpDatas
public void cleanAllHttpDatas()
- Specified by:
cleanAllHttpDatasin interfaceHttpDataFactory
-
-