예제 #1
0
 @Override
 protected void updateSaga(Saga saga) {
   SagaEntry sagaEntry = new SagaEntry(saga, serializer);
   mongoTemplate
       .sagaCollection()
       .findAndModify(
           SagaEntry.queryByIdentifier(saga.getSagaIdentifier()), sagaEntry.asDBObject());
 }
예제 #2
0
  @Override
  protected Set<String> findAssociatedSagaIdentifiers(
      Class<? extends Saga> type, AssociationValue associationValue) {
    final BasicDBObject value = associationValueQuery(type, associationValue);

    DBCursor dbCursor =
        mongoTemplate.sagaCollection().find(value, new BasicDBObject("sagaIdentifier", 1));
    Set<String> found = new TreeSet<String>();
    while (dbCursor.hasNext()) {
      found.add((String) dbCursor.next().get("sagaIdentifier"));
    }
    return found;
  }
예제 #3
0
 @Override
 public Saga load(String sagaIdentifier) {
   DBObject dbSaga =
       mongoTemplate.sagaCollection().findOne(SagaEntry.queryByIdentifier(sagaIdentifier));
   if (dbSaga == null) {
     return null;
   }
   SagaEntry sagaEntry = new SagaEntry(dbSaga);
   Saga loadedSaga = sagaEntry.getSaga(serializer);
   if (injector != null) {
     injector.injectResources(loadedSaga);
   }
   return loadedSaga;
 }
예제 #4
0
 @Override
 protected void removeAssociationValue(
     AssociationValue associationValue, String sagaType, String sagaIdentifier) {
   mongoTemplate
       .sagaCollection()
       .update(
           new BasicDBObject("sagaIdentifier", sagaIdentifier).append("sagaType", sagaType),
           new BasicDBObject(
               "$pull",
               new BasicDBObject(
                   "associations",
                   new BasicDBObject("key", associationValue.getKey())
                       .append("value", associationValue.getValue()))));
 }
 @Override
 protected <T extends Saga> T loadSaga(Class<T> type, String sagaIdentifier) {
   DBObject dbSaga =
       mongoTemplate.sagaCollection().findOne(SagaEntry.queryByIdentifier(sagaIdentifier));
   if (dbSaga == null) {
     throw new NoSuchSagaException(type, sagaIdentifier);
   }
   SagaEntry sagaEntry = new SagaEntry(dbSaga);
   Saga loadedSaga = sagaEntry.getSaga(serializer);
   if (!type.isInstance(loadedSaga)) {
     return null;
   }
   T storedSaga = type.cast(loadedSaga);
   if (injector != null) {
     injector.injectResources(storedSaga);
   }
   return storedSaga;
 }
예제 #6
0
 @Override
 protected void storeSaga(Saga saga) {
   SagaEntry sagaEntry = new SagaEntry(saga, serializer);
   DBObject sagaObject = sagaEntry.asDBObject();
   mongoTemplate.sagaCollection().save(sagaObject);
 }
예제 #7
0
 @Override
 protected void deleteSaga(Saga saga) {
   mongoTemplate
       .sagaCollection()
       .findAndRemove(SagaEntry.queryByIdentifier(saga.getSagaIdentifier()));
 }