Permalink
Browse files

Add support for providing a configuration for the list of classes to be

serialized
  • Loading branch information...
1 parent 00fa362 commit e40c00b7008b01e197d0719a39c38baab8a4713e @opti-mix opti-mix committed May 20, 2012
@@ -0,0 +1,21 @@
+#########################################################
+# Akka akka-quickser-serializer Reference Config File #
+#########################################################
+
+# This is the reference config file that contains all the default settings.
+# Make your edits/overrides in your application.conf.
+
+akka {
+ actor {
+ quickser {
+
+ # Define a set of fully qualified class names for
+ # classes to be used for serialization.
+ #
+ classes = [
+ # fully.qualified.classname1
+ # fully.qualified.classname2
+ ]
+ }
+ }
+}
@@ -38,6 +38,24 @@ import QuickserSerialization._
val serializer = new Serialization()
+ val settings = new Settings(system.settings.config)
+
+ val classes = settings.ClassNames
+
+ locally {
+ // Register classes
+ for(classname <- classnames) {
+ // Load class
+ system.dynamicAccess.getClassFor[AnyRef](classname) match {
+ case Right(clazz) => serializer.registerClass(clazz)
+ case Left(e) => {
+ log.warning("Class could not be loaded and/or registered: {} ", classname)
+ /* throw e */
+ }
+ }
+ }
+ }
+
// This is whether "fromBinary" requires a "clazz" or not
def includeManifest: Boolean = false
@@ -35,6 +35,7 @@ object QuickserSerialization {
class Settings(val config: Config) {
import scala.collection.JavaConverters._
import config._
+ val ClassNames: java.util.List[String] = config.getStringList("akka.actor.quickser.classes")
}
}

0 comments on commit e40c00b

Please sign in to comment.