Mike, This is a very dirty hack that I personally hate it. This is the hack to utilize Eclipse¹s (or other smart IDE) to do auto-completion for you to find the right callback method.
if you write caller.getTarget().createVolumeFromBaseImageCallBack(null, null); Java will interprete it as a standalone method call, If you write as below, it tries to tell that this is to setup a callback, to return this in caller.setCallback is to let you continue to use fluent style to callback setups caller.setCallback( caller.getTarget().createVolumeFromBaseImageCallBack(null, null) );, Behind scene, it uses CGLIB for dispatcher to figure out which method is the callback without requiring developer to give it as literal string AsyncMethod pattern is used commonly in parallel algorithms to dynamically branch out sub-calculations, I think it does not fit well in CloudStack, and also due to the lack of language feature in Java, this hacking technique makes the code really hard to read Kelven On 1/27/14, 6:55 PM, "Mike Tutkowski" <mike.tutkow...@solidfire.com> wrote: >Hi, > >I've been looking at our callback pattern. > >Can someone explain why we always seem to do this?: > >caller.setCallback(caller.getTarget().createVolumeFromBaseImageCallBack(nu >ll, >null)); > >When setCallback is implemented like this: > >public AsyncCallbackDispatcher<T, R> setCallback(Object useless) { > > return this; > > } > >Why not just this?: > >caller.getTarget().createVolumeFromBaseImageCallBack(null, null); > >Thanks! > >-- >*Mike Tutkowski* >*Senior CloudStack Developer, SolidFire Inc.* >e: mike.tutkow...@solidfire.com >o: 303.746.7302 >Advancing the way the world uses the >cloud<http://solidfire.com/solution/overview/?video=play> >**