package api
Contains the public API for Scala developers.
Access the current Play application
import play.api.Play.current
Read configuration
val poolSize = configuration.getInt("engine.pool.size")
Use the logger
Logger.info("Hello!")
Define a Plugin
class MyPlugin(app: Application) extends Plugin
Create adhoc applications (for testing)
val application = Application(new File("."), this.getClass.getClassloader, None, Play.Mode.DEV)
- Source
- package.scala
- Alphabetic
- By Inheritance
- api
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
trait
Application extends AnyRef
A Play application.
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.
- Annotations
- @implicitNotFound( ... )
-
trait
ApplicationLoader extends AnyRef
Loads an application.
Loads an application. This is responsible for instantiating an application given a context.
Application loaders are expected to instantiate all parts of an application, wiring everything together. They may be manually implemented, if compile time wiring is preferred, or core/third party implementations may be used, for example that provide a runtime dependency injection framework.
During dev mode, an ApplicationLoader will be instantiated once, and called once, each time the application is reloaded. In prod mode, the ApplicationLoader will be instantiated and called once when the application is started.
Out of the box Play provides a Guice module that defines a Java and Scala default implementation based on Guice, as well as various helpers like GuiceApplicationBuilder. This can be used simply by adding the "PlayImport.guice" dependency in build.sbt.
A custom application loader can be configured using the
play.application.loader
configuration property. Implementations must define a no-arg constructor. -
trait
BuiltInComponents extends I18nComponents
Helper to provide the Play built in components.
-
abstract
class
BuiltInComponentsFromContext extends BuiltInComponents
Helper that provides all the built in components dependencies from the application loader context
-
trait
ConfigLoader[A] extends AnyRef
A config loader
-
case class
Configuration(underlying: Config) extends Product with Serializable
A full configuration set.
A full configuration set.
The underlying implementation is provided by https://github.com/typesafehub/config.
- underlying
the underlying Config implementation
-
class
DefaultApplication extends Application
- Annotations
- @Singleton()
-
class
DefaultMarkerContext extends MarkerContext
A default marker context.
A default marker context. This is used by
MarkerContext.apply
, but can also be used to provide explicit typing for markers. For example, to define a SecurityContext marker, you can define a case object extending DefaultMarkerContext:case object SecurityMarkerContext extends DefaultMarkerContext(MarkerFactory.getMarker("SECURITY"))
-
case class
Environment(rootPath: File, classLoader: ClassLoader, mode: Mode) extends Product with Serializable
The environment for the application.
The environment for the application.
Captures concerns relating to the classloader and the filesystem for the application.
- rootPath
The root path that the application is deployed at.
- classLoader
The classloader that all application classes and resources can be loaded from.
- mode
The mode of the application.
-
class
Logger extends LoggerLike
A Play logger.
-
trait
LoggerConfigurator extends AnyRef
Runs through underlying logger configuration.
-
trait
LoggerLike extends AnyRef
Typical logger interface.
- trait LowPriorityMarkerContextImplicits extends AnyRef
-
trait
MarkerContext extends AnyRef
A MarkerContext trait, to provide easy access to org.slf4j.Marker in Logger API.
A MarkerContext trait, to provide easy access to org.slf4j.Marker in Logger API. This is usually accessed with a marker through an implicit conversion from a Marker.
implicit val markerContext: MarkerContext = org.slf4j.MarkerFactory.getMarker("EXAMPLEMARKER") log.error("This message will be logged with the EXAMPLEMARKER marker")
-
sealed abstract
class
Mode extends AnyRef
Application mode, either
Dev
,Test
, orProd
.Application mode, either
Dev
,Test
, orProd
.- See also
play.Mode
-
trait
NoHttpFiltersComponents extends AnyRef
A component to mix in when no default filters should be mixed in to BuiltInComponents.
A component to mix in when no default filters should be mixed in to BuiltInComponents.
- See also
- class OptionalSourceMapper extends AnyRef
-
case class
UnexpectedException(message: Option[String] = None, unexpected: Option[Throwable] = None) extends PlayException with Product with Serializable
Generic exception for unexpected error cases.
Value Members
- object Application
- object ApplicationLoader
- object ConfigLoader
-
object
Configuration extends Serializable
This object provides a set of operations to create
Configuration
values.This object provides a set of operations to create
Configuration
values.For example, to load a
Configuration
in a running application:val config = Configuration.load() val foo = config.getString("foo").getOrElse("boo")
The underlying implementation is provided by https://github.com/typesafehub/config.
- object Environment extends Serializable
-
object
Logger extends Logger
High-level API for logging operations.
High-level API for logging operations.
For example, logging with the default application logger:
Logger.info("Hello!")
Logging with a custom logger:
Logger("my.logger").info("Hello!")
- object LoggerConfigurator
- object MarkerContext extends LowPriorityMarkerContextImplicits
- object MarkerContexts
- object Mode
-
object
Play
High-level API to access Play global features.