| 65 | ||{{{thread}}} ||{{{ThreadedFilter}}} ||none ||any ||Runs a thread, so the following filter will run in a separate thread|| |
| 66 | ||{{{serialize}}} ||{{{SerializeFilter}}} ||none ||any to {{{byte[]}}} ||Serializes any serializable Java object to a byte array|| |
| 67 | ||{{{deserialize}}} ||{{{DeserializeFilter}}} ||none ||{{{byte[]}}} to object ||Deserializes a serialized byte array to a Java object|| |
| 68 | ||{{{compress}}} ||{{{CompressFilter}}} ||none ||{{{byte[]}}} ||Compresses byte arrays using the Deflate algorithm|| |
| 69 | ||{{{decompress}}} ||{{{DecompressFilter}}} ||none ||{{{byte[]}}} ||Decompresses compressed byte arrays|| |
| 70 | ||{{{chunk}}} ||{{{ChunkFilter}}} ||{{{int chunks}}} ||{{{byte[]}}} ||Splits up a byte array into {{{chunks}}} smaller byte arrays for separate processing.|| |
| 71 | ||{{{dechunk}}} ||{{{DechunkFilter}}} ||{{{int chunks}}} ||{{{byte[]}}} ||Combines a byte array that was split up by the chunk filter.|| |
| 84 | } |
| 85 | }}} |
| 86 | |
| 87 | By default, the conduit filters get applied at the receiving submodel. If a filter should be applied at the sending submodel, or if filters should be applied at both locations, the tie argument can take an additional argument, so that the first list of filters is applied at the sending side and the second list of filters is applied at the receiving side. |
| 88 | The following fragment multiplies the data with a constant on the sending side, and prints it on the receiving side: |
| 89 | {{{ |
| 90 | cs.attach('w' => 'r') { |
| 91 | tie('dataOut', 'dataIn',['multiply_0.5'],['console']) |
| 92 | } |
| 93 | }}} |
| 94 | |
| 95 | And the following fragment compresses data on the sending side and uncompresses it on the receiving side: |
| 96 | {{{ |
| 97 | cs.attach('w' => 'r') { |
| 98 | tie('dataOut', 'dataIn',['serialize','compress'],['decompress','deserialize']) |
| 99 | } |
| 100 | }}} |
| 101 | |
| 102 | For large sets of data it might even make sense to split the data up before compressing, so that it gets sent in separate chunks and the compressing is done in a separate thread from sending: |
| 103 | {{{ |
| 104 | cs.attach('w' => 'r') { |
| 105 | tie('dataOut', 'dataIn',['serialize','chunk_16','compress','thread'],['decompress','dechunk_16','deserialize']) |