abstract public class TransientResourceRead<R> extends BinaryRead<Object,Resource,R> implements ReadExt {
- protected static final Object WITH_PARENT = new Object();
-
- public TransientResourceRead(ReadGraph graph, Resource parameter) throws DatabaseException {
- this(graph, graph.getService(QueryControl.class), parameter);
- }
-
- public TransientResourceRead(ReadGraph graph, QueryControl qc, Resource parameter) throws DatabaseException {
- super(resolveFirstParameter(graph, qc), parameter);
- }
-
- final private static Object resolveFirstParameter(ReadGraph graph, QueryControl qc) throws DatabaseException {
- if(qc.hasParentRequest(graph)) return WITH_PARENT;
- else return graph.getModificationCounter();
- }
-
- @Override
- final public R perform(ReadGraph _graph) throws DatabaseException {
- if(parameter == WITH_PARENT) {
- return perform(_graph, parameter2);
- } else {
- QueryControl qc = _graph.getService(QueryControl.class);
- ReadGraph graph = qc.getIndependentGraph(_graph);
- return perform(graph, parameter2);
- }
- }
-
- abstract public R perform(ReadGraph graph, Resource parameter) throws DatabaseException;
-
- @Override
- public boolean isImmutable(ReadGraph graph) throws DatabaseException {
- return graph.isImmutable(parameter2);
- }
-
+ protected static final Object WITH_PARENT = new Object();
+
+ public TransientResourceRead(ReadGraph graph, Resource parameter) throws DatabaseException {
+ this(graph, graph.getService(QueryControl.class), parameter);
+ }
+
+ public TransientResourceRead(ReadGraph graph, QueryControl qc, Resource parameter) throws DatabaseException {
+ super(resolveFirstParameter(graph, qc), parameter);
+ }
+
+ final private static Object resolveFirstParameter(ReadGraph graph, QueryControl qc) throws DatabaseException {
+ if(qc.hasParentRequest(graph)) return WITH_PARENT;
+ else return graph.getModificationCounter();
+ }
+
+ @Override
+ final public R perform(ReadGraph _graph) throws DatabaseException {
+ if(parameter == WITH_PARENT) {
+ return perform(_graph, parameter2);
+ } else {
+ QueryControl qc = _graph.getService(QueryControl.class);
+ return qc.syncRequestIndependent(_graph, new UniqueRead<R>() {
+ @Override
+ public R perform(ReadGraph graph) throws DatabaseException {
+ return TransientResourceRead.this.perform(graph, parameter2);
+ }
+ });
+ }
+ }
+
+ abstract public R perform(ReadGraph graph, Resource parameter) throws DatabaseException;
+
+ @Override
+ public boolean isImmutable(ReadGraph graph) throws DatabaseException {
+ return graph.isImmutable(parameter2);
+ }
+
}