Permalink
Browse files

Cleanup for 2.10

  • Loading branch information...
1 parent c21cac9 commit 557fefe7ba09569d61e3790c3713457d571db8a8 @janm janm committed Oct 23, 2012
Showing with 38 additions and 642 deletions.
  1. +11 −3 sbt/build.sbt
  2. +0 −37 sbt/src/main/scala/org/cakesolutions/akkapatterns/api/boot.scala
  3. +0 −37 sbt/src/main/scala/org/cakesolutions/akkapatterns/api/customer.scala
  4. +0 −47 sbt/src/main/scala/org/cakesolutions/akkapatterns/api/dummy.scala
  5. +0 −38 sbt/src/main/scala/org/cakesolutions/akkapatterns/api/home.scala
  6. +0 −68 sbt/src/main/scala/org/cakesolutions/akkapatterns/api/marshalling.scala
  7. +0 −24 sbt/src/main/scala/org/cakesolutions/akkapatterns/api/user.scala
  8. +2 −3 sbt/src/main/scala/org/cakesolutions/akkapatterns/core/application/application.scala
  9. +0 −125 sbt/src/main/scala/org/cakesolutions/akkapatterns/core/application/casbah.scala
  10. +12 −14 sbt/src/main/scala/org/cakesolutions/akkapatterns/core/application/customer.scala
  11. +8 −19 sbt/src/main/scala/org/cakesolutions/akkapatterns/core/application/user.scala
  12. +1 −1 sbt/src/main/scala/org/cakesolutions/akkapatterns/core/boot.scala
  13. +3 −2 sbt/src/main/scala/org/cakesolutions/akkapatterns/domain/configuration.scala
  14. +1 −3 sbt/src/main/scala/org/cakesolutions/akkapatterns/main/Main.scala
  15. +0 −36 sbt/src/main/scala/org/cakesolutions/akkapatterns/web/boot.scala
  16. +0 −37 sbt/src/test/scala/org/cakesolutions/akkapatterns/api/CustomerServiceSpec.scala
  17. +0 −18 sbt/src/test/scala/org/cakesolutions/akkapatterns/api/HomeServiceSpec.scala
  18. +0 −83 sbt/src/test/scala/org/cakesolutions/akkapatterns/api/support.scala
  19. +0 −46 sbt/src/test/scala/org/cakesolutions/akkapatterns/core/CustomerActorSpecx.scala
  20. +0 −1 sbt/src/test/scala/org/cakesolutions/akkapatterns/test/DefaultTestData.scala
