Package play.core

Interface BuildLink


  • public interface BuildLink
    Interface used by the Play build plugin to communicate with an embedded Play server. BuildLink objects are created by the plugin's run command and provided to Play's NettyServer devMode methods.

    This interface is written in Java and uses only Java types so that communication can work even when the plugin and embedded Play server are built with different versions of Scala.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.Object[] findSource​(java.lang.String className, java.lang.Integer line)
      Find the original source file for the given class name and line number.
      void forceReload()
      Force the application to reload on the next invocation of reload.
      java.io.File projectPath()
      Get the path of the project.
      java.lang.Object reload()
      Check if anything has changed, and if so, return an updated classloader.
      java.util.Map<java.lang.String,​java.lang.String> settings()
      Returns a list of application settings configured in the build system.
    • Method Detail

      • reload

        java.lang.Object reload()
        Check if anything has changed, and if so, return an updated classloader.

        This method is called multiple times on every request, so it is advised that change detection happens asynchronously to this call, and that this call just check a boolean.

        Returns:
        Either
        • Throwable - If something went wrong (eg, a compile error). PlayException and its sub types can be used to provide specific details on compile errors or other exceptions.
        • ClassLoader - If the classloader has changed, and the application should be reloaded.
        • null - If nothing changed.
      • findSource

        java.lang.Object[] findSource​(java.lang.String className,
                                      java.lang.Integer line)
        Find the original source file for the given class name and line number.

        When the application throws an exception, this will be called for every element in the stack trace from top to bottom until a source file may be found, so that the browser can render the line of code that threw the exception.

        If the class is generated (eg a template), then the original source file should be returned, and the line number should be mapped back to the line number in the original source file, if possible.

        Parameters:
        className - The name of the class to find the source for.
        line - The line number the exception was thrown at.
        Returns:
        Either:
        • [File, Integer] - The source file, and the passed in line number, if the source wasn't generated, or if it was generated, and the line number could be mapped, then the original source file and the mapped line number.
        • [File, null] - If the source was generated but the line number couldn't be mapped, then just the original source file and null for the unmappable line number.
        • null - If no source file could be found for the class name.
      • projectPath

        java.io.File projectPath()
        Get the path of the project. This is used by methods such as play.api.Application#getFile.
        Returns:
        The path of the project.
      • forceReload

        void forceReload()
        Force the application to reload on the next invocation of reload.

        This is invoked by plugins for example that change something on the classpath or something about the application that requires a reload, for example, the evolutions plugin.

      • settings

        java.util.Map<java.lang.String,​java.lang.String> settings()
        Returns a list of application settings configured in the build system.
        Returns:
        The settings.