2009-05-16 10:46:24 +02:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2009 Scalable Solutions.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package se.scalablesolutions.akka.kernel.jersey
|
|
|
|
|
|
2009-07-12 23:08:17 +02:00
|
|
|
import kernel.Kernel
|
|
|
|
|
import config.ConfiguratorRepository
|
2009-07-26 19:12:22 +02:00
|
|
|
import util.Logging
|
2009-07-03 17:15:36 +02:00
|
|
|
|
2009-05-18 08:19:30 +02:00
|
|
|
import com.sun.jersey.api.core.{DefaultResourceConfig, ResourceConfig}
|
2009-05-16 10:46:24 +02:00
|
|
|
import com.sun.jersey.spi.container.servlet.ServletContainer
|
|
|
|
|
import com.sun.jersey.spi.container.WebApplication
|
2009-07-26 19:12:22 +02:00
|
|
|
|
|
|
|
|
import javax.servlet.{ServletConfig}
|
|
|
|
|
import java.net.{URL,URLClassLoader}
|
2009-07-03 17:15:36 +02:00
|
|
|
import java.util.HashSet
|
|
|
|
|
|
2009-07-26 19:12:22 +02:00
|
|
|
|
2009-07-25 21:35:47 +02:00
|
|
|
class AkkaServlet extends ServletContainer{
|
2009-05-16 10:46:24 +02:00
|
|
|
|
|
|
|
|
override def initiate(rc: ResourceConfig, wa: WebApplication) = {
|
2009-07-25 21:35:47 +02:00
|
|
|
// super.initiate(rc, wa)
|
|
|
|
|
|
2009-07-12 23:08:17 +02:00
|
|
|
Kernel.boot // will boot if not already booted by 'main'
|
|
|
|
|
val configurators = ConfiguratorRepository.getConfiguratorsFor(getServletContext);
|
2009-05-18 08:19:30 +02:00
|
|
|
val set = new HashSet[Class[_]]
|
2009-07-03 17:15:36 +02:00
|
|
|
for {
|
|
|
|
|
conf <- configurators
|
|
|
|
|
clazz <- conf.getComponentInterfaces
|
|
|
|
|
} set.add(clazz)
|
2009-05-18 08:19:30 +02:00
|
|
|
|
|
|
|
|
wa.initiate(
|
|
|
|
|
new DefaultResourceConfig(set),
|
2009-07-25 21:35:47 +02:00
|
|
|
new ActorComponentProviderFactory(configurators))
|
2009-05-16 10:46:24 +02:00
|
|
|
}
|
2009-07-26 19:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AkkaCometServlet extends org.atmosphere.cpr.AtmosphereServlet with Logging
|
|
|
|
|
{
|
|
|
|
|
override def init(sconf : ServletConfig) = {
|
|
|
|
|
|
|
|
|
|
val url = sconf.getServletContext().getResource("/WEB-INF/classes/")
|
|
|
|
|
val urlC = new URLClassLoader(Array(url),Thread.currentThread().getContextClassLoader())
|
|
|
|
|
|
|
|
|
|
loadAtmosphereDotXml(sconf.getServletContext.getResourceAsStream("META-INF/atmosphere.xml"), urlC);
|
|
|
|
|
|
|
|
|
|
super.init(sconf)
|
|
|
|
|
}
|
|
|
|
|
}
|