import java.lang.reflect.Constructor

import models.User
import play.api.Application
import play.api.libs.concurrent.Akka
import play.api.mvc.WithFilters
import securesocial.core.RuntimeEnvironment
import security.{MongoUserService, ApplicationRuntimeEnvironment}
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global

object Global extends WithFilters(HttpsRedirectFilter) {
  override def getControllerInstance[A](controllerClass: Class[A]): A = {
    val instance = controllerClass.getConstructors.find { c =>
      val params = c.getParameterTypes
      params.length == 1 && params(0) == classOf[RuntimeEnvironment[User]]
    }.map {
      _.asInstanceOf[Constructor[A]].newInstance(ApplicationRuntimeEnvironment)
    }
    instance.getOrElse(super.getControllerInstance(controllerClass))
  }
}

import java.lang.reflect.Constructor

import models.User
import play.api.{Logger, Application}
import play.api.libs.concurrent.Akka
import play.api.mvc.WithFilters
import securesocial.core.RuntimeEnvironment
import security.{MongoUserService, ApplicationRuntimeEnvironment}
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global

object Global extends WithFilters(HttpsRedirectFilter) {
  override def getControllerInstance[A](controllerClass: Class[A]): A = {
    val instance = controllerClass.getConstructors.find { c =>
      val params = c.getParameterTypes
      params.length == 1 && params(0) == classOf[RuntimeEnvironment[User]]
    }.map {
      _.asInstanceOf[Constructor[A]].newInstance(ApplicationRuntimeEnvironment)
    }
    instance.getOrElse(super.getControllerInstance(controllerClass))
  }

  override def onStart(app: Application): Unit = {
    Akka.system(app).scheduler.scheduleOnce(10 seconds) {
      Logger.info("Run after 10 seconds")
    }

    Akka.system(app).scheduler.schedule(11 seconds, 1 second) {
      Logger.info("Every second")
    }
  }
}

--- 
+++ 
@@ -1,7 +1,7 @@
 import java.lang.reflect.Constructor
 
 import models.User
-import play.api.{Logger, Application}
+import play.api.Application
 import play.api.libs.concurrent.Akka
 import play.api.mvc.WithFilters
 import securesocial.core.RuntimeEnvironment
@@ -19,14 +19,4 @@
     }
     instance.getOrElse(super.getControllerInstance(controllerClass))
   }
-
-  override def onStart(app: Application): Unit = {
-    Akka.system(app).scheduler.scheduleOnce(10 seconds) {
-      Logger.info("Run after 10 seconds")
-    }
-
-    Akka.system(app).scheduler.schedule(11 seconds, 1 second) {
-      Logger.info("Every second")
-    }
-  }
 }
Revert "Test scheduling on Heroku."

This reverts commit 21067b4915e2817acdaa1d01448d0e30bd841088.
