Exemplo n.º 1
0
 @Override
 protected void updateSaga(Saga saga) {
   SagaEntry sagaEntry = new SagaEntry(saga, serializer);
   mongoTemplate
       .sagaCollection()
       .findAndModify(
           SagaEntry.queryByIdentifier(saga.getSagaIdentifier()), sagaEntry.asDBObject());
 }
Exemplo n.º 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;
  }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 6
0
 @Override
 protected void storeSaga(Saga saga) {
   SagaEntry sagaEntry = new SagaEntry(saga, serializer);
   DBObject sagaObject = sagaEntry.asDBObject();
   mongoTemplate.sagaCollection().save(sagaObject);
 }
Exemplo n.º 7
0
 @Override
 protected void deleteSaga(Saga saga) {
   mongoTemplate
       .sagaCollection()
       .findAndRemove(SagaEntry.queryByIdentifier(saga.getSagaIdentifier()));
 }