bitcoin-atm
bitcoin atm for pyc inc.
git clone https://9o.is/git/bitcoin-atm.git
Boot.scala
(2187B)
1 package bootstrap.liftweb
2
3 import net.liftweb._
4 import common._
5 import http._
6 import mapper._
7 import util._
8 import net.liftmodules.extras.LiftExtras
9 import inc.pyc.chimera._
10 import model._
11 import System._
12
13 /**
14 * A class that's instantiated early and run. It allows the application
15 * to modify lift's environment
16 */
17 class Boot extends Loggable {
18 def boot {
19
20 logger.info("Run Mode: " + Props.mode.toString)
21
22 // where to search snippet
23 LiftRules.addToPackages("inc.pyc.chimera")
24
25 // set up Local DB
26 this.setDB()
27
28 // set the default htmlProperties
29 LiftRules.htmlProperties.default.set(
30 (r: Req) => new Html5Properties(r.userAgent))
31
32 // Force the request to be UTF-8
33 LiftRules.early.append(_.setCharacterEncoding("UTF-8"))
34
35 // set name to generate correct minified js and css files
36 LiftExtras.artifactName.default.set("pyc-0.0.1")
37
38 // don't include the liftAjax.js code. It's served statically.
39 LiftRules.autoIncludeAjaxCalc.default.set(() => (session: LiftSession) => false)
40
41 // Does the following at system shutdown
42 LiftRules.unloadHooks.append {
43 () =>
44 lycia.Lycia.stateWatcher ! akka.actor.PoisonPill
45 System.overlord ! akka.actor.PoisonPill
46 System.system.shutdown()
47 }
48 }
49
50 def setDB(): Unit = {
51
52 // set up connection
53 if (!DB.jndiJdbcConnAvailable_?) {
54 val vendor =
55 new StandardDBVendor(
56 "org.h2.Driver",
57 "jdbc:h2:lift_proto.db;AUTO_SERVER=TRUE",
58 Empty, //Full(Settings(system).name),
59 Empty) //Full(Settings(system).secret))
60
61 LiftRules.unloadHooks.append(vendor.closeAllConnections_! _)
62 DB.defineConnectionManager(util.DefaultConnectionIdentifier, vendor)
63 }
64
65 // setup schemas
66 Schemifier.schemify(true, Schemifier.infoF _, CompletedTransaction)
67 Schemifier.schemify(true, Schemifier.infoF _, IncompleteTransaction)
68
69 // setup H2 login
70 // H2 Console
71 if (Props.devMode || Props.testMode) {
72 LiftRules.liftRequest.append({
73 case r if (r.path.partPath match {
74 case "console" :: _ => true
75 case _ => false
76 }) => false
77 })
78 }
79 }
80 }