Skip to content
stemey edited this page Oct 20, 2012 · 7 revisions

A snapshot is a serializable representation of an object or a view of an object. The entity or parts of it can be rebuild from the snapshot. The snapshot is implemented via a dynamic entity. This dynamic entity is described by a dynamic EntityType which is created from the view. The values of the attributes are stored in a map in the dynamic entity. The values are the serializable values returned from PrimitiveType.serialize().

Person person=new Person();
person.setFirstName("Will");
// create the snapshot operation
SnapshotBuilder snapshotBuilder = SnapshotBuilderFactory.create(personType);
snapshotBuilder.include("firstName");
...
Transformation<Person,DynamicEntity> snapshotting = (..) snapshotBuilder.create();
// take a snapshot
DynamicEntity snapshot =snapshotting.snapshot(person);
// firstName will be Will
String firstName =snapshot.get("firstName");
// merge snapshot back to an instance of Person
Person person2 = new Person();
transformation.getAB().transform(snapshot,person2);

General usage

EntityType operation

###Configuration

  • classpath:/meta/utility/snapshot.xml : classpath scanning
  • classpath:/meta/utility/snapshot-example.xml : defines the component "meta-utility-snapshotBuilderFactory" and "snapshot-entityType-repository" which must be included in the EntityTypeRepository.

taken from /meta/utility/snapshot-example.xml:

<bean  id="meta-utility-snapshotBuilderFactory" class="org.atemsource.atem.utility.snapshot.SnapshotBuilderFactory">
	<property name="dynamicEntityTypeRepository" ref="snapshot-entityType-repository"></property>
	<property name="transformationBuilderFactory" ref="meta-utility-transformationBuilderFactory"></property>
	<property name="attributePathBuilderFactory" ref="meta-utility-attributePathBuilderFactory"></property>
</bean>

Clone this wiki locally