-
Notifications
You must be signed in to change notification settings - Fork 60
/
PingApplicationLoader.scala
59 lines (48 loc) · 1.74 KB
/
PingApplicationLoader.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package loader
import com.ybrikman.ping.scalaapi.dedupe.{CacheFilter, DedupingCache}
import controllers._
import data.{ServiceClient, FutureUtil, FakeServiceClient}
import play.api.libs.ws.WSResponse
import play.api.libs.ws.ning.NingWSComponents
import play.api.routing.Router
import play.api.{BuiltInComponentsFromContext, Application, ApplicationLoader}
import play.api.ApplicationLoader.Context
import router.Routes
import play.api.libs.concurrent.Execution.Implicits._
import scala.concurrent.Future
/**
* This is the entry point for loading this Play app, as configured in conf/application.conf.
*/
class PingApplicationLoader extends ApplicationLoader {
override def load(context: Context): Application = {
new PingComponents(context).application
}
}
/**
* Compile-time dependency injection for this Play app.
*
* @param context
*/
class PingComponents(context: Context) extends BuiltInComponentsFromContext(context) with NingWSComponents {
val cache = new DedupingCache[String, Future[WSResponse]]
val futureUtil = new FutureUtil(actorSystem)
val fakeServiceClient = new FakeServiceClient(futureUtil)
val serviceClient = new ServiceClient(wsClient, cache)
val withoutBigPipe = new WithoutBigPipe(fakeServiceClient)
val withBigPipe = new WithBigPipe(fakeServiceClient)
val moreBigPipeExamples = new MoreBigPipeExamples(fakeServiceClient)
val deduping = new Deduping(serviceClient)
val mock = new Mock
val assets = new Assets(httpErrorHandler)
val routes = new Routes(
httpErrorHandler,
withoutBigPipe,
withBigPipe,
moreBigPipeExamples,
deduping,
mock,
assets)
override val router: Router = routes
val cacheFilter = new CacheFilter(cache)
override lazy val httpFilters = Seq(cacheFilter)
}