Package play

Class PlayPlugin

java.lang.Object
play.PlayPlugin
All Implemented Interfaces:
Comparable<PlayPlugin>
Direct Known Subclasses:
AuthenticityTokenPlugin, DBPlugin, JobsPlugin, JPAPlugin, MessagesPlugin, PlayStatusPlugin, RePlayLogoPlugin, RequestLogPlugin, TempFilePlugin, ValidationPlugin, WS

public abstract class PlayPlugin extends Object implements Comparable<PlayPlugin>
A framework plugin
  • Field Details

    • index

      public int index
      Plugin priority (0 for highest priority)
  • Constructor Details

    • PlayPlugin

      public PlayPlugin()
  • Method Details

    • disable

      protected void disable()
    • isEnabled

      public boolean isEnabled()
    • onLoad

      public void onLoad()
      Called at plugin loading
    • bind

      public Object bind(Http.Request request, Scope.Session session, RootParamNode rootParamNode, String name, Class<?> clazz, Type type, Annotation[] annotations)
      Called when play need to bind a Java object from HTTP params.
      Parameters:
      rootParamNode - parameters to bind
      name - the name of the object
      clazz - the class of the object to bind
      type - type
      annotations - annotation on the object
      Returns:
      binding object
    • getMessage

      public Optional<String> getMessage(String locale, Object key, Object... args)
      Translate the given key for the given locale and arguments. If null is returned, Play's normal message translation mechanism will be used.
      Parameters:
      locale - the locale we want
      key - the message key
      args - arguments of the messages
      Returns:
      the formatted string
    • getStatus

      public String getStatus()
      Return the plugin status
      Returns:
      the plugin status
    • getJsonStatus

      public com.google.gson.JsonObject getJsonStatus()
      Return the plugin status in JSON format
      Returns:
      the plugin status in JSON format
    • rawInvocation

      public boolean rawInvocation(Http.Request request, Http.Response response, Scope.Session session, Scope.RenderArgs renderArgs, Scope.Flash flash) throws Exception
      Give a chance to this plugin to fully manage this request
      Parameters:
      request - The Play request
      response - The Play response
      Returns:
      true if this plugin has managed this request
      Throws:
      Exception
    • loadTemplate

      public Optional<Template> loadTemplate(File file)
      Parameters:
      file - the file of the template to load
      Returns:
      the template object
    • detectChange

      public void detectChange()
      It's time for the plugin to detect changes. Throw an exception is the application must be reloaded.
    • onApplicationStart

      public void onApplicationStart()
      Called at application start (and at each reloading) Time to start stateful things.
    • afterApplicationStart

      public void afterApplicationStart()
      Called after the application start.
    • onApplicationStop

      public void onApplicationStop()
      Called at application stop (and before each reloading) Time to shut down stateful things.
    • beforeInvocation

      public void beforeInvocation()
      Called before a Play! invocation. Time to prepare request specific things.
    • afterInvocation

      public void afterInvocation()
      Called after an invocation. (unless an exception has been thrown). Time to close request specific things.
    • onActionInvocationException

      public void onActionInvocationException(@Nonnull Http.Request request, @Nonnull Http.Response response, @Nonnull Throwable e)
    • onJobInvocationException

      public void onJobInvocationException(@Nonnull Throwable e)
    • onJobInvocationFinally

      public void onJobInvocationFinally()
    • beforeActionInvocation

      public void beforeActionInvocation(Http.Request request, Http.Response response, Scope.Session session, Scope.RenderArgs renderArgs, Scope.Flash flash, Method actionMethod)
      Called before an 'action' invocation, ie an HTTP request processing.
    • onActionInvocationResult

      public void onActionInvocationResult(@Nonnull Http.Request request, @Nonnull Http.Response response, @Nonnull Scope.Session session, @Nonnull Scope.Flash flash, @Nonnull Scope.RenderArgs renderArgs, @Nonnull Result result)
      Called when the action method has thrown a result.
      Parameters:
      result - The result object for the request.
    • onActionInvocationResult

      @Deprecated public void onActionInvocationResult(Http.Request request, Http.Response response, Scope.Session session, Scope.RenderArgs renderArgs, Result result)
      Deprecated.
      Use/override method with flash parameter
    • onInvocationSuccess

      public void onInvocationSuccess()
    • afterActionInvocation

      public void afterActionInvocation(Http.Request request, Http.Response response, Scope.Session session, Scope.Flash flash)
      Called at the end of the action invocation.
    • onActionInvocationFinally

      public void onActionInvocationFinally(@Nonnull Http.Request request, @Nonnull Http.Response response)
      Called at the end of the action invocation (either in case of success or any failure). Time to close request-specific things.
    • onConfigurationRead

      public void onConfigurationRead()
      Called when the application.conf has been read.
    • routeRequest

      public void routeRequest(Http.Request request)
      Let some plugins route themselves
      Parameters:
      request - the current request
    • compareTo

      public int compareTo(PlayPlugin o)
      Specified by:
      compareTo in interface Comparable<PlayPlugin>