View
@@ -3,7 +3,7 @@ import sbtrelease._
/** Project */
name := "akka-patterns"
-version := "1.7.1"
+version := "1.0"
organization := "org.cakesolutions"
@@ -21,12 +21,20 @@ resolvers += "spray repo" at "http://repo.spray.io"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
+resolvers += "Sonatype OSS Releases" at "http://oss.sonatype.org/content/repositories/releases/"
+
+resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
+
libraryDependencies <<= scalaVersion { scala_version =>
val sprayVersion = "1.1-M4"
val akkaVersion = "2.1.0-RC1"
Seq(
- "com.typesafe.akka" % "akka-kernel" % akkaVersion,
- "io.spray" % "spray-can" % sprayVersion
+ "com.typesafe.akka" % "akka-kernel_2.10.0-RC1" % akkaVersion,
+ "io.spray" % "spray-can" % sprayVersion,
+ "io.spray" % "spray-routing" % sprayVersion,
+ "io.spray" % "spray-httpx" % sprayVersion,
+ "io.spray" % "spray-util" % sprayVersion,
+ "io.spray" % "spray-json_2.9.2" % "1.2.2"
)
}
@@ -1,37 +0,0 @@
-package org.cakesolutions.akkapatterns.api
-
-import akka.actor.{ActorRef, Props}
-import cc.spray._
-import http.{StatusCodes, HttpResponse}
-import org.cakesolutions.akkapatterns.core.Core
-import akka.util.Timeout
-
-trait Api {
- this: Core =>
-
- val routes =
- new HomeService().route ::
- //new DummyService("customers").route ::
- new CustomerService().route ::
- Nil
-
- def rejectionHandler: PartialFunction[scala.List[cc.spray.Rejection], cc.spray.http.HttpResponse] = {
- case (rejections: List[Rejection]) => HttpResponse(StatusCodes.BadRequest)
- }
-
- val svc: Route => ActorRef = route => actorSystem.actorOf(Props(new HttpService(route, rejectionHandler)))
-
- val rootService = actorSystem.actorOf(
- props = Props(new RootService(
- svc(routes.head),
- routes.tail.map(svc):_*
- )),
- name = "root-service"
- )
-
-}
-
-trait DefaultTimeout {
- final implicit val timeout = Timeout(3000)
-
-}
@@ -1,37 +0,0 @@
-package org.cakesolutions.akkapatterns.api
-
-import akka.actor.ActorSystem
-import cc.spray.Directives
-import org.cakesolutions.akkapatterns.domain.Customer
-import org.cakesolutions.akkapatterns.core.application._
-import cc.spray.directives.JavaUUID
-import akka.pattern.ask
-import org.cakesolutions.akkapatterns.core.application.RegisterCustomer
-import org.cakesolutions.akkapatterns.domain.Customer
-import org.cakesolutions.akkapatterns.core.application.Get
-import org.cakesolutions.akkapatterns.core.application.FindAll
-
-/**
- * @author janmachacek
- */
-class CustomerService(implicit val actorSystem: ActorSystem) extends Directives with Marshallers with Unmarshallers with DefaultTimeout with LiftJSON {
- def customerActor = actorSystem.actorFor("/user/application/customer")
-
- val route =
- path("customers" / JavaUUID) { id =>
- get {
- completeWith((customerActor ? Get(id)).mapTo[Option[Customer]])
- }
- } ~
- path("customers") {
- get {
- completeWith((customerActor ? FindAll()).mapTo[List[Customer]])
- } ~
- post {
- content(as[RegisterCustomer]) { rc =>
- completeWith((customerActor ? rc).mapTo[Either[NotRegisteredCustomer, RegisteredCustomer]])
- }
- }
- }
-
-}
@@ -1,47 +0,0 @@
-package org.cakesolutions.akkapatterns.api
-
-import cc.spray.Directives
-import akka.actor.ActorSystem
-import cc.spray.http._
-import cc.spray.http.MediaTypes._
-import cc.spray.RequestContext
-
-class DummyService(path: String)(implicit val actorSystem: ActorSystem) extends Directives {
-
- val route = {
- pathPrefix(path) {
- x =>
- x.complete(
- HttpResponse(StatusCodes.OK, getContent(x, `application/json`)))
- }
- }
-
- private def getContent(ctx: RequestContext, contentType: ContentType): HttpContent = {
-
- var filename = ctx.request.path
-
- if (filename.startsWith("/")) filename = filename.drop(1)
- if (filename.endsWith("/")) filename = filename.dropRight(1)
- filename = filename.replace("/", "-")
- filename = filename + "-" + ctx.request.method.toString().toLowerCase + ".json"
-
- val uidRegex = "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}".r
- val fileContent = uidRegex.findFirstIn(filename) match {
- case Some(uid) =>
- getFileAsString(uidRegex.replaceAllIn(filename, "UUID"))
- case None =>
- getFileAsString(filename)
- }
-
- HttpContent(contentType, fileContent)
- }
-
- private def getFileAsString(filename: String): String = {
- try {
- scala.io.Source.fromInputStream(getClass.getResourceAsStream(filename)).mkString
- }
- catch {
- case _: Throwable => "{body of file " + filename + " -- Missing File!}"
- }
- }
-}
@@ -1,38 +0,0 @@
-package org.cakesolutions.akkapatterns.api
-
-import akka.actor.ActorSystem
-import cc.spray.Directives
-import cc.spray.directives.Slash
-import java.net.InetAddress
-import akka.pattern.ask
-import org.cakesolutions.akkapatterns.core.application.{PoisonPill, GetImplementation, Implementation}
-
-case class SystemInfo(implementation: Implementation, host: String)
-
-class HomeService(implicit val actorSystem: ActorSystem) extends Directives with Marshallers with DefaultTimeout with LiftJSON {
-
- def applicationActor = actorSystem.actorFor("/user/application")
- import scala.concurrent.ExecutionContext.Implicits.global
-
- val route = {
- path(Slash) {
- get {
- completeWith {
- (applicationActor ? GetImplementation()).mapTo[Implementation].map {
- SystemInfo(_, InetAddress.getLocalHost.getCanonicalHostName)
- }
- }
- }
- } ~
- path("poisonpill") {
- post {
- completeWith {
- applicationActor ! PoisonPill()
-
- "Goodbye"
- }
- }
- }
- }
-
-}
@@ -1,68 +0,0 @@
-package org.cakesolutions.akkapatterns.api
-
-import cc.spray.typeconversion._
-import net.liftweb.json._
-import cc.spray.http.{HttpContent, ContentType}
-import cc.spray.http.MediaTypes._
-import net.liftweb.json.Serialization._
-import cc.spray.http.ContentTypeRange
-import java.util.UUID
-
-trait Marshallers extends DefaultMarshallers {
- this: LiftJSON =>
-
- implicit def liftJsonMarshaller[A <: AnyRef] = new SimpleMarshaller[A] {
- val canMarshalTo = ContentType(`application/json`) :: Nil
- def marshal(value: A, contentType: ContentType) = {
- val jsonSource = write(value.asInstanceOf[AnyRef])
- DefaultMarshallers.StringMarshaller.marshal(jsonSource, contentType)
- }
- }
-
-}
-
-trait Unmarshallers extends DefaultUnmarshallers {
- this: LiftJSON =>
-
- implicit def liftJsonUnmarshaller[A <: Product : Manifest] = new SimpleUnmarshaller[A] {
- val canUnmarshalFrom = ContentTypeRange(`application/json`) :: Nil
- def unmarshal(content: HttpContent) = protect {
- val jsonSource = DefaultUnmarshallers.StringUnmarshaller(content).right.get
- parse(jsonSource).extract[A]
- }
- }
-
-}
-
-trait LiftJSON {
- implicit def liftJsonFormats: Formats =
- DefaultFormats + new UUIDSerializer + FieldSerializer[AnyRef]()
-
- class UUIDSerializer extends Serializer[UUID] {
- private val UUIDClass = classOf[UUID]
-
- def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), UUID] = {
- case (TypeInfo(UUIDClass, _), json) => json match {
- case JString(s) => UUID.fromString(s)
- case x => throw new MappingException("Can't convert " + x + " to UUID")
- }
- }
-
- def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {
- case x: UUID => JString(x.toString)
- }
- }
-
- class StringBuilderMarshallingContent(sb: StringBuilder) extends MarshallingContext {
-
- def marshalTo(content: HttpContent) {
- if (sb.length > 0) sb.append(",")
- sb.append(new String(content.buffer))
- }
-
- def handleError(error: Throwable) {}
-
- def startChunkedMessage(contentType: ContentType) = throw new UnsupportedOperationException
- }
-
-}
@@ -1,24 +0,0 @@
-package org.cakesolutions.akkapatterns.api
-
-import akka.actor.ActorSystem
-import cc.spray.Directives
-import org.cakesolutions.akkapatterns.domain.User
-import org.cakesolutions.akkapatterns.core.application.{NotRegisteredUser, RegisteredUser}
-import akka.pattern.ask
-
-/**
- * @author janmachacek
- */
-class UserService(implicit val actorSystem: ActorSystem) extends Directives with Marshallers with Unmarshallers with DefaultTimeout with LiftJSON {
- def userActor = actorSystem.actorFor("/user/application/user")
-
- val route =
- path("user" / "register") {
- post {
- content(as[User]) { user =>
- completeWith((userActor ? RegisteredUser(user)).mapTo[Either[NotRegisteredUser, RegisteredUser]])
- }
- }
- }
-
-}
@@ -3,7 +3,6 @@ package org.cakesolutions.akkapatterns.core.application
import org.cakesolutions.akkapatterns.core.{Started, Stop, Start}
import akka.actor.{Props, Actor}
import org.cakesolutions.akkapatterns.domain.Configured
-import com.mongodb.casbah.MongoDB
case class GetImplementation()
case class Implementation(title: String, version: String, build: String)
@@ -42,7 +41,7 @@ class ApplicationActor extends Actor {
}
trait MongoCollections extends Configured {
- def customers = configured[MongoDB].apply("customers")
- def users = configured[MongoDB].apply("users")
+// def customers = configured[MongoDB].apply("customers")
+// def users = configured[MongoDB].apply("users")
}
Oops, something went wrong.

0 comments on commit 557fefe

Please sign in to comment.