[ http://issues.apache.org/jira/browse/DIRMINA-215?page=all ]

Trustin Lee updated DIRMINA-215:
--------------------------------

        Summary: ClosingCallback which implements IoFuture.Callback  (was: 
IoFuture.Callback.CLOSE)
    Description: 
When you want to close the connection when the last message is sent, you 
usually choose one of two approaches:

1) session.write(message).join();
    session.close();

2) session.write(message).setCallback(new IoFuture.Callback() {
            public void operationComplete(IoFuture future) {
                session.close();
            });

The first approach is very good from the viewpoint of simplicity, but it won't 
work in a single thread mode.  The second one works in a single thread mode, 
but it's very verbose.  To relax the code complexity of the approach 2, it 
would be nice if we have a predefined Callback for closing a session.  The new 
code will be:

2) session.write(message).setCallback(new ClosingCallback(session));

which is much better than before.

  was:
When you want to close the connection when the last message is sent, you 
usually choose one of two approaches:

1) session.write(message).join();
    session.close();

2) session.write(message).setCallback(new IoFuture.Callback() {
            public void operationComplete(IoFuture future) {
                future.getSession().close();
            });

The first approach is very good from the viewpoint of simplicity, but it won't 
work in a single thread mode.  The second one works in a single thread mode, 
but it's very verbose.  To relax the code complexity of the approach 2, it 
would be nice if we have a predefined Callback for closing a session.  The new 
code will be:

2) session.write(message).setCallback(IoFuture.Callback.CLOSE);

which is much better than before.
    


> ClosingCallback which implements IoFuture.Callback
> --------------------------------------------------
>
>          Key: DIRMINA-215
>          URL: http://issues.apache.org/jira/browse/DIRMINA-215
>      Project: Directory MINA
>         Type: New Feature

>     Reporter: Trustin Lee
>     Assignee: Trustin Lee
>     Priority: Trivial
>      Fix For: 0.9.5

>
> When you want to close the connection when the last message is sent, you 
> usually choose one of two approaches:
> 1) session.write(message).join();
>     session.close();
> 2) session.write(message).setCallback(new IoFuture.Callback() {
>             public void operationComplete(IoFuture future) {
>                 session.close();
>             });
> The first approach is very good from the viewpoint of simplicity, but it 
> won't work in a single thread mode.  The second one works in a single thread 
> mode, but it's very verbose.  To relax the code complexity of the approach 2, 
> it would be nice if we have a predefined Callback for closing a session.  The 
> new code will be:
> 2) session.write(message).setCallback(new ClosingCallback(session));
> which is much better than before.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to