Hi, I'm trying to implement a protocol that looks like this in Apache Mina (1.x ): 1: The client send a text line message ending with a newline. 2: Optional binary data sent as raw byte data.
Depending on the content of the string in 1 the codec in 2 should read the raw data or not. For example, if the text-line in 1 ends with "attachment:<size>" the codec should expect to read binary data of size <size>, otherwise it should not expect any more data. My first thought was to reuse the TextLineDecoder in step1 and then delegate to another decoder that inspects the content of the first step and see if it should read the raw data or not. This codec could then assemble the whole attachment as a byte[] in memory and put it in a key in the session so that fitlers can take care of assembling the domain object (unfortunately I have to store the whole attachment in memory for other reasons, i.e. I cannot just delegate the chunks). Does this seem like a feasible solution? I cannot understand how to use multiple decoders in this way though and I don't think I can use a filter for step 2 right? The only solution I have right now is to copy parts of the TextLineDecoder into my own decoder which does both 1 & 2. But this doesn't seem right due to bad reuse? Thanks, Johan
