May 2015
Intermediate to advanced
274 pages
5h 11m
English
Some plugins need to provide users with helper methods to simplify transactions, whereas others need not do anything besides some tasks to be added in the application's life cycle. For example, our NotifierPlugin just sends e-mails on start and stop. Then, the methods of our CassandraPlugin can be accessed using the plugin method of play.api.Application:
object CassandraHelper {
private val casPlugin = Play.application.plugin[CassandraPlugin].get
//complete DB transactions with the connection pool started through the plugin
def executeStmt(stmt:String) = {
casPlugin.session.execute(stmt)
}
}Alternatively, the plugin can also provide a helper object:
object Cassandra { private val casPlugin = Play.application.plugin[CassandraPlugin].get ...Read now
Unlock full access