Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79209214
Boot.scala
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Aug 25, 07:07
Size
1 KB
Mime Type
text/x-c++
Expires
Tue, Aug 27, 07:07 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20161784
Attached To
R2664 SHRINE MedCo Fork
Boot.scala
View Options
package
net.shrine.dashboard
import
akka.actor.
{
ActorRef
,
ActorSystem
,
Props
}
import
net.shrine.log.Log
import
net.shrine.problem.
{
AbstractProblem
,
ProblemHandler
,
ProblemSources
}
import
net.shrine.source.ConfigSource
import
spray.servlet.WebBoot
import
scala.util.control.NonFatal
// this class is instantiated by the servlet initializer
// it needs to have a default constructor and implement
// the spray.servlet.WebBoot trait
class
Boot
extends
WebBoot
{
println
(
"Start of dashboard boot"
)
Log
.
info
(
"Start of dashboard boot"
)
// we need an ActorSystem to host our application in
override
val
system
=
startActorSystem
()
// the service actor replies to incoming HttpRequests
override
val
serviceActor
:
ActorRef
=
startServiceActor
()
def
startActorSystem
()
=
try
ActorSystem
(
"DashboardActors"
,
ConfigSource
.
config
)
catch
{
case
NonFatal
(
x
)
=>
CannotStartDashboard
(
x
);
throw
x
case
x
:
ExceptionInInitializerError
=>
CannotStartDashboard
(
x
);
throw
x
}
def
startServiceActor
()
=
try
{
//TODO: create a common interface for Problems to hide behind, so that it doesn't exist anywhere in the code
//TODO: except for when brought into scope by a DatabaseProblemHandler
val
handler
:
ProblemHandler
=
ConfigSource
.
getObject
(
"shrine.problem.problemHandler"
,
ConfigSource
.
config
)
handler
.
warmUp
()
// the service actor replies to incoming HttpRequests
system
.
actorOf
(
Props
[
DashboardServiceActor
])
}
catch
{
case
NonFatal
(
x
)
=>
CannotStartDashboard
(
x
);
throw
x
case
x
:
ExceptionInInitializerError
=>
CannotStartDashboard
(
x
);
throw
x
}
println
(
"End of dashboard boot"
)
Log
.
info
(
"End of dashboard boot"
)
}
case
class
CannotStartDashboard
(
ex
:
Throwable
)
extends
AbstractProblem
(
ProblemSources
.
Dsa
)
{
override
def
summary
:
String
=
"The Dashboard could not start due to an exception."
override
def
description
:
String
=
s
"The Dashboard could not start due to ${throwable.get}"
override
def
throwable
=
Some
(
ex
)
}
Event Timeline
Log In to Comment