The invocation framework defines the Invocable interface which represent an object that has InvocableFunctions that can be invoked. There are a few uses for the framework:
Let supposed that you have a method callMeALot in an class MyObject that is called frequently in your application, but as the requirement of the design you are allowed to call it using java reflection api
MyObject obj = new MyObject(); //...later somewhere in your application... Method m = obj.getMethod("callMeALot", argTypes); m.invoke(args);
MyObject obj = new MyObject(); Invocable inv = new ReflectionWrapperInvocable(obj); //...later somewhere in your application inv.invoke("callMeALot", args); //notice this is simpler than reflection api
MyObject obj = new MyObject(); Invocable inv = new ReflectionWrapperInvocable(obj); inv.addFunction(new AbstractInvocableFunction("callMeALot", new Class[] {}){ public Object invoke(Object obj, Object[] args){ return ((MyObject)obj).callMeALot(); } } //...later somewhere in your application inv.invoke("callMeALot", args); //this time, it will do the direct call