I am using Play!Framework 2.2.x(Java) for communication between server and mobile app.
I want to get callback if the mobile app request data and it was successfully returned in controller's action.
Because I want to store last time the app successfully get the data from the server, so that I can only provide the data after that time if the app is not request specific time of data.
I looked at play.GlobalSettings, there are onRequest, onBadRequest, OnError, however I can't find onSuccess kind of global handler.
It would be very appreciated if anybody give me some ideas in this case.
I did as follows on GlobalSettings#onRequest,
@Override
public Action onRequest(Request request, Method method) {
return new Action.Simple() {
@Override
public Promise<SimpleResult> call(Context context) throws Throwable {
// TODO: do something before actual action call.
Promise<SimpleResult> call = delegate.call(context);
Callback<SimpleResult> callbackOnRedeem = new Callback<SimpleResult>() {
@Override
public void invoke(SimpleResult result) throws Throwable {
// TODO : do something after action call.
}
};
call.onRedeem(callbackOnRedeem);
return call;
}
};
}
Javadoc for onRedeem:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.