-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
98 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#Project properties | ||
#Fri Apr 08 20:36:08 CEST 2011 | ||
project.organization=com.dbo | ||
project.name=poc-scalatra | ||
sbt.version=0.7.4 | ||
project.version=1.0 | ||
build.scala.versions=2.8.1 | ||
project.initialize=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
import sbt._ | ||
class build(info: ProjectInfo) extends DefaultWebProject(info) { | ||
// scalatra | ||
val sonatypeNexusSnapshots = "Sonatype Nexus Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots" | ||
val sonatypeNexusReleases = "Sonatype Nexus Releases" at "https://oss.sonatype.org/content/repositories/releases" | ||
val scalatra = "org.scalatra" %% "scalatra" % "2.0.0.M3" | ||
|
||
// jetty | ||
val jetty6 = "org.mortbay.jetty" % "jetty" % "6.1.22" % "test" | ||
val servletApi = "org.mortbay.jetty" % "servlet-api" % "2.5-20081211" % "provided" | ||
|
||
class PocScalatra(info: ProjectInfo) extends DefaultWebProject(info) { | ||
// scalatra | ||
val sonatypeNexusSnapshots = "Sonatype Nexus Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots" | ||
val sonatypeNexusReleases = "Sonatype Nexus Releases" at "https://oss.sonatype.org/content/repositories/releases" | ||
val scalatra = "org.scalatra" %% "scalatra" % "2.0.0.M3" | ||
|
||
|
||
val guice = "com.google.inject" % "guice" % "3.0" | ||
val guiceServlet = "com.google.inject.extensions" % "guice-servlet" % "3.0" | ||
val scalaGuice = "scala-guice" % "scala-guice" % "0.1" from "http://guice-maven.googlecode.com/svn/trunk/scala-guice/scala-guice_2.8.0-0.1.jar" | ||
|
||
|
||
// jetty | ||
val jetty6 = "org.mortbay.jetty" % "jetty" % "6.1.22" % "test" | ||
val servletApi = "org.mortbay.jetty" % "servlet-api" % "2.5-20081211" % "provided" | ||
} | ||
|
20 changes: 20 additions & 0 deletions
20
poc-scalatra/src/main/scala/poc/scalatra/inject/MyGuiceServletConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package poc.scalatra.inject | ||
|
||
import com.google.inject.{Injector, Guice} | ||
import com.google.inject.servlet.GuiceServletContextListener | ||
|
||
|
||
|
||
class MyGuiceServletConfig extends GuiceServletContextListener { | ||
|
||
override def contextInitialized(servletContextEvent: javax.servlet.ServletContextEvent) = { | ||
println("contextInitialized") | ||
getInjector() | ||
} | ||
|
||
override def getInjector():Injector = { | ||
Guice.createInjector(new MyServletModule()); | ||
} | ||
|
||
|
||
} |
15 changes: 15 additions & 0 deletions
15
poc-scalatra/src/main/scala/poc/scalatra/inject/MyServletModule.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package poc.scalatra.inject | ||
|
||
import com.google.inject.servlet.ServletModule | ||
import poc.scalatra.service.BlipService | ||
|
||
|
||
class MyServletModule extends ServletModule { | ||
|
||
override def configureServlets() { | ||
println("configureServlets - ENTER") | ||
serve("/blip/*").`with`(classOf[BlipService]) | ||
println("configureServlets - LEAVE") | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
poc-scalatra/src/main/scala/poc/scalatra/service/BlipService.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package poc.scalatra.service | ||
|
||
import javax.servlet.http.{HttpServletRequest, HttpServletResponse, HttpServlet} | ||
|
||
@com.google.inject.Singleton | ||
class BlipService extends HttpServlet { | ||
|
||
|
||
override def doGet(request: HttpServletRequest, response: HttpServletResponse) = response.getWriter().println("BlipService") | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE web-app | ||
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" | ||
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> | ||
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" | ||
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> | ||
<web-app> | ||
|
||
<servlet> | ||
<servlet-name>WebApp</servlet-name> | ||
<servlet-class>WebApp</servlet-class> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>WebApp</servlet-name> | ||
<url-pattern>/*</url-pattern> | ||
</servlet-mapping> | ||
|
||
|
||
<listener> | ||
<listener-class>poc.scalatra.inject.MyGuiceServletConfig</listener-class> | ||
</listener> | ||
|
||
<filter> | ||
<filter-name>guiceFilter</filter-name> | ||
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class> | ||
</filter> | ||
|
||
<filter-mapping> | ||
<filter-name>guiceFilter</filter-name> | ||
<url-pattern>/*</url-pattern> | ||
</filter-mapping> | ||
|
||
<!--<servlet>--> | ||
<!--<servlet-name>WebApp</servlet-name>--> | ||
<!--<servlet-class>WebApp</servlet-class>--> | ||
<!--</servlet>--> | ||
|
||
<!--<servlet-mapping>--> | ||
<!--<servlet-name>WebApp</servlet-name>--> | ||
<!--<url-pattern>/hello/*</url-pattern>--> | ||
<!--</servlet-mapping>--> | ||
</web-app> | ||
|