Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does one place a scala file in the Play Framework 2.0 so that it is compiled as part of the default package?

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...

like image 296
Frobbit Avatar asked Jul 04 '12 00:07

Frobbit


1 Answers

GlobalSettings object typically resides in app/Global.scala. Look at zentasks sample.

like image 71
lambdas Avatar answered Nov 15 '22 23:11

lambdas