forked from playframework/playframework
JavaInterceptors
Bikiew edited this page Jul 16, 2012
·
7 revisions
One important aspect of the GlobalSettings
class is that it provides a way to intercept requests and execute business logic before a request is dispatched to an action.
For example:
import play.*;
import play.mvc.Action;
import play.mvc.Http.Request;
import java.lang.reflect.Method;
public class Global extends GlobalSettings {
@Override
public Action onRequest(Request request, Method actionMethod) {
System.out.println("before each request..." + request.toString());
return super.onRequest(request, actionMethod);
}
}
It’s also possible to intercept a specific action method. This can be achieved via Action composition.
Next: Testing your application
- HTTP programming
- Asynchronous HTTP programming
- The template engine
- HTTP form submission and validation
- Working with JSON
- Working with XML
- Handling file upload
- Accessing an SQL database
- Using the Cache
- Calling WebServices
- Integrating with Akka
- Internationalization
- The application Global object
- Testing your application