Skip to content

Commit

Permalink
Fix warnings in 2.8 examples (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
takezoe authored Sep 25, 2021
1 parent d2e2517 commit e01ca01
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import javax.servlet.ServletContext
class ScalatraBootstrap extends LifeCycle {

val system = ActorSystem()
val myActor = system.actorOf(Props[MyActor])
val myActor = system.actorOf(Props.apply[MyActor]())

override def init(context: ServletContext) {
override def init(context: ServletContext) = {
context.mount(new FutureController(system), "/*")
context.mount(new MyActorApp(system, myActor), "/actors/*")
}

override def destroy(context:ServletContext) {
override def destroy(context:ServletContext) = {
system.terminate()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MyActorApp(system:ActorSystem, myActor:ActorRef) extends ScalatraServlet w

class MyActor extends Actor {
def receive = {
case "Do stuff and give me an answer" => sender ! "The answer is 42"
case "Do stuff and give me an answer" => sender() ! "The answer is 42"
case "Hey, you know what?" => println("Yeah I know... oh boy do I know")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.eclipse.jetty.servlet.{ DefaultServlet, ServletContextHandler }
import org.eclipse.jetty.webapp.WebAppContext

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

val server = new Server(port)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.scalatra._
import javax.servlet.ServletContext

class ScalatraBootstrap extends LifeCycle {
override def init(context: ServletContext) {
override def init(context: ServletContext) = {
context.mount(new HerokuApp, "/*")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.scalatra._
import javax.servlet.ServletContext

class ScalatraBootstrap extends LifeCycle {
override def init(context: ServletContext) {
override def init(context: ServletContext) = {
context.mount(new FormsController, "/*")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.scalatra._
import javax.servlet.ServletContext

class ScalatraBootstrap extends LifeCycle {
override def init(context: ServletContext) {
override def init(context: ServletContext) = {
context.mount(new AuthDemo, "/*")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.scalatra._
class AuthDemo extends ScalatraServlet with AuthenticationSupport {

get("/*") {
val user: User = basicAuth.get
val user: User = basicAuth().get

<html>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.scalatra._
import javax.servlet.ServletContext

class ScalatraBootstrap extends LifeCycle {
override def init(context: ServletContext) {
override def init(context: ServletContext) = {
context.mount(new GZipApp, "/*")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.scalatra._
import javax.servlet.ServletContext

class ScalatraBootstrap extends LifeCycle {
override def init(context: ServletContext) {
override def init(context: ServletContext) = {
context.mount(new CookiesExample, "/cookies-example")
context.mount(new FileUploadExample, "/upload")
context.mount(new FilterExample, "/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.scalatra._
import javax.servlet.ServletContext

class ScalatraBootstrap extends LifeCycle {
override def init(context: ServletContext) {
override def init(context: ServletContext) = {
context.mount(new ProtectedController, "/*")
context.mount(new SessionsController, "/sessions/*")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class UserPasswordStrategy(protected val app: ScalatraBase)
/**
* What should happen if the user is currently not authenticated?
*/
override def unauthenticated()(implicit request: HttpServletRequest, response: HttpServletResponse) {
override def unauthenticated()(implicit request: HttpServletRequest, response: HttpServletResponse) = {
app.redirect("/sessions/new")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.mongodb.scala.MongoClient
import org.scalatra.example.MongoController

class ScalatraBootstrap extends LifeCycle {
override def init(context: ServletContext) {
override def init(context: ServletContext) = {

// As you can see, there's not much to do in order to get MongoDb working with Scalatra.
// We're connecting with default settings - localhost on port 27017 -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MongoController(collection: MongoCollection[Document]) extends ScalatraMon
* Retrieve everything in the MongoDb collection we're currently using.
*/
get("/") {
collection.find().results().map(doc => doc.toJson)
collection.find().results().map(doc => doc.toJson())
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import scala.concurrent.duration._
class ScalatraMongoExample extends ScalatraServlet {

implicit class DocumentObservable[C](val observable: Observable[Document]) extends ImplicitObservable[Document] {
override val converter: (Document) => String = (doc) => doc.toJson
override val converter: (Document) => String = (doc) => doc.toJson()
}

implicit class GenericObservable[C](val observable: Observable[C]) extends ImplicitObservable[C] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ class ScalatraBootstrap extends LifeCycle {
val cpds = new ComboPooledDataSource
logger.info("Created c3p0 connection pool")

override def init(context: ServletContext) {
override def init(context: ServletContext) = {
val db = Database.forDataSource(cpds, None)
context.mount(new SlickApp(db), "/*")
}

private def closeDbConnection() {
private def closeDbConnection() = {
logger.info("Closing c3po connection pool")
cpds.close
}

override def destroy(context: ServletContext) {
override def destroy(context: ServletContext) = {
super.destroy(context)
closeDbConnection
closeDbConnection()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ScalatraBootstrap extends LifeCycle with DatabaseInit {
configureDb
context mount (new ArticlesController, "/*")
}

override def destroy(context:ServletContext) = {
closeDbConnection
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import org.scalatra.example.models.BlogDb
import java.util.Random
import java.util.Collections

class ArticlesController extends ScalatraServlet
class ArticlesController extends ScalatraServlet
with SessionSupport
with DatabaseSessionSupport
with DatabaseSessionSupport
with MethodOverride
with FlashMapSupport
with PrimitiveTypeMode {
Expand All @@ -22,21 +22,21 @@ class ArticlesController extends ScalatraServlet

get("/") {
contentType = "text/html"

val articles = from(BlogDb.articles)(select(_))
html.index(articles.toList)
}
val newArticle = get("/articles/new") {

val newArticle = get("/articles/new") {
contentType = "text/html"

val article = new Article()
html.form(article)
}

post("/articles") {
contentType = "text/html"

val article = new Article(0, params("title"), params("body"))

if(Article.create(article)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.scalatra._
import javax.servlet.ServletContext

class ScalatraBootstrap extends LifeCycle {
override def init(context: ServletContext) {
override def init(context: ServletContext) = {
context.mount(new ScalatraTwirlServlet, "/")
}
}

0 comments on commit e01ca01

Please sign in to comment.