Issue Details (XML | Word | Printable)

Key: DIRMINA-145
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Niklas Therning
Reporter: Johannes Zillmann
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
MINA

filter for writing streams

Created: 15/Dec/05 10:14 PM   Updated: 26/May/09 12:47 AM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 0.9.1

Time Tracking:
Not Specified

File Attachments:
  Size
Zip Archive Licensed for inclusion in ASF works streamWriteFilter.zip 2005-12-15 10:15 PM Johannes Zillmann 3 kB

Resolution Date: 16/Jan/06 12:44 AM


 Description  « Hide
a filter for easy stream writing would be usefull.
I append a zip with that kind of filter.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Niklas Therning added a comment - 17/Dec/05 05:58 AM
I've applied the attached patch and made some minor changes to make it more generic. The changes are:

* The filter will now call nextFilter.messageSent once all the contents of the stream has been written.
* The filter won't close the stream. The IoHandler will have to take care of this in messageSent.
* The filter will throw IllegalStateException if one tries to write something while there's a stream being worked on.
* The advances property has been changed into a writeBufferSize property. I think that will make more sense to users.

I hope these changes are ok and that they will make the filter even more useful. I will check it into subversion as soon as I have updated the test.

Thank you, Johannes, for your contribution!

Trustin Lee added a comment - 21/Dec/05 05:08 PM
Is this patch really applied? I cannot find it.

BTW it would be great if we can provide input/outputstream by default instead of using StreamIoHandler which forces users to choose only one approach. In some cases users want to use both asynchronous and synchronous I/O for maximum compatibility. WDYT?

Johannes Zillmann added a comment - 21/Dec/05 05:33 PM
< TW it would be great if we can provide input/outputstream by default instead of using StreamIoHandler which forces users to choose only one approach. In some cases users want to use both asynchronous and synchronous I/O for maximum compatibility. WDYT?

Would be real cool ! ;)

Niklas Therning added a comment - 21/Dec/05 05:40 PM
No, I hasn't been checked in yet. I should have made that clearer. I have applied the patch to my local tree and made some changes. The unit test hasn't been completed yet. I won't check it in until the test is finished.

About input/outputstream. I'm not sure I understand what you mean? Should there be methods like IoSession.getInputStream()/IoSession.getOutputStream()?

Trustin Lee added a comment - 21/Dec/05 06:38 PM
It would be great if user can switch IoHandler mode and InputStream/OutputStream mode very easy.

What about providing SwitchingIoHandler?

SwitchingIoHandler handler = ...;
handler.setHandler( new MyIoHandler() ); // Set default one
...
handler.setHandler( new StreamIoHandler() {...}); // Change the handler

I guess this is the simplest solution. WDYT?

Johannes Zillmann added a comment - 21/Dec/05 08:14 PM
> What about providing SwitchingIoHandler?
> handler.setHandler( new MyIoHandler() ); // Set default one
> ...
> handler.setHandler( new StreamIoHandler() {...}); // Change the handler

I don't dig sooo deep in this topic, but some initial thoughts...
Is it useful to switch handlers per session ? Then you might switch filter chains to ? (fe you had object sersialization filter in MyIoHandler)
Would it not make more sense to configure session for a) streams (blocking) or b.) events (non-blocking) ???

Niklas Therning added a comment - 16/Jan/06 12:44 AM
The filter StreamWriteFilter has been committed. Basically it allows you to write InputStream objects using session.write(). The filter will take care of reading the bytes from the stream, put them in a ByteBuffer and pass that buffer along to the next filter. IoHandler.messageSent() won't be called until all the bytes of the stream have been written. Bytes are read in 4k chunks from the stream by default. This is configurable.

For now I haven't looked into the SwitchingIoHandler feature. Maybe it would be better to open up a new issue for that?