You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/02/16 09:10:05 UTC

[GitHub] ivankelly opened a new pull request #1156: Call static methods and build callbacks in MavenClassLoader

ivankelly opened a new pull request #1156: Call static methods and build callbacks in MavenClassLoader
URL: https://github.com/apache/bookkeeper/pull/1156
 
 
   To properly test some functionality we need to be able to call static
   methods (e.g. for the creation of ByteBuf), and also to be able to
   build callbacks (e.g. to call async methods).
   
   This patch implements methods for doing this. For static methods, you
   need to pass the className, the method name and a list of
   arguments. It first tries to find the method using non-primitive
   types, but falls back to trying primative types if possible.
   
   Invokation looks like:
   ```
   cl.callStaticMethod("org.apache.bookkeeper.client.BKException",
                       "create", [-101])
   ```
   
   For callbacks you specify an interface and the a groovy closure.
   It is assumed the closure will take as many arguments as the
   callback. The invokation handler doesn't check the method name
   called on the callback object, so it only works with callbacks
   with a single method.
   
   Invokation looks like:
   ```
   def callback = classLoader.createCallback(
       "org.apache.bookkeeper.client.AsyncCallback\$AddCallback",
           { rc, _ledger, entryId, ctx ->
               // do something
           })
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services