This example is contained in org.eclipse.etrice.examples.dynamicactors8.
The example demonstrates the use of the persistence interface for dynamic actors.
Dynamic actors can be persisted and restored. To this end the user has to pass an java.io.ObjectOutput to the creation method (createOptionalActor()) and an java.io.ObjectInput to the deletion method (destroyOptionalActor()).
The code generation has to be invoked with the -persistable (e.g. by setting the ’generate persistence interface’ flag in the Java Generator tab of the launch configuration). This lets the generator implement the IPersistable interface for actor classes.
The example adds a manually coded very simple FilePersistor with four static methods for creation and deletion of scalar and replicated dynamic actors.
The Container class first creates an optional actor of type Optional1 in the scalar reference opt. Then messages are sent to this actor instance which lead to some state changes. Finally it is saved and destroyed. Now another actor class is instantiated in the same actor reference and also destroyed. Then the first instance is loaded from file. It directly starts in the state it had when it was saved. The second part of the example loads copies of the two instances created in the beginning into the optarr reference.