@Override public void onStart(Application app) { if (Play.application().configuration().getString("app.envirement").equals("dev")) { AppConfig.setupDevEnv(); } else if (Play.application().configuration().getString("app.envirement").equals("test")) { AppConfig.setupTestEnv(); } else if (Play.application().configuration().getString("app.envirement").equals("prod")) { AppConfig.setupProdEnv(); } play.libs.Akka.system() .scheduler() .schedule( Duration.create(0, TimeUnit.MILLISECONDS), Duration.create(1, TimeUnit.DAYS), new Runnable() { public void run() { System.out.println("tick"); File dir = new File(AppConfig.temporaryFilesDirectory); for (String fname : dir.list()) { if (fname.equals(".") || fname.equals("..")) continue; File tmp = new File(AppConfig.temporaryFilesDirectory + fname); if (tmp.exists() && tmp.isFile() && (new Date().getTime() - tmp.lastModified()) > (30L * 86400L * 1000L)) { tmp.delete(); } } } }); super.onStart(app); }
@Override public void onStart(Application application) { tweetUrl = Play.application().configuration().getString("tweet.url"); sentimentUrl = Play.application().configuration().getString("sentiment.url"); if ((sentimentUrl == null) || (tweetUrl == null)) { throw new RuntimeException("Both sentiment.url and tweet.url configs must be specified"); } usersActor = Akka.system().actorOf(new Props(UsersActor.class), "users"); stockHolderActor = Akka.system().actorOf(new Props(StockHolderActor.class), "stocks"); // fetch a new data point once every second Akka.system() .scheduler() .schedule( Duration.Zero(), Duration.create(50, TimeUnit.MILLISECONDS), stockHolderActor, FetchLatest.instance(), Akka.system().dispatcher()); super.onStart(application); }
@Override public void onStart(Application app) { Logger.info("Global - onStart"); super.onStart(app); /* * Sets the schedule for cleaning the media temp directory */ Akka.system() .scheduler() .schedule( Duration.create(0, TimeUnit.MILLISECONDS), Duration.create(30, TimeUnit.MINUTES), new Runnable() { public void run() { MediaController.cleanUpTemp(); } }, Akka.system().dispatcher()); InitialData.insert(app); }
@Override public void onStart(Application application) { // System.out.println("アプリケーションスタート"); TimeTableTaskActorBase.getInstance().start(); super.onStart(application); }