org.spicefactory.pimento.io
Class SnapshotEncoder

java.lang.Object
  extended by org.spicefactory.pimento.io.SnapshotEncoder

public class SnapshotEncoder
extends Object

Responsible for encoding entity instances to snapshot representations. Those snapshot representations may contain all property values of the entity or only a subset if a change set of a modified entity will be created. Snapshots instead of entities will be used for exchanging data between client and server.

Author:
Jens Halm

Constructor Summary
SnapshotEncoder(Metamodel metamodel, TransactionContext txContext)
          Creates a new instance.
 
Method Summary
 EntitySnapshot getSnapshot(Object instance, Entity entity, FetchPlan fetchPlan)
          Disassemble the specified entity to a snapshot representation.
 EntitySnapshot getSnapshot(Object instance, Entity entity, FetchPlan fetchPlan, boolean lazy)
          Disassemble the specified entity to a snapshot representation.
 boolean isUnitializedProxy(Object instance)
          Checks whether the specified entity is an uninitialized proxy.
 boolean isUnitializedProxy(Object collection, Object owner)
          Checks whether the specified collection is an uninitialized proxy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnapshotEncoder

public SnapshotEncoder(Metamodel metamodel,
                       TransactionContext txContext)
Creates a new instance.

Parameters:
metamodel - the metamodel of all entities managed by Pimento
txContext - the context of the current transaction
Method Detail

getSnapshot

public EntitySnapshot getSnapshot(Object instance,
                                  Entity entity,
                                  FetchPlan fetchPlan)
Disassemble the specified entity to a snapshot representation. For entities that were already processed this method returns an existing snapshot instance.

Parameters:
instance - the entity to disassemble
entity - the entity metamodel
fetchPlan - the fetch plan to use
Returns:
the snapshot representation of the entity

getSnapshot

public EntitySnapshot getSnapshot(Object instance,
                                  Entity entity,
                                  FetchPlan fetchPlan,
                                  boolean lazy)
Disassemble the specified entity to a snapshot representation. For entities that were already processed this method returns an existing snapshot instance.

Parameters:
instance - the entity to disassemble
entity - the entity for the entity
fetchPlan - the fetch plan to use
lazy - whether the entity should be lazily fetched
Returns:
the snapshot representation of the entity

isUnitializedProxy

public boolean isUnitializedProxy(Object instance)
Checks whether the specified entity is an uninitialized proxy.

Parameters:
instance - the entity to check
Returns:
true if the specified entity is an uninitialized proxy

isUnitializedProxy

public boolean isUnitializedProxy(Object collection,
                                  Object owner)
Checks whether the specified collection is an uninitialized proxy.

Parameters:
collection - the collection to check
owner - the entity that owns the collection
Returns:
true if the specified collection is an uninitialized proxy