org.qi4j.entitystore.sql
Class SQLEntityStoreMixin

java.lang.Object
  extended by org.qi4j.entitystore.sql.SQLEntityStoreMixin
All Implemented Interfaces:
Activatable, StateStore, EntityStore, EntityStoreSPI

public class SQLEntityStoreMixin
extends Object
implements EntityStore, EntityStoreSPI, StateStore, Activatable

Most of this code is copy-paste from MapEntityStoreMixin. TODO refactor stuff that has to do with general things than actual MapEntityStore from MapEntityStoreMixin so that this class could extend some "AbstractJSONEntityStoreMixin".


Constructor Summary
SQLEntityStoreMixin()
           
 
Method Summary
 void activate()
          This is invoked on the service when the instance is being activated
 StateCommitter applyChanges(EntityStoreUnitOfWork unitofwork, Iterable<EntityState> states, String version, long lastModified)
           
 Input<EntityState,EntityStoreException> entityStates(ModuleSPI module)
           
 EntityState getEntityState(EntityStoreUnitOfWork unitOfWork, EntityReference entityRef)
           
 JSONObject getState(String id)
           
protected  DatabaseSQLService.EntityValueResult getValue(EntityReference ref)
           
 EntityState newEntityState(EntityStoreUnitOfWork unitOfWork, EntityReference entityRef, EntityDescriptor entityDescriptor)
           
 EntityStoreUnitOfWork newUnitOfWork(Usecase usecase, ModuleSPI module)
           
protected  String newUnitOfWorkId()
           
 void passivate()
          This is invoked on the service when the instance is being passivated
protected  DefaultEntityState readEntityState(DefaultEntityStoreUnitOfWork unitOfWork, Reader entityState)
           
protected  void writeEntityState(DefaultEntityState state, Writer writer, String version)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLEntityStoreMixin

public SQLEntityStoreMixin()
Method Detail

activate

public void activate()
              throws Exception
Description copied from interface: Activatable
This is invoked on the service when the instance is being activated

Specified by:
activate in interface Activatable
Throws:
Exception - if service could not be activated

passivate

public void passivate()
               throws Exception
Description copied from interface: Activatable
This is invoked on the service when the instance is being passivated

Specified by:
passivate in interface Activatable
Throws:
Exception - if the service could not be passivated

applyChanges

public StateCommitter applyChanges(EntityStoreUnitOfWork unitofwork,
                                   Iterable<EntityState> states,
                                   String version,
                                   long lastModified)
Specified by:
applyChanges in interface EntityStoreSPI

getEntityState

public EntityState getEntityState(EntityStoreUnitOfWork unitOfWork,
                                  EntityReference entityRef)
Specified by:
getEntityState in interface EntityStoreSPI

newEntityState

public EntityState newEntityState(EntityStoreUnitOfWork unitOfWork,
                                  EntityReference entityRef,
                                  EntityDescriptor entityDescriptor)
Specified by:
newEntityState in interface EntityStoreSPI

newUnitOfWork

public EntityStoreUnitOfWork newUnitOfWork(Usecase usecase,
                                           ModuleSPI module)
Specified by:
newUnitOfWork in interface EntityStore

entityStates

public Input<EntityState,EntityStoreException> entityStates(ModuleSPI module)
Specified by:
entityStates in interface EntityStore

newUnitOfWorkId

protected String newUnitOfWorkId()

readEntityState

protected DefaultEntityState readEntityState(DefaultEntityStoreUnitOfWork unitOfWork,
                                             Reader entityState)
                                      throws EntityStoreException
Throws:
EntityStoreException

getState

public JSONObject getState(String id)
                    throws IOException
Specified by:
getState in interface StateStore
Throws:
IOException

getValue

protected DatabaseSQLService.EntityValueResult getValue(EntityReference ref)

writeEntityState

protected void writeEntityState(DefaultEntityState state,
                                Writer writer,
                                String version)
                         throws EntityStoreException
Throws:
EntityStoreException