I am new to Play and Scala, and I am reading Play for Scala from Manning press. I would like to use the instructions to use Squeryl instead of Anorm.
The book mentions that I need to initialize Squeryl in a class that extends GlobalSettings.
import org.squeryl.adapters.H2Adapter
import org.squeryl.{Session, SessionFactory}
import play.api.db.DB import play.api.{Application, GlobalSettings}
object Global extends GlobalSettings {
SessionFactory.concreteFactory = Some(() =>
Session.create(DB.getConnection()(app), new H2Adapter) )
...
As this is an early edition (MEAP) it is not clear about where to place this code... So I after a little digging on the play site I found the following example that extends GlobalSettings
import play.api._
object Global extends GlobalSettings {
override def onStart(app: Application) {
Logger.info("Application has started")
}
override def onStop(app: Application) {
Logger.info("Application shutdown...")
}
}
The play example gives a little more help but I am still unable to follow the directions, which state : This object must be defined in the default (empty) package.
Which leads to my question: Where does one place a scala file in the Play Framework 2.0 so that it is complied as part of the default package?
Thanks for any help...
GlobalSettings object typically resides in app/Global.scala. Look at zentasks sample.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With