You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Henryk Konsek <he...@gmail.com> on 2012/06/19 09:09:31 UTC
Anonymous inner noop AsyncCallbacks
Hi,
What about replacing anonymous inner noop AsyncCallback with
EmptyAsyncCallback? Just to make a codebase a little bit nicer.
// Bad
Object value = invocation.proceed(new AsyncCallback() {
public void done(boolean doneSync) { // nnop }
}, sync);
// Good
Object value = invocation.proceed(new EmptyAsyncCallback(), sync);
Patch attached in Jira issue [1] if you like the idea.
Laters.
[1] https://issues.apache.org/jira/browse/CAMEL-5379
--
Henryk Konsek
http://henryk-konsek.blogspot.com
Re: Anonymous inner noop AsyncCallbacks
Posted by Henryk Konsek <he...@gmail.com>.
> Well I dont like adding more classes to the root package, there is
> plenty already.
Yeah, we could stick just to the NoopAsyncCallback. The Jira issue is
on your side so just apply it when you think it's appropriate moment.
Laters.
--
Henryk Konsek
http://henryk-konsek.blogspot.com
Re: Anonymous inner noop AsyncCallbacks
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 20, 2012 at 5:00 PM, Henryk Konsek <he...@gmail.com> wrote:
>> We should probably name it NoopAsyncCallback as IMHO thats a better name.
>
> I'm used to naming Noop- callbacks as Empty-ones but Noop sounds fine
> as well :) .
>
>> Also we may consider a single static instance as its just a noop, eg
>> like Collections.emptyList() does.
>
> I thought about it but decided to make patch as simple as possible.
>
> BTW I thought also about utility like this:
>
> AsyncCallbacks.noop();
> AsyncCallbacks.log(exchange); // callback that logs to SLF4J that
> exchange has been processed.
>
Well I dont like adding more classes to the root package, there is
plenty already.
And this is frankly not end user API, but for component developers. So
it should be in a sub package such as support.
And not used as much as you can see, its only like 5 components or so
you refactored.
> --
> Henryk Konsek
> http://henryk-konsek.blogspot.com
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: Anonymous inner noop AsyncCallbacks
Posted by Henryk Konsek <he...@gmail.com>.
> We should probably name it NoopAsyncCallback as IMHO thats a better name.
I'm used to naming Noop- callbacks as Empty-ones but Noop sounds fine
as well :) .
> Also we may consider a single static instance as its just a noop, eg
> like Collections.emptyList() does.
I thought about it but decided to make patch as simple as possible.
BTW I thought also about utility like this:
AsyncCallbacks.noop();
AsyncCallbacks.log(exchange); // callback that logs to SLF4J that
exchange has been processed.
--
Henryk Konsek
http://henryk-konsek.blogspot.com
Re: Anonymous inner noop AsyncCallbacks
Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jun 19, 2012 at 9:09 AM, Henryk Konsek <he...@gmail.com> wrote:
> Hi,
>
> What about replacing anonymous inner noop AsyncCallback with
> EmptyAsyncCallback? Just to make a codebase a little bit nicer.
>
> // Bad
> Object value = invocation.proceed(new AsyncCallback() {
> public void done(boolean doneSync) { // nnop }
> }, sync);
>
> // Good
> Object value = invocation.proceed(new EmptyAsyncCallback(), sync);
>
> Patch attached in Jira issue [1] if you like the idea.
>
> Laters.
>
> [1] https://issues.apache.org/jira/browse/CAMEL-5379
>
> --
> Henryk Konsek
> http://henryk-konsek.blogspot.com
We should probably name it NoopAsyncCallback as IMHO thats a better name.
Also we may consider a single static instance as its just a noop, eg
like Collections.emptyList() does.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen