Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3 from ryanbrainard/2.1.1

Scalatra 2.1.1 Update
  • Loading branch information...
commit 88b51631b77bdcfe8917e75ea83b6ca80ce2b8cf 2 parents 4ca3f5d + d15d069
Lincoln Stoll authored
19 build.sbt
View
@@ -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/"
15 src/main/scala/JettyLauncher.scala
View
@@ -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 src/main/scala/Scalatra.scala
View
@@ -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 src/main/webapp/WEB-INF/web.xml
View
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.