play
Class GlobalSettings

java.lang.Object
  extended by play.GlobalSettings

public class GlobalSettings
extends java.lang.Object

GlobalSettings is instantiated by the framework when an application starts, to let you perform specific tasks at start-up or shut-down.

How to use it: create a Global.java class in your Java application and override the methods you want.


Constructor Summary
GlobalSettings()
           
 
Method Summary
 void beforeStart(Application app)
          Executed before any plugin - you can set-up your database schema here, for instance.
 Result onBadRequest(java.lang.String uri, java.lang.String error)
          Triggered when a resource was requested but not found, the default implementation returns null, so that the Scala engine handles the onBadRequest.
 Result onError(java.lang.Throwable t)
          Returns a Result that could be a custom error page.
 Result onHandlerNotFound(java.lang.String uri)
          Triggered when a resource was requested but not found.
 Action onRequest(Http.Request request, java.lang.reflect.Method actionMethod)
          Call to create the root Action of a request for a Java application.
 void onStart(Application app)
          Executed after all plugins, including the database set-up with Evolutions and the EBean wrapper.
 void onStop(Application app)
          Executed when the application stops.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlobalSettings

public GlobalSettings()
Method Detail

beforeStart

public void beforeStart(Application app)
Executed before any plugin - you can set-up your database schema here, for instance.


onStart

public void onStart(Application app)
Executed after all plugins, including the database set-up with Evolutions and the EBean wrapper. This is a good place to execute some of your application code to create entries, for instance.


onStop

public void onStop(Application app)
Executed when the application stops.


onError

public Result onError(java.lang.Throwable t)
Returns a Result that could be a custom error page. The default implementation returns null, so that the Scala engine handles the excepetion and show an error page.

Parameters:
t - is any throwable
Returns:
null as the default implementation

onRequest

public Action onRequest(Http.Request request,
                        java.lang.reflect.Method actionMethod)
Call to create the root Action of a request for a Java application. The request and actionMethod values are passed for information.

Parameters:
request - The HTTP Request
actionMethod - The action method containing the user code for this Action.
Returns:
The default implementation returns a raw Action calling the method.

onHandlerNotFound

public Result onHandlerNotFound(java.lang.String uri)
Triggered when a resource was requested but not found. The default implementation returns null, so that the Scala engine handles the onActionNotFound.

Parameters:
uri - the request URI
Returns:
null in the default implementation, you can return your own custom Result in your Global class.

onBadRequest

public Result onBadRequest(java.lang.String uri,
                           java.lang.String error)
Triggered when a resource was requested but not found, the default implementation returns null, so that the Scala engine handles the onBadRequest.

Parameters:
uri - the request URI
Returns:
null in the default implementation, you can return your own custom Result in your Global class.