13cfae9 Jun 13, 2014
@fwbrasil @b0c1
136 lines (92 sloc) 3.96 KB


Activate is a framework to persist objects in Scala. It is a STM (Software Transactional Memory) distributed and durable with pluggable persistence. Its core is the RadonSTM, which provides a powerful mechanism for controlling transactions in memory, analogous to the transactions of databases, to do optimistic concurrency control. The durability of transactions is pluggable and can use persistence in different paradigms such as relational (JDBC), prevalence (Prevayler) and non-relational (MongoDB). The framework also has support for polyglot persistence using distributed transactions.


Activate requires Java 7.

Sample code


import net.fwbrasil.activate.ActivateContext

object persistenceContext extends ActivateContext {
  val storage = StorageFactory.fromSystemProperties("myStorage")

import persistenceContext._

class Person(var name: String) extends Entity

class CreatePersonTableMigration extends Migration {
  def timestamp = 2012111616051
  def up = {

object simpleMain extends App {

  transactional {
    new Person("John")

  val john = transactional {
    select[Person].where( :== "John").head

  transactional { = "John Doe"

  transactional {


The main benefits of the framework are:

  • Atomic, consistent, isolated and durable transactions. You can use entities without worrying about concurrency issues.
  • Easy and transparent polyglot persistence.
  • Entities are always consistent in memory and in the persistence layer. For example, if rollback occurs, entities in memory stay consistent.
  • Transaction propagation control, including nested transactions.
  • Transaction execution is a non-blocking operation.
  • Entities are lazy loaded and initialized automatically when needed.
  • Queries are type-safe and consistent, even with objects created in the current transaction.
  • The available memory is used efficiently, minimizing the conversation with the storage and maximizing performance.

How to get Activate

Repositories URLs to browse artifacts

Repositories roots

Group id: net.fwbrasil

Artifacts ids:

  • activate-core
  • activate-play
  • activate-lift
  • activate-jdbc
  • activate-jdbc-async
  • activate-mongo
  • activate-mongo-async
  • activate-prevayler
  • activate-prevalent
  • activate-slick
  • activate-spray-json

Last version: 1.6

Available scala versions: 2.10

SBT dependency example

"net.fwbrasil" %% "activate-core" % "1.6"

Maven dependency example


Activate example project

A easy way to start with Activate is to use the example project.

Download activate example project.

Install the Simple Build Tool (SBT) following the instructions.

Modify project/ActivateExampleBuild.scala and com/example/foo/ActivateExampleContext.scala to determine the storage. Memory storage is the default value.

Call sbt inside the activate-example folder and create the eclipse project files:

$ sbt

> eclipse

Now you can import into eclipse. It is necessary that the scala plugin is installed

If you want to change the storage, simply change the two classes mentioned above, open the console and rebuild the eclipse project with the same command (“eclipse”).