I handle a website which is designed in GWT and I want to check if database connection goes down in between accessing the website. If database connection is down I want to give message as cannot connect to server.
Can anybody suggest what will be the best way to handle this?
I know the onFailure(Throwable t)
method on AsyncCallback
is there. This method is called when the RPC fails for any reason, including (but not limited 开发者_开发技巧to) loss of connection.
Why not throw a meaningful exception from the RPC service on DB failure and handle the scenario inside onFailure of GWT RPC? You should extend AsyncCallback and handle all such general failure conditions (DB/NW failure etc...) at a single place and subclass this callback everywhere instead of defining new AsyncCallback instances each time.
精彩评论