Created
October 31, 2015 22:23
-
-
Save agnaldo4j/875aa2613ba493883510 to your computer and use it in GitHub Desktop.
Implementação de servidor jetty embarcado com Java WebSocket API e Scalatra. :-)
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
def main(args: Array[String]) { | |
val port = restApiConfig.getInt("port") | |
println(restApiConfig.getString("resourceBase")) | |
val server = new Server(port) | |
val context = new WebAppContext() | |
context setContextPath "/" | |
context.setResourceBase(restApiConfig.getString("resourceBase")) | |
context.setInitParameter(ScalatraListener.LifeCycleKey, "com.opportunity.simple.restapi.ScalatraBootstrap") | |
context.addEventListener(new ScalatraListener) | |
context.addServlet(classOf[DefaultServlet],"/") | |
server.setHandler(context) | |
val wscontainer:ServerContainer = WebSocketServerContainerInitializer.configureContext(context) | |
wscontainer.setDefaultMaxSessionIdleTimeout(1000 * 60 * 30) | |
wscontainer.addEndpoint(classOf[MyEchoSocket]) | |
server.start | |
server.join | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment