Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1228 fix spellling mistake #1229

Merged
merged 2 commits into from
Apr 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion framework/src/play/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static void init() {
}
Logger.log4j = org.apache.log4j.Logger.getLogger("play");
// In test mode, append logs to test-result/application.log
if (Play.runingInTestMode()) {
if (Play.runningInTestMode()) {
org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger();
try {
if (!Play.getFile("test-result").exists()) {
Expand Down
70 changes: 44 additions & 26 deletions framework/src/play/Play.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public class Play {
public enum Mode {

/**
* Enable development-specific features, e.g. view the documentation at the URL {@literal "/@documentation"}.
* Enable development-specific features, e.g. view the documentation at the URL
* {@literal "/@documentation"}.
*/
DEV,
/**
Expand Down Expand Up @@ -155,8 +156,9 @@ public boolean isProd() {
*/
public static PluginCollection pluginCollection = new PluginCollection();
/**
* Readonly list containing currently enabled plugins. This list is updated from pluginCollection when
* pluginCollection is modified Play plugins Use pluginCollection instead.
* Readonly list containing currently enabled plugins. This list is updated from
* pluginCollection when pluginCollection is modified Play plugins Use
* pluginCollection instead.
*/
@Deprecated
public static List<PlayPlugin> plugins = pluginCollection.getEnabledPlugins();
Expand All @@ -181,12 +183,14 @@ public boolean isProd() {
public static boolean lazyLoadTemplates = false;

/**
* This is used as default encoding everywhere related to the web: request, response, WS
* This is used as default encoding everywhere related to the web: request,
* response, WS
*/
public static String defaultWebEncoding = "utf-8";

/**
* This flag indicates if the app is running in a standalone Play server or as a WAR in an applicationServer
* This flag indicates if the app is running in a standalone Play server or as a
* WAR in an applicationServer
*/
public static boolean standalonePlayServer = true;

Expand Down Expand Up @@ -281,7 +285,8 @@ public static void init(File root, String id) {

// Build basic templates path
templatesPath.clear();
if (appRoot.child("app/views").exists() || (usePrecompiled && appRoot.child("precompiled/templates/app/views").exists())) {
if (appRoot.child("app/views").exists()
|| (usePrecompiled && appRoot.child("precompiled/templates/app/views").exists())) {
templatesPath.add(appRoot.child("app/views"));
}

Expand Down Expand Up @@ -342,7 +347,8 @@ public static void guessFrameworkPath() {
URI uri = new URI(versionUrl.toString().replace(" ", "%20"));
if (frameworkPath == null || !frameworkPath.exists()) {
if (uri.getScheme().equals("jar")) {
String jarPath = uri.getSchemeSpecificPart().substring(5, uri.getSchemeSpecificPart().lastIndexOf("!"));
String jarPath = uri.getSchemeSpecificPart().substring(5,
uri.getSchemeSpecificPart().lastIndexOf("!"));
frameworkPath = new File(jarPath).getParentFile().getParentFile().getAbsoluteFile();
} else if (uri.getScheme().equals("file")) {
frameworkPath = new File(uri).getParentFile().getParentFile().getParentFile().getParentFile();
Expand Down Expand Up @@ -473,7 +479,8 @@ public static synchronized void start() {
// Can only register shutdown-hook if running as standalone server
if (!shutdownHookEnabled) {
// registers shutdown hook - Now there's a good chance that we can notify
// our plugins that we're going down when some calls ctrl+c or just kills our process..
// our plugins that we're going down when some calls ctrl+c or just kills our
// process..
shutdownHookEnabled = true;
Thread hook = new Thread() {
@Override
Expand Down Expand Up @@ -505,7 +512,8 @@ public void run() {
if (!Logger.configuredManually) {
Logger.setUp(logLevel);
}
Logger.recordCaller = Boolean.parseBoolean(configuration.getProperty("application.log.recordCaller", "false"));
Logger.recordCaller = Boolean
.parseBoolean(configuration.getProperty("application.log.recordCaller", "false"));

// Locales
langs = new ArrayList<>(Arrays.asList(configuration.getProperty("application.langs", "").split(",")));
Expand Down Expand Up @@ -710,14 +718,16 @@ public static void initStaticStuff() {
}

/**
* Load all modules. You can even specify the list using the MODULES environment variable.
* Load all modules. You can even specify the list using the MODULES environment
* variable.
*/
public static void loadModules() {
loadModules(VirtualFile.open(applicationPath));
}

/**
* Load all modules. You can even specify the list using the MODULES environment variable.
* Load all modules. You can even specify the list using the MODULES environment
* variable.
*
* @param appRoot
* the application path virtual file
Expand All @@ -734,15 +744,17 @@ public static void loadModules(VirtualFile appRoot) {
modulePath.getAbsolutePath());
} else {
String modulePathName = modulePath.getName();
String moduleName = modulePathName.contains("-") ? modulePathName.substring(0, modulePathName.lastIndexOf("-"))
String moduleName = modulePathName.contains("-")
? modulePathName.substring(0, modulePathName.lastIndexOf("-"))
: modulePathName;
addModule(appRoot, moduleName, modulePath);
}
}
}
}

// Load modules from modules/ directory, but get the order from the dependencies.yml file
// Load modules from modules/ directory, but get the order from the
// dependencies.yml file
// .listFiles() returns items in an OS dependant sequence, which is bad
// See #781
// the yaml parser wants play.version as an environment variable
Expand All @@ -757,7 +769,8 @@ public static void loadModules(VirtualFile appRoot) {
DependenciesManager dm = new DependenciesManager(applicationPath, frameworkPath, userHome);
modules = dm.retrieveModules();
} catch (Exception e) {
Logger.error("There was a problem parsing dependencies.yml (module will not be loaded in order of the dependencies.yml)",
Logger.error(
"There was a problem parsing dependencies.yml (module will not be loaded in order of the dependencies.yml)",
e);
// Load module without considering the dependencies.yml order
modules.addAll(Arrays.asList(localModules.list()));
Expand All @@ -773,13 +786,15 @@ public static void loadModules(VirtualFile appRoot) {
}

if (module == null || !module.exists()) {
Logger.error("Module %s will not be loaded because %s does not exist", moduleName, module.getAbsolutePath());
Logger.error("Module %s will not be loaded because %s does not exist", moduleName,
module.getAbsolutePath());
} else if (module.isDirectory()) {
addModule(appRoot, moduleName, module);
} else {
File modulePath = new File(IO.readContentAsString(module).trim());
if (!modulePath.exists() || !modulePath.isDirectory()) {
Logger.error("Module %s will not be loaded because %s does not exist", moduleName, modulePath.getAbsolutePath());
Logger.error("Module %s will not be loaded because %s does not exist", moduleName,
modulePath.getAbsolutePath());
} else {
addModule(appRoot, moduleName, modulePath);
}
Expand All @@ -788,7 +803,7 @@ public static void loadModules(VirtualFile appRoot) {
}

// Auto add special modules
if (Play.runingInTestMode()) {
if (Play.runningInTestMode()) {
addModule(appRoot, "_testrunner", new File(Play.frameworkPath, "modules/testrunner"));
}
}
Expand Down Expand Up @@ -821,12 +836,12 @@ public static void addModule(VirtualFile appRoot, String name, File path) {
if (root.child("app").exists()) {
javaPath.add(root.child("app"));
}
if (root.child("app/views").exists()
|| (usePrecompiled && appRoot.child("precompiled/templates/from_module_" + name + "/app/views").exists())) {
if (root.child("app/views").exists() || (usePrecompiled
&& appRoot.child("precompiled/templates/from_module_" + name + "/app/views").exists())) {
templatesPath.add(root.child("app/views"));
}
if (root.child("conf/routes").exists()
|| (usePrecompiled && appRoot.child("precompiled/templates/from_module_" + name + "/conf/routes").exists())) {
if (root.child("conf/routes").exists() || (usePrecompiled
&& appRoot.child("precompiled/templates/from_module_" + name + "/conf/routes").exists())) {
modulesRoutes.put(name, root.child("conf/routes"));
}
roots.add(root);
Expand Down Expand Up @@ -858,18 +873,21 @@ public static File getFile(String path) {
}

/**
* Returns true if application is runing in test-mode. Test-mode is resolved from the framework id.
* Returns true if application is running in test-mode. Test-mode is resolved
* from the framework id.
*
* Your app is running in test-mode if the framwork id (Play.id) is 'test' or 'test-?.*'
* Your app is running in test-mode if the framework id (Play.id) is 'test' or
* 'test-?.*'
*
* @return true if testmode
* @return true if test mode
*/
public static boolean runingInTestMode() {
public static boolean runningInTestMode() {
return id.matches("test|test-?.*");
}

/**
* Call this method when there has been a fatal error that Play cannot recover from
* Call this method when there has been a fatal error that Play cannot recover
* from
*/
public static void fatalServerErrorOccurred() {
if (standalonePlayServer) {
Expand Down
2 changes: 1 addition & 1 deletion framework/src/play/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public Server(String[] args) {
Logger.error("Could not bind on port " + httpsPort, e);
Play.fatalServerErrorOccurred();
}
if (Play.mode == Mode.DEV || Play.runingInTestMode()) {
if (Play.mode == Mode.DEV || Play.runningInTestMode()) {
// print this line to STDOUT - not using logger, so auto test runner will not block if logger is misconfigured (see #1222)
System.out.println("~ Server is up and running");
}
Expand Down