1
什麼是通過使用GWT進行反射來調用方法的最佳方式,我知道有一些像「GWT Reflection」這樣的框架,但我真的很想聽到關於此的一些反饋。 如何轉換這樣的事情最好的辦法:什麼是在GWT中通過Reflection調用方法的最佳方式
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);
非常感謝, 路易斯。
請發佈更新,無論您是否能夠解決問題。如果通過選擇答案或發佈自己的答案來解決問題,這是一個很好的做法。 – SSR