|
@@ -0,0 +1,56 @@
|
|
|
|
+package bootstrap.liftweb
|
|
|
|
+
|
|
|
|
+import net.liftweb._
|
|
|
|
+import util._
|
|
|
|
+import Helpers._
|
|
|
|
+
|
|
|
|
+import common._
|
|
|
|
+import http._
|
|
|
|
+import sitemap._
|
|
|
|
+import Loc._
|
|
|
|
+import mapper._
|
|
|
|
+
|
|
|
|
+import code._
|
|
|
|
+
|
|
|
|
+import java.util.concurrent.ThreadLocalRandom
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * A class that's instantiated early and run. It allows the application
|
|
|
|
+ * to modify lift's environment
|
|
|
|
+ */
|
|
|
|
+class Boot {
|
|
|
|
+ def boot {
|
|
|
|
+ if (!DB.jndiJdbcConnAvailable_?) {
|
|
|
|
+ val vendor =
|
|
|
|
+ new StandardDBVendor(Props.get("db.driver") openOr "org.h2.Driver",
|
|
|
|
+ Props.get("db.url") openOr
|
|
|
|
+ "jdbc:h2:lift_proto.db;AUTO_SERVER=TRUE",
|
|
|
|
+ Props.get("db.user"), Props.get("db.password"))
|
|
|
|
+
|
|
|
|
+ LiftRules.unloadHooks.append(vendor.closeAllConnections_! _)
|
|
|
|
+
|
|
|
|
+ DB.defineConnectionManager(DefaultConnectionIdentifier, vendor)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Use Lift's Mapper ORM to populate the database
|
|
|
|
+ // you don't need to use Mapper to use Lift... use
|
|
|
|
+ // any ORM you want
|
|
|
|
+ //Schemifier.schemify(true, Schemifier.infoF _, model.World)
|
|
|
|
+
|
|
|
|
+ // where to search snippet
|
|
|
|
+ LiftRules.addToPackages("code")
|
|
|
|
+
|
|
|
|
+ lib.StatelessJson.init()
|
|
|
|
+ lib.StatelessDb.init()
|
|
|
|
+
|
|
|
|
+ // Force the request to be UTF-8
|
|
|
|
+ LiftRules.early.append(_.setCharacterEncoding("UTF-8"))
|
|
|
|
+
|
|
|
|
+ // Use HTML5 for rendering
|
|
|
|
+ LiftRules.htmlProperties.default.set((r: Req) =>
|
|
|
|
+ new Html5Properties(r.userAgent))
|
|
|
|
+
|
|
|
|
+ // Make a transaction span the whole HTTP request
|
|
|
|
+ S.addAround(DB.buildLoanWrapper)
|
|
|
|
+ }
|
|
|
|
+}
|