首页  

play Application Settings     所属分类 play 浏览量 686
https://www.playframework.com/documentation/2.8.x/ScalaApplication

A running instance of Play is built around the Application class, 
the starting point for most of the application state for Play. 
The Application is loaded through an ApplicationLoader and is configured with a disposable classloader 
so that changing a setting in development mode will reload the Application.

Application
ApplicationLoader

play.api.Application
play.api.ApplicationLoader

disposable ApplicationLoader
一次性的 可废弃的 ApplicationLoader

开发模式 重新加载 Application

Application configuration has changed in Play 2.5.x so that dependency injection is the primary method of configuration.

A Play application.
Application creation is handled by the framework engine.
If you need to create an ad-hoc application, for example in case of unit testing, you can easily achieve this using:

val application = new DefaultApplication(new File("."), this.getClass.getClassloader, None, Play.Mode.Dev)
 
This will create an application using the current classloader.


trait Application {
  // The absolute path hosting this application, mainly used by the `getFile(path)` helper method
  def path: File

  def classloader: ClassLoader

  // `Dev`, `Prod` or `Test`
  def mode: Mode = environment.mode

  def environment: Environment

  def configuration: Configuration

  private[play] lazy val httpConfiguration =
    HttpConfiguration.fromConfiguration(configuration, environment)

  // The default ActorSystem used by the application.
  def actorSystem: ActorSystem

  // The default Materializer used by the application.
  // 有啥作用?
  implicit def materializer: Materializer

  // The default CoordinatedShutdown to stop the Application
  def coordinatedShutdown: CoordinatedShutdown

  // The factory used to create requests for this application.
  def requestFactory: RequestFactory

  // The HTTP request handler
  def requestHandler: HttpRequestHandler

  // The HTTP error handler
  def errorHandler: HttpErrorHandler

  // Return the application as a Java application.
  def asJava: play.Application = {
    new play.DefaultApplication(this, configuration.underlying, injector.asJava, environment.asJava)
  }

  // Get the runtime injector for this application. 
  // In a runtime dependency injection based application, 
  // this can be used to obtain components as bound by the DI framework.
  def injector: Injector = NewInstanceInjector


}

上一篇     下一篇
scala 多行字符串

scala 元组和多重赋值

play json 操作

akka hello http server

scala中的classOf isInstanceOf asInstanceOf

大数据scala基础