Package play
Class Environment
java.lang.Object
play.Environment
The environment for the application.
Captures concerns relating to the classloader and the filesystem for the application.
-
Constructor Summary
ConstructorsConstructorDescriptionEnvironment(File rootPath) Environment(File rootPath, ClassLoader classLoader, Mode mode) Environment(File rootPath, Mode mode) Environment(play.api.Environment environment) Environment(Mode mode) -
Method Summary
Modifier and TypeMethodDescriptionplay.api.EnvironmentasScala()The underlying Scala API Environment object that this Environment wraps.The classloader that all application classes and resources can be loaded from.getExistingFile(String relativePath) Retrieves a file relative to the application root path.Retrieves a file relative to the application root path.booleanisDev()Returns `true` if the application is `DEV` mode.booleanisProd()Returns `true` if the application is `PROD` mode.booleanisTest()Returns `true` if the application is `TEST` mode.mode()The mode of the application.Retrieves a resource from the classpath.resourceAsStream(String relativePath) Retrieves a resource stream from the classpath.rootPath()The root path that the application is deployed at.static Environmentsimple()A simple environment.
-
Constructor Details
-
Environment
public Environment(play.api.Environment environment) -
Environment
-
Environment
-
Environment
-
Environment
-
-
Method Details
-
rootPath
The root path that the application is deployed at.- Returns:
- the path
-
classLoader
The classloader that all application classes and resources can be loaded from.- Returns:
- the class loader
-
mode
The mode of the application.- Returns:
- the mode
-
isDev
public boolean isDev()Returns `true` if the application is `DEV` mode.- Returns:
- `true` if the application is `DEV` mode.
-
isProd
public boolean isProd()Returns `true` if the application is `PROD` mode.- Returns:
- `true` if the application is `PROD` mode.
-
isTest
public boolean isTest()Returns `true` if the application is `TEST` mode.- Returns:
- `true` if the application is `TEST` mode.
-
getFile
Retrieves a file relative to the application root path.- Parameters:
relativePath- relative path of the file to fetch- Returns:
- a file instance - it is not guaranteed that the file exists
-
getExistingFile
Retrieves a file relative to the application root path. This method returns an Optional, using empty if the file was not found.- Parameters:
relativePath- relative path of the file to fetch- Returns:
- an existing file
-
resource
Retrieves a resource from the classpath.- Parameters:
relativePath- relative path of the resource to fetch- Returns:
- URL to the resource (may be null)
-
resourceAsStream
Retrieves a resource stream from the classpath.- Parameters:
relativePath- relative path of the resource to fetch- Returns:
- InputStream to the resource (may be null)
-
simple
A simple environment.Uses the same classloader that the environment classloader is defined in, the current working directory as the path and test mode.
- Returns:
- the environment
-
asScala
public play.api.Environment asScala()The underlying Scala API Environment object that this Environment wraps.- Returns:
- the environment
- See Also:
-
Environment
-