use of org.qi4j.api.unitofwork.ConcurrentEntityModificationException in project qi4j-sdk by Qi4j.
the class LoggingServiceMixin method log.
public void log(LogType type, Composite composite, String category, String message) {
UnitOfWork uow = uowf.newUnitOfWork();
try {
List<Serializable> paramsList = new ArrayList<Serializable>();
createLogRecord(uow, type, composite, category, message, paramsList);
uow.complete();
} catch (ConcurrentEntityModificationException e) {
// ignore for now. Perhaps discard() and try again.
} catch (UnitOfWorkCompletionException e) {
// ignore for now. Perhaps discard() and try again.
}
}
use of org.qi4j.api.unitofwork.ConcurrentEntityModificationException in project qi4j-sdk by Qi4j.
the class LoggingServiceMixin method log.
public void log(LogType type, Composite composite, String category, String message, Serializable param1, Serializable param2) {
UnitOfWork uow = uowf.newUnitOfWork();
try {
List<Serializable> paramsList = new ArrayList<Serializable>();
paramsList.add(param1);
paramsList.add(param2);
createLogRecord(uow, type, composite, category, message, paramsList);
uow.complete();
} catch (ConcurrentEntityModificationException e) {
// ignore for now. Perhaps discard() and try again.
} catch (UnitOfWorkCompletionException e) {
// ignore for now. Perhaps discard() and try again.
}
}
use of org.qi4j.api.unitofwork.ConcurrentEntityModificationException in project qi4j-sdk by Qi4j.
the class DebuggingServiceMixin method debug.
@Override
public void debug(Composite composite, String message, Serializable... params) {
UnitOfWork uow = uowf.newUnitOfWork();
try {
List<Serializable> paramsList = new ArrayList<Serializable>(Arrays.asList(params));
createDebugRecord(uow, composite, message, paramsList);
uow.complete();
} catch (ConcurrentEntityModificationException e) {
// ignore for now. Perhaps discard() and try again.
} catch (UnitOfWorkCompletionException e) {
// ignore for now. Perhaps discard() and try again.
}
}
use of org.qi4j.api.unitofwork.ConcurrentEntityModificationException in project qi4j-sdk by Qi4j.
the class UnitOfWorkInstance method applyChanges.
private List<StateCommitter> applyChanges() throws UnitOfWorkCompletionException {
List<StateCommitter> committers = new ArrayList<>();
for (EntityStoreUnitOfWork entityStoreUnitOfWork : storeUnitOfWork.values()) {
try {
StateCommitter committer = entityStoreUnitOfWork.applyChanges();
committers.add(committer);
} catch (Exception e) {
// Cancel all previously prepared stores
for (StateCommitter committer : committers) {
committer.cancel();
}
if (e instanceof ConcurrentEntityStateModificationException) {
// If we cancelled due to concurrent modification, then create the proper exception for it!
ConcurrentEntityStateModificationException mee = (ConcurrentEntityStateModificationException) e;
Collection<EntityReference> modifiedEntityIdentities = mee.modifiedEntities();
Collection<EntityComposite> modifiedEntities = new ArrayList<>();
for (EntityReference modifiedEntityIdentity : modifiedEntityIdentities) {
Collection<EntityInstance> instances = instanceCache.values();
for (EntityInstance instance : instances) {
if (instance.identity().equals(modifiedEntityIdentity)) {
modifiedEntities.add(instance.<EntityComposite>proxy());
}
}
}
throw new ConcurrentEntityModificationException(modifiedEntities);
} else {
throw new UnitOfWorkCompletionException(e);
}
}
}
return committers;
}
use of org.qi4j.api.unitofwork.ConcurrentEntityModificationException in project qi4j-sdk by Qi4j.
the class DebuggingServiceMixin method debug.
@Override
public void debug(Composite composite, String message) {
UnitOfWork uow = uowf.newUnitOfWork();
try {
List<Serializable> paramsList = new ArrayList<Serializable>();
createDebugRecord(uow, composite, message, paramsList);
uow.complete();
} catch (ConcurrentEntityModificationException e) {
// ignore for now. Perhaps discard() and try again.
} catch (UnitOfWorkCompletionException e) {
// ignore for now. Perhaps discard() and try again.
}
}
Aggregations