public class MongoPersister<T> extends AbstractPersister<T,org.statefulj.persistence.mongo.StateDocumentImpl> implements Persister<T>, org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.context.ApplicationContextAware
| Constructor and Description |
|---|
MongoPersister(List<State<T>> states,
State<T> startState,
Class<T> clazz,
org.springframework.data.mongodb.core.MongoTemplate mongoTemplate)
Instantiate the MongoPersister with a specified template.
|
MongoPersister(List<State<T>> states,
State<T> startState,
Class<T> clazz,
String repoId)
Instantiate the MongoPersister with the id of the MongoRepository bean for
the Managed Entity.
|
MongoPersister(List<State<T>> states,
String stateFieldName,
State<T> startState,
Class<T> clazz,
org.springframework.data.mongodb.core.MongoTemplate mongoTemplate)
Instantiate the MongoPersister with a specified template.
|
MongoPersister(List<State<T>> states,
String stateFieldName,
State<T> startState,
Class<T> clazz,
String repoId)
Instantiate the MongoPersister with the id of the MongoRepository bean for
the Managed Entity.
|
| Modifier and Type | Method and Description |
|---|---|
protected org.springframework.data.mongodb.core.query.Query |
buildQuery(org.statefulj.persistence.mongo.StateDocumentImpl state,
State<T> current) |
protected org.springframework.data.mongodb.core.query.Update |
buildUpdate(State<T> current,
State<T> next) |
protected org.statefulj.persistence.mongo.StateDocumentImpl |
createStateDocument(T stateful) |
protected Field |
findIdField(Class<?> clazz) |
protected org.statefulj.persistence.mongo.StateDocumentImpl |
findStateDoc(String id) |
protected org.springframework.data.mongodb.core.MongoTemplate |
getMongoTemplate() |
protected String |
getState(T stateful) |
protected org.statefulj.persistence.mongo.StateDocumentImpl |
getStateDocument(T stateful) |
protected Class<?> |
getStateFieldType() |
void |
postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
void |
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setCurrent(T stateful,
State<T> current,
State<T> next)
Set the current State.
|
protected void |
setState(T stateful,
String state) |
protected void |
setStateDocument(T stateful,
StateDocument stateDoc) |
protected void |
throwStaleState(String current,
String next) |
protected void |
updateInMemory(T stateful,
org.statefulj.persistence.mongo.StateDocumentImpl stateDoc,
String current,
String next) |
protected org.statefulj.persistence.mongo.StateDocumentImpl |
updateStateDoc(org.springframework.data.mongodb.core.query.Query query,
org.springframework.data.mongodb.core.query.Update update) |
protected boolean |
validStateField(Field stateField) |
buildIdFieldAccessor, buildStateFieldAccessor, findStateField, getClazz, getCurrent, getId, getIdField, getIdFieldAccessor, getStartState, getStateField, getStateFieldAccessor, setStartState, setStates, throwStaleStateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetCurrent, setStartState, setStatespublic MongoPersister(List<State<T>> states, State<T> startState, Class<T> clazz, org.springframework.data.mongodb.core.MongoTemplate mongoTemplate)
states - List of the StatesstartState - The Start Stateclazz - The Managed Entity classmongoTemplate - MongoTemplate to use to persist the Managed Entitypublic MongoPersister(List<State<T>> states, String stateFieldName, State<T> startState, Class<T> clazz, org.springframework.data.mongodb.core.MongoTemplate mongoTemplate)
states - List of the StatesstateFieldName - The name of the State FieldstartState - The Start Stateclazz - The Managed Entity classmongoTemplate - MongoTemplate to use to persist the Managed Entitypublic MongoPersister(List<State<T>> states, State<T> startState, Class<T> clazz, String repoId)
states - List of the StatesstartState - The Start Stateclazz - The Managed Entity classrepoId - Bean Id of the Managed Entity's MongoRepositorypublic MongoPersister(List<State<T>> states, String stateFieldName, State<T> startState, Class<T> clazz, String repoId)
states - List of StatesstateFieldName - The name of the State FieldstartState - The Start Stateclazz - The Managed Entity classrepoId - Bean Id of the Managed Entity's MongoRepositorypublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionpublic void setCurrent(T stateful, State<T> current, State<T> next) throws StaleStateException
setCurrent in interface Persister<T>setCurrent in class AbstractPersister<T,org.statefulj.persistence.mongo.StateDocumentImpl>stateful - Stateful Entitycurrent - Expected current Statenext - The value of the next StateStaleStateException - thrown if the value of the State does not equal to the provided current Statepublic void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
throws org.springframework.beans.BeansException
postProcessBeanFactory in interface org.springframework.beans.factory.config.BeanFactoryPostProcessororg.springframework.beans.BeansExceptionpublic void postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
throws org.springframework.beans.BeansException
postProcessBeanDefinitionRegistry in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessororg.springframework.beans.BeansExceptionprotected boolean validStateField(Field stateField)
validStateField in class AbstractPersister<T,org.statefulj.persistence.mongo.StateDocumentImpl>protected Field findIdField(Class<?> clazz)
findIdField in class AbstractPersister<T,org.statefulj.persistence.mongo.StateDocumentImpl>protected Class<?> getStateFieldType()
getStateFieldType in class AbstractPersister<T,org.statefulj.persistence.mongo.StateDocumentImpl>protected org.springframework.data.mongodb.core.query.Query buildQuery(org.statefulj.persistence.mongo.StateDocumentImpl state,
State<T> current)
protected org.springframework.data.mongodb.core.query.Update buildUpdate(State<T> current, State<T> next)
protected String getState(T stateful) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
getState in class AbstractPersister<T,org.statefulj.persistence.mongo.StateDocumentImpl>NoSuchFieldExceptionSecurityExceptionIllegalArgumentExceptionIllegalAccessExceptionprotected void setState(T stateful, String state) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException
setState in class AbstractPersister<T,org.statefulj.persistence.mongo.StateDocumentImpl>IllegalArgumentExceptionIllegalAccessExceptionNoSuchFieldExceptionSecurityExceptionprotected org.statefulj.persistence.mongo.StateDocumentImpl getStateDocument(T stateful) throws IllegalArgumentException, IllegalAccessException
protected org.statefulj.persistence.mongo.StateDocumentImpl createStateDocument(T stateful) throws IllegalArgumentException, IllegalAccessException, SecurityException, NoSuchFieldException
protected void setStateDocument(T stateful, StateDocument stateDoc) throws IllegalArgumentException, IllegalAccessException
protected void updateInMemory(T stateful, org.statefulj.persistence.mongo.StateDocumentImpl stateDoc, String current, String next) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, StaleStateException
protected void throwStaleState(String current, String next) throws StaleStateException
StaleStateExceptionprotected org.springframework.data.mongodb.core.MongoTemplate getMongoTemplate()
protected org.statefulj.persistence.mongo.StateDocumentImpl updateStateDoc(org.springframework.data.mongodb.core.query.Query query,
org.springframework.data.mongodb.core.query.Update update)
protected org.statefulj.persistence.mongo.StateDocumentImpl findStateDoc(String id)
Copyright © 2016. All rights reserved.