@Singleton public class Environment extends Object
Captures concerns relating to the classloader and the filesystem for the application.
Constructor and Description |
---|
Environment(play.api.Environment environment) |
Environment(File rootPath) |
Environment(File rootPath,
ClassLoader classLoader,
Mode mode) |
Environment(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.
|
ClassLoader |
classLoader()
The classloader that all application classes and resources can be loaded from.
|
Optional<File> |
getExistingFile(String relativePath)
Retrieves a file relative to the application root path.
|
File |
getFile(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.
|
URL |
resource(String relativePath)
Retrieves a resource from the classpath.
|
InputStream |
resourceAsStream(String relativePath)
Retrieves a resource stream from the classpath.
|
File |
rootPath()
The root path that the application is deployed at.
|
static Environment |
simple()
A simple environment.
|
@Inject public Environment(play.api.Environment environment)
public Environment(File rootPath, ClassLoader classLoader, Mode mode)
public Environment(File rootPath)
public Environment(Mode mode)
public File rootPath()
public ClassLoader classLoader()
public Mode mode()
public boolean isDev()
public boolean isProd()
public boolean isTest()
public File getFile(String relativePath)
relativePath
- relative path of the file to fetchpublic Optional<File> getExistingFile(String relativePath)
relativePath
- relative path of the file to fetchpublic URL resource(String relativePath)
relativePath
- relative path of the resource to fetchpublic InputStream resourceAsStream(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.
public play.api.Environment asScala()
Environment