Classes inside the PersistentEntities (Actors)

Hi,

Newbie question:

Let’s say you have a Entity such as below that accepts the classes in the constructor, and you wire those classes in your ApplicationLoader.

class CustomerEntity(heavyObjectWithNoState:HeavyObject) extends PersistentEntity

Does it mean that the new instance of heavyObjectWithNoState: will get created everytime the new instance of CustomerEntity actor gets created? Or will all Customer actors be referencing to the singleton HeavyObject instance? (the later is of course much preferred as it will keep the actor less fat).

Thanks,

When you register a persistent entity with the PersistentEntityRegistry, you provide the function it uses to create new entities. So, either option is possible, it only depends on how you’ve written that function. If you want to reuse a single instance, you can create that once in your ApplicationLoader and then refer to it in the entityFactory function you register.

1 Like