Package net.sodacan.core.serialize.gson
Class GsonSerializerFactory
java.lang.Object
net.sodacan.core.serialize.gson.GsonSerializerFactory
- All Implemented Interfaces:
SerializerFactory
,PoolItemFactory<com.google.gson.Gson>
public class GsonSerializerFactory
extends Object
implements SerializerFactory, PoolItemFactory<com.google.gson.Gson>
Factory that creates individual Serializers. Each actor will ask for a serializer.
The factory is free to hand out individual Serializers or a single shared serializer.
In any case, the factory will be getting requests from multiple threads and so should be sure to avoid
concurrency issues.
Our constructor is created during Config. At this time, before we are accessed by Actors, we create a thread-safe pool of Gson instances.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a serializer for the specified actorId.com.google.gson.Gson
com.google.gson.GsonBuilder
getBuilderFor
(ActorId actorId)
-
Field Details
-
messageClass
-
builder
protected com.google.gson.GsonBuilder builder -
pool
-
-
Constructor Details
-
GsonSerializerFactory
-
-
Method Details
-
getBuilderFor
-
createItem
public com.google.gson.Gson createItem()- Specified by:
createItem
in interfacePoolItemFactory<com.google.gson.Gson>
-
create
Create a serializer for the specified actorId. This method is called from an individual Actor's thread. We don't modify any shared variables here but if we did, then syncing is needed.- Specified by:
create
in interfaceSerializerFactory
-
getConfig
-
getMessageClass
-