This repository has been archived by the owner on Oct 25, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update for Scalatra 2.1.1 with use of org.scalatra.servlet.ScalatraLi…
…stener
- Loading branch information
1 parent
4ca3f5d
commit d15d069
Showing
4 changed files
with
46 additions
and
32 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
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,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 | ||
} | ||
|
||
} | ||
} |
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 @@ | ||
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, "/*") | ||
} | ||
} |
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,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> |