Merge branch 'master' of github.com:jboner/akka
This commit is contained in:
commit
0f7e33704d
5 changed files with 21 additions and 15 deletions
|
|
@ -114,7 +114,7 @@ object Serializable {
|
|||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
trait ScalaJSON[T] extends JSON {
|
||||
def toJSON: String = new String(toBytes, "UTF-8")
|
||||
def toJSON: String
|
||||
def fromJSON(js: String): T
|
||||
def toBytes: Array[Byte]
|
||||
def fromBytes(bytes: Array[Byte]): T
|
||||
|
|
|
|||
|
|
@ -129,7 +129,6 @@ object Serializer {
|
|||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
trait ScalaJSON {
|
||||
import dispatch.json._
|
||||
import sjson.json._
|
||||
|
||||
var classLoader: Option[ClassLoader] = None
|
||||
|
|
|
|||
9
akka-remote/src/main/scala/serialization/package.scala
Normal file
9
akka-remote/src/main/scala/serialization/package.scala
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package se.scalablesolutions.akka
|
||||
|
||||
package object serialization {
|
||||
type JsValue = _root_.dispatch.json.JsValue
|
||||
val JsValue = _root_.dispatch.json.JsValue
|
||||
val Js = _root_.dispatch.json.Js
|
||||
val JsonSerialization = sjson.json.JsonSerialization
|
||||
val DefaultProtocol = sjson.json.DefaultProtocol
|
||||
}
|
||||
|
|
@ -9,16 +9,15 @@ import org.junit.runner.RunWith
|
|||
import se.scalablesolutions.akka.serialization.Serializable.ScalaJSON
|
||||
|
||||
object Serializables {
|
||||
import sjson.json.DefaultProtocol._
|
||||
import DefaultProtocol._
|
||||
import JsonSerialization._
|
||||
|
||||
case class Shop(store: String, item: String, price: Int) extends
|
||||
ScalaJSON[Shop] {
|
||||
implicit val ShopFormat: sjson.json.Format[Shop] =
|
||||
asProduct3("store", "item", "price")(Shop)(Shop.unapply(_).get)
|
||||
|
||||
import dispatch.json._
|
||||
import sjson.json._
|
||||
import sjson.json.JsonSerialization._
|
||||
|
||||
def toJSON: String = JsValue.toJson(tojson(this))
|
||||
def toBytes: Array[Byte] = tobinary(this)
|
||||
def fromBytes(bytes: Array[Byte]) = frombinary[Shop](bytes)
|
||||
def fromJSON(js: String) = fromjson[Shop](Js(js))
|
||||
|
|
@ -33,10 +32,7 @@ object Serializables {
|
|||
implicit val MyJsonObjectFormat: sjson.json.Format[MyJsonObject] =
|
||||
asProduct3("key", "map", "standAloneInt")(MyJsonObject)(MyJsonObject.unapply(_).get)
|
||||
|
||||
import dispatch.json._
|
||||
import sjson.json._
|
||||
import sjson.json.JsonSerialization._
|
||||
|
||||
def toJSON: String = JsValue.toJson(tojson(this))
|
||||
def toBytes: Array[Byte] = tobinary(this)
|
||||
def fromBytes(bytes: Array[Byte]) = frombinary[MyJsonObject](bytes)
|
||||
def fromJSON(js: String) = fromjson[MyJsonObject](Js(js))
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import org.scalatest.junit.JUnitRunner
|
|||
import org.junit.runner.RunWith
|
||||
|
||||
import se.scalablesolutions.akka.serialization._
|
||||
import dispatch.json._
|
||||
// import dispatch.json._
|
||||
import se.scalablesolutions.akka.actor._
|
||||
import ActorSerialization._
|
||||
import Actor._
|
||||
|
|
@ -230,12 +230,14 @@ case class MyMessage(val id: String, val value: Tuple2[String, Int])
|
|||
extends Serializable.ScalaJSON[MyMessage] {
|
||||
|
||||
def this() = this(null, null)
|
||||
import sjson.json.DefaultProtocol._
|
||||
import sjson.json._
|
||||
import sjson.json.JsonSerialization._
|
||||
|
||||
import DefaultProtocol._
|
||||
import JsonSerialization._
|
||||
|
||||
implicit val MyMessageFormat: sjson.json.Format[MyMessage] =
|
||||
asProduct2("id", "value")(MyMessage)(MyMessage.unapply(_).get)
|
||||
|
||||
def toJSON: String = JsValue.toJson(tojson(this))
|
||||
def toBytes: Array[Byte] = tobinary(this)
|
||||
def fromBytes(bytes: Array[Byte]) = frombinary[MyMessage](bytes)
|
||||
def fromJSON(js: String) = fromjson[MyMessage](Js(js))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue