Adding Scala reST docs for Serialization

This commit is contained in:
Viktor Klang 2011-12-30 20:57:40 +01:00
parent ca911038eb
commit d8b2f88ced
2 changed files with 36 additions and 0 deletions

View file

@ -131,4 +131,32 @@ class SerializationDocSpec extends AkkaSpec {
SerializationExtension(a).serializerFor(classOf[java.lang.Boolean]).getClass.getName must equal("akka.docs.serialization.MyOwnSerializer") SerializationExtension(a).serializerFor(classOf[java.lang.Boolean]).getClass.getName must equal("akka.docs.serialization.MyOwnSerializer")
a.shutdown() a.shutdown()
} }
"demonstrate the programmatic API" in {
//#programmatic
val system = ActorSystem("example")
// Get the Serialization Extension
val serialization = SerializationExtension(system)
// Have something to serialize
val original = "woohoo"
// Find the Serializer for it
val serializer = serialization.findSerializerFor(original)
// Turn it into bytes
val bytes = serializer.toBinary(original)
// Turn it back into an object
val back = serializer.fromBinary(bytes,
manifest = None,
classLoader = None)
// Voilá!
back must equal(original)
//#programmatic
system.shutdown()
}
} }

View file

@ -66,6 +66,14 @@ If you want to verify that your ``Props`` are serializable you can enable the fo
Programmatic Programmatic
------------ ------------
If you want to programmatically serialize/deserialize using Akka Serialization,
here's some examples:
.. includecode:: code/akka/docs/serialization/SerializationDocSpec.scala
:include: imports,programmatic
For more information, have a look at the ``ScalaDoc`` for ``akka.serialization._``
Customization Customization
============= =============