Skip to content
This repository has been archived by the owner on Oct 25, 2019. It is now read-only.

Commit

Permalink
update for Scalatra 2.1.1 with use of org.scalatra.servlet.ScalatraLi…
Browse files Browse the repository at this point in the history
…stener
  • Loading branch information
ryanbrainard committed Dec 2, 2012
1 parent 4ca3f5d commit d15d069
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 32 deletions.
19 changes: 10 additions & 9 deletions build.sbt
Expand Up @@ -6,19 +6,20 @@ name := "cider-endpoint"

version := "0.1"

scalaVersion := "2.9.1"
scalaVersion := "2.9.2"

seq(webSettings :_*)

classpathTypes ~= (_ + "orbit")

libraryDependencies ++= Seq(
"org.scalatra" %% "scalatra" % "2.0.1",
"org.scalatra" %% "scalatra-scalate" % "2.0.1",
"org.eclipse.jetty" % "jetty-webapp" % "7.4.5.v20110725" % "container",
"org.eclipse.jetty" % "jetty-server" % "7.4.5.v20110725" % "container",
"org.eclipse.jetty" % "jetty-webapp" % "7.4.5.v20110725",
"org.eclipse.jetty" % "jetty-server" % "7.4.5.v20110725",
"org.slf4j" % "slf4j-simple" % "1.6.1",
"javax.servlet" % "servlet-api" % "2.5" % "provided"
"org.scalatra" % "scalatra" % "2.1.1",
"org.scalatra" % "scalatra-scalate" % "2.1.1",
"org.scalatra" % "scalatra-specs2" % "2.1.1" % "test",
"ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",
"org.eclipse.jetty" % "jetty-server" % "8.1.7.v20120910" % "container;compile",
"org.eclipse.jetty" % "jetty-webapp" % "8.1.7.v20120910" % "container;compile",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar"))
)

resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
Expand Down
15 changes: 8 additions & 7 deletions src/main/scala/JettyLauncher.scala
@@ -1,19 +1,20 @@
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.servlet.{DefaultServlet, ServletContextHandler}
import org.eclipse.jetty.webapp.WebAppContext

object JettyLauncher {
def main(args: Array[String]) {
val port = if(System.getenv("PORT") != null) System.getenv("PORT").toInt else 8080
val port = sys.env.get("PORT").map(_.toInt).getOrElse(8080)

val server = new Server(port)
val context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS)

context.addFilter(classOf[CiderEndpointFilter], "/*", 0)
context.addServlet(classOf[DefaultServlet], "/");
val context = new WebAppContext()
context setContextPath "/"
context.setResourceBase("src/main/webapp")
context.addEventListener(new org.scalatra.servlet.ScalatraListener)

server.setHandler(context)

server.start
server.join
}

}
}
15 changes: 15 additions & 0 deletions src/main/scala/Scalatra.scala
@@ -0,0 +1,15 @@
import org.scalatra._
import javax.servlet.ServletContext

/**
* This is the Scalatra bootstrap file. You can use it to mount servlets or
* filters. It's also a good place to put initialization code which needs to
* run at application start (e.g. database configurations), and init params.
*/
class Scalatra extends LifeCycle {
override def init(context: ServletContext) {

// Mount one or more servlets
context.mount(new CiderEndpointFilter, "/*")
}
}
29 changes: 13 additions & 16 deletions src/main/webapp/WEB-INF/web.xml
@@ -1,18 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<filter>
<filter-name>scalatra</filter-name>
<filter-class>
CiderEndpointFilter
</filter-class>
</filter>

<filter-mapping>
<filter-name>scalatra</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<!--
This listener loads a class in the default package called Scalatra.
That class should should implement org.scalatra.LifeCycle. Your app
can be configured in Scala code there.
-->
<listener>
<listener-class>org.scalatra.servlet.ScalatraListener</listener-class>
</listener>
</web-app>

0 comments on commit d15d069

Please sign in to comment.