@Singleton
public class Environment
extends java.lang.Object
Captures concerns relating to the classloader and the filesystem for the application.
Constructor and Description |
---|
Environment(play.api.Environment environment) |
Environment(java.io.File rootPath) |
Environment(java.io.File rootPath,
java.lang.ClassLoader classLoader,
Mode mode) |
Environment(java.io.File rootPath,
Mode mode) |
Environment(Mode mode) |
Modifier and Type | Method and Description |
---|---|
play.api.Environment |
asScala()
The underlying Scala API Environment object that this Environment wraps.
|
java.lang.ClassLoader |
classLoader()
The classloader that all application classes and resources can be loaded from.
|
java.util.Optional<java.io.File> |
getExistingFile(java.lang.String relativePath)
Retrieves a file relative to the application root path.
|
java.io.File |
getFile(java.lang.String relativePath)
Retrieves a file relative to the application root path.
|
boolean |
isDev()
Returns `true` if the application is `DEV` mode.
|
boolean |
isProd()
Returns `true` if the application is `PROD` mode.
|
boolean |
isTest()
Returns `true` if the application is `TEST` mode.
|
Mode |
mode()
The mode of the application.
|
java.net.URL |
resource(java.lang.String relativePath)
Retrieves a resource from the classpath.
|
java.io.InputStream |
resourceAsStream(java.lang.String relativePath)
Retrieves a resource stream from the classpath.
|
java.io.File |
rootPath()
The root path that the application is deployed at.
|
static Environment |
simple()
A simple environment.
|
play.api.Environment |
underlying()
Deprecated.
As of release 2.6.0. Use
asScala() |
@Inject public Environment(play.api.Environment environment)
public Environment(java.io.File rootPath, java.lang.ClassLoader classLoader, Mode mode)
public Environment(java.io.File rootPath, Mode mode)
public Environment(java.io.File rootPath)
public Environment(Mode mode)
public java.io.File rootPath()
public java.lang.ClassLoader classLoader()
public Mode mode()
public boolean isDev()
public boolean isProd()
public boolean isTest()
public java.io.File getFile(java.lang.String relativePath)
relativePath
- relative path of the file to fetchpublic java.util.Optional<java.io.File> getExistingFile(java.lang.String relativePath)
relativePath
- relative path of the file to fetchpublic java.net.URL resource(java.lang.String relativePath)
relativePath
- relative path of the resource to fetchpublic java.io.InputStream resourceAsStream(java.lang.String relativePath)
relativePath
- relative path of the resource to fetchpublic static Environment simple()
Uses the same classloader that the environment classloader is defined in, the current working directory as the path and test mode.
@Deprecated public play.api.Environment underlying()
asScala()
public play.api.Environment asScala()
Environment