2011-05-23 11:37:56 -04:00
|
|
|
/**
|
2011-07-14 16:03:08 +02:00
|
|
|
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
|
2011-05-23 11:37:56 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package akka.servlet
|
|
|
|
|
|
2011-08-29 11:44:33 +02:00
|
|
|
import akka.cluster.BootableRemoteActorService
|
2011-05-23 11:37:56 -04:00
|
|
|
import akka.actor.BootableActorLoaderService
|
|
|
|
|
import akka.config.Config
|
|
|
|
|
import akka.util.{ Bootable, AkkaLoader }
|
|
|
|
|
|
|
|
|
|
import javax.servlet.{ ServletContextListener, ServletContextEvent }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This class can be added to web.xml mappings as a listener to start and postStop Akka.
|
|
|
|
|
*
|
|
|
|
|
* <web-app>
|
|
|
|
|
* ...
|
|
|
|
|
* <listener>
|
|
|
|
|
* <listener-class>akka.servlet.Initializer</listener-class>
|
|
|
|
|
* </listener>
|
|
|
|
|
* ...
|
|
|
|
|
* </web-app>
|
|
|
|
|
*/
|
|
|
|
|
class Initializer extends ServletContextListener {
|
|
|
|
|
lazy val loader = new AkkaLoader
|
|
|
|
|
|
|
|
|
|
def contextDestroyed(e: ServletContextEvent): Unit =
|
|
|
|
|
loader.shutdown
|
|
|
|
|
|
|
|
|
|
def contextInitialized(e: ServletContextEvent): Unit =
|
|
|
|
|
loader.boot(true, new BootableActorLoaderService with BootableRemoteActorService)
|
|
|
|
|
}
|