diff --git a/framework/src/play/Play.java b/framework/src/play/Play.java index a8700c0cf0..ce0c4ebc9c 100644 --- a/framework/src/play/Play.java +++ b/framework/src/play/Play.java @@ -70,15 +70,15 @@ public boolean isProd() { /** * The framework ID */ - public static String id; + public static String id = System.getProperty("play.id", ""); /** * The application mode */ - public static Mode mode; + public static Mode mode = Mode.DEV; /** * The application root */ - public static File applicationPath = null; + public static File applicationPath = new File(System.getProperty("application.path", ".")); /** * tmp dir */ @@ -106,11 +106,11 @@ public boolean isProd() { /** * All paths to search for Java files */ - public static List javaPath; + public static List javaPath = new CopyOnWriteArrayList<>(); /** * All paths to search for templates files */ - public static List templatesPath; + public static List templatesPath = new ArrayList<>(2); /** * Main routes file */ @@ -118,7 +118,7 @@ public boolean isProd() { /** * Plugin routes files */ - public static Map modulesRoutes; + public static Map modulesRoutes = new HashMap<>(16); /** * The loaded configuration files */ @@ -126,7 +126,7 @@ public boolean isProd() { /** * The app configuration (already resolved from the framework id) */ - public static Properties configuration; + public static Properties configuration = new Properties(); /** * The last time than the application has started */ @@ -262,24 +262,24 @@ public static void init(File root, String id) { // Build basic java source path VirtualFile appRoot = VirtualFile.open(applicationPath); + roots.clear(); roots.add(appRoot); - javaPath = new CopyOnWriteArrayList<>(); + + javaPath.clear(); javaPath.add(appRoot.child("app")); javaPath.add(appRoot.child("conf")); // Build basic templates path + templatesPath.clear(); if (appRoot.child("app/views").exists() || (usePrecompiled && appRoot.child("precompiled/templates/app/views").exists())) { - templatesPath = new ArrayList<>(2); templatesPath.add(appRoot.child("app/views")); - } else { - templatesPath = new ArrayList<>(1); } - + // Main route file routes = appRoot.child("conf/routes"); // Plugin route files - modulesRoutes = new HashMap<>(16); + modulesRoutes.clear(); // Load modules loadModules(appRoot); diff --git a/framework/src/play/db/Evolutions.java b/framework/src/play/db/Evolutions.java index 5a94493492..701008cf53 100644 --- a/framework/src/play/db/Evolutions.java +++ b/framework/src/play/db/Evolutions.java @@ -47,16 +47,11 @@ public class Evolutions extends PlayPlugin { public static void main(String[] args) throws SQLException { /** Start the DB plugin **/ - Play.id = System.getProperty("play.id"); - Play.applicationPath = new File(System.getProperty("application.path")); Play.guessFrameworkPath(); Play.readConfiguration(); - Play.javaPath = new ArrayList<>(); Play.classes = new ApplicationClasses(); Play.classloader = new ApplicationClassloader(); - Play.templatesPath = new ArrayList<>(); - Play.modulesRoutes = new HashMap<>(); Play.loadModules(VirtualFile.open(Play.applicationPath)); if (System.getProperty("modules") != null) { diff --git a/framework/src/play/i18n/Messages.java b/framework/src/play/i18n/Messages.java index 38929519b8..0c3f39d1ab 100644 --- a/framework/src/play/i18n/Messages.java +++ b/framework/src/play/i18n/Messages.java @@ -32,11 +32,11 @@ public class Messages { private static final Object[] NO_ARGS = new Object[] { null }; - static public Properties defaults; + public static Properties defaults = new Properties(); - static public Map locales = new HashMap<>(); + public static Map locales = new HashMap<>(); - static Pattern recursive = Pattern.compile("&\\{(.*?)\\}"); + private static final Pattern recursive = Pattern.compile("&\\{(.*?)\\}"); /** * Given a message code, translate it using current locale. If there is no @@ -107,7 +107,7 @@ public static String getMessage(String locale, Object key, Object... args) { if (value == null && locale != null && locale.length() == 5 && locales.containsKey(locale.substring(0, 2))) { value = locales.get(locale.substring(0, 2)).getProperty(key.toString()); } - if (value == null && defaults != null) { + if (value == null) { value = defaults.getProperty(key.toString()); } if (value == null) { @@ -196,7 +196,7 @@ public static Properties all(String locale) { return defaults; Properties mergedMessages = new Properties(); mergedMessages.putAll(defaults); - if (locale != null && locale.length() == 5 && locales.containsKey(locale.substring(0, 2))) { + if (locale.length() == 5 && locales.containsKey(locale.substring(0, 2))) { mergedMessages.putAll(locales.get(locale.substring(0, 2))); } mergedMessages.putAll(locales.get(locale)); diff --git a/framework/src/play/jobs/JobsPlugin.java b/framework/src/play/jobs/JobsPlugin.java index bfe0124cd3..12d07c4ca1 100644 --- a/framework/src/play/jobs/JobsPlugin.java +++ b/framework/src/play/jobs/JobsPlugin.java @@ -29,7 +29,7 @@ public class JobsPlugin extends PlayPlugin { public static ScheduledThreadPoolExecutor executor; - public static List scheduledJobs; + public static List scheduledJobs = new ArrayList<>(); private static final ThreadLocal>> afterInvocationActions = new ThreadLocal<>(); @Override @@ -183,7 +183,7 @@ private Job createJob(Class clazz) throws InstantiationException, IllegalA public void onApplicationStart() { int core = Integer.parseInt(Play.configuration.getProperty("play.jobs.pool", "10")); executor = new ScheduledThreadPoolExecutor(core, new PThreadFactory("jobs"), new ThreadPoolExecutor.AbortPolicy()); - scheduledJobs = new ArrayList<>(); + scheduledJobs.clear(); } public static void scheduleForCRON(Job job) {