@Override protected void storeAssociationValue( AssociationValue associationValue, String sagaType, String sagaIdentifier) { AssociationValueEntry associationValueEntry = new AssociationValueEntry(sagaIdentifier, sagaType, associationValue); mongoTemplate.associationsCollection().save(associationValueEntry.asDBObject()); }
@Override protected void removeAssociationValue( AssociationValue associationValue, String sagaType, String sagaIdentifier) { DBObject query = AssociationValueEntry.queryBySagaIdentifierAndAssociationKeyValue( sagaIdentifier, associationValue.getKey(), associationValue.getValue()); mongoTemplate.associationsCollection().findAndRemove(query); }
private synchronized void initialize() { if (!initialized) { DBCursor dbCursor = mongoTemplate.associationsCollection().find(); getAssociationValueMap().clear(); while (dbCursor.hasNext()) { AssociationValueEntry entry = new AssociationValueEntry(dbCursor.next()); getAssociationValueMap() .add(entry.getAssociationValue(), entry.getSagaType(), entry.getSagaIdentifier()); } initialized = true; } }