Hi all,

What’s the best way to invoke a method by reflection using GWT, converting 
something like this:

 

GreetingServiceAsync service = GWT.create(GreetingService.class);

AsyncCallback callBack = new AsyncCallback< Void>() {

                                                @Override

                                                public void 
onFailure(Throwable caught) 
{                                                            

                                                }

                                                @Override

                                                public void onSuccess(Void 
result) {                                        

                                                }

                                };                             

service.doSomething(callBack);

 

in:

GreetingServiceAsync greetingService = GWT.create(GreetingService.class);

 

String methodName = “doSomething”;

Object service;

AsyncCallback callBack = new AsyncCallback< Void>() {

                                                @Override

                                                public void 
onFailure(Throwable caught) 
{                                                            

                                                }

                                                @Override

                                                public void onSuccess(Void 
result) {                                        

                                                }

                                };

/*somehow invoke by reflection*/

Class<?> c = Class.forName(GreetingServiceAsync.class.getName());

Method  method = c.getMethod(methodName, AsyncCallback.class);

method.invoke (service, callBack);

 

 

Many thanks,

Luis.

 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/MYz8uHTCuU0J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to