Class TarAggregationStrategy
java.lang.Object
org.apache.camel.processor.aggregate.tarfile.TarAggregationStrategy
- All Implemented Interfaces:
org.apache.camel.AggregationStrategy
@Metadata(label="bean",
description="AggregationStrategy to combine together incoming messages into a tar file. Please note that this aggregation strategy requires eager completion check to work properly.",
annotations="interfaceName=org.apache.camel.AggregationStrategy")
@Configurer(metadataOnly=true)
public class TarAggregationStrategy
extends Object
implements org.apache.camel.AggregationStrategy
This aggregation strategy will aggregate all incoming messages into a TAR file.
If the incoming exchanges contain GenericFileMessage file name will be taken from the body otherwise the body
content will be treated as a byte array and the TAR entry will be named using the message id (unless the flag
useFilenameHeader is set to true.
NOTE 1: Please note that this aggregation strategy requires eager completion check to work properly.
NOTE 2: This implementation is very inefficient especially on big files since the tar file is completely rewritten for each file that is added to it. Investigate if the files can be collected and at completion stored to tar file.
-
Constructor Summary
ConstructorsConstructorDescriptionTarAggregationStrategy(boolean preserveFolderStructure) TarAggregationStrategy(boolean preserveFolderStructure, boolean useFilenameHeader) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.camel.Exchangeaggregate(org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange) booleanbooleanvoidonCompletion(org.apache.camel.Exchange exchange, org.apache.camel.Exchange inputExchange) voidsetFilePrefix(String filePrefix) Sets the prefix that will be used when creating the TAR filename.voidsetFileSuffix(String fileSuffix) Sets the suffix that will be used when creating the ZIP filename.voidsetParentDir(File parentDir) Sets the parent directory to use for writing temporary files.voidsetParentDir(String parentDir) Sets the parent directory to use for writing temporary files.voidsetPreserveFolderStructure(boolean preserveFolderStructure) If the incoming message is from a file, then the folder structure of said file can be preservedvoidsetUseFilenameHeader(boolean useFilenameHeader) Whether to use CamelFileName header for the filename instead of using unique message idMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.AggregationStrategy
aggregate, canPreComplete, onCompletion, onOptimisticLockFailure, preComplete, timeout
-
Constructor Details
-
TarAggregationStrategy
public TarAggregationStrategy() -
TarAggregationStrategy
public TarAggregationStrategy(boolean preserveFolderStructure) - Parameters:
preserveFolderStructure- if true, the folder structure is preserved when the source is a type ofGenericFileMessage. If used with a file, use recursive=true.
-
TarAggregationStrategy
public TarAggregationStrategy(boolean preserveFolderStructure, boolean useFilenameHeader) - Parameters:
preserveFolderStructure- if true, the folder structure is preserved when the source is a type ofGenericFileMessage. If used with a file, use recursive=true.useFilenameHeader- if true, the filename header will be used to name aggregated byte arrays within the TAR file.
-
-
Method Details
-
getFilePrefix
-
setFilePrefix
Sets the prefix that will be used when creating the TAR filename. -
getFileSuffix
-
setFileSuffix
Sets the suffix that will be used when creating the ZIP filename. -
getParentDir
-
setParentDir
Sets the parent directory to use for writing temporary files. -
setParentDir
Sets the parent directory to use for writing temporary files. -
isPreserveFolderStructure
public boolean isPreserveFolderStructure() -
setPreserveFolderStructure
public void setPreserveFolderStructure(boolean preserveFolderStructure) If the incoming message is from a file, then the folder structure of said file can be preserved -
isUseFilenameHeader
public boolean isUseFilenameHeader() -
setUseFilenameHeader
public void setUseFilenameHeader(boolean useFilenameHeader) Whether to use CamelFileName header for the filename instead of using unique message id -
aggregate
public org.apache.camel.Exchange aggregate(org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange) - Specified by:
aggregatein interfaceorg.apache.camel.AggregationStrategy
-
onCompletion
public void onCompletion(org.apache.camel.Exchange exchange, org.apache.camel.Exchange inputExchange) - Specified by:
onCompletionin interfaceorg.apache.camel.AggregationStrategy
-