]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.common/src/org/simantics/db/common/primitiverequest/PossibleAdapter.java
Multiple reader thread support for db client
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / primitiverequest / PossibleAdapter.java
index 61a47ecb12a96443620f5c546b29bc2fda50813d..81d0f38958e9217bfbbe4cd7efd6c367f75b8618 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
 /*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2018 Association for Decentralized Information Management
  * in Industry THTH ry.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * in Industry THTH ry.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  *******************************************************************************/
 package org.simantics.db.common.primitiverequest;
 
  *******************************************************************************/
 package org.simantics.db.common.primitiverequest;
 
-import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Resource;
-import org.simantics.db.procedure.AsyncProcedure;
-import org.simantics.db.request.AsyncRead;
+import org.simantics.db.adaption.AdaptionService;
+import org.simantics.db.common.request.BinaryRead;
+import org.simantics.db.exception.DatabaseException;
 
 
-final public class PossibleAdapter<T> implements AsyncRead<T> {
+public final class PossibleAdapter<T> extends BinaryRead<Resource,Class<T>, T> {
 
 
-       final private Resource resource;
-    final private Class<T> clazz;
-    
-    @Override
-    public int hashCode() {
-        return resource.hashCode() + 31 * clazz.hashCode();
-    }
-    
-    @Override
-    public boolean equals(Object object) {
-        if (this == object)
-            return true;
-        else if (object == null)
-            return false;
-        else if (getClass() != object.getClass())
-            return false;
-        PossibleAdapter<?> r = (PossibleAdapter<?>)object;
-        return resource.equals(r.resource) && clazz.equals(r.clazz);
-    }
-
-    @Override
-    public int threadHash() {
-       return hashCode();
-    }
-
-    @Override
-    public int getFlags() {
-        return 0;
-    }
-    
     public PossibleAdapter(Resource resource, Class<T> clazz) {
     public PossibleAdapter(Resource resource, Class<T> clazz) {
-        this.resource = resource;
-        this.clazz = clazz;
+        super(resource, clazz);
     }
 
     @Override
     }
 
     @Override
-    public void perform(AsyncReadGraph graph, AsyncProcedure<T> procedure) {
-        
-        graph.forPossibleAdapted(resource, clazz, procedure);
-        
+    public T perform(ReadGraph graph) throws DatabaseException {
+        final AdaptionService service = graph.peekService(AdaptionService.class);
+        return service.adapt(graph, parameter, parameter, Resource.class, parameter2, true);
     }
 
 }
     }
 
 }