]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/bindings/ResourceBinding.java
Initial support for concurrency in databoard, bindings and serializers
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / bindings / ResourceBinding.java
index d623b439fc2917a051d3999412141b08ebc4b5d2..eca8a89dab272ab8d6eeb1e9ab3fa19d932ffcfa 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
@@ -31,23 +31,13 @@ public class ResourceBinding extends LongBinding {
 
     public static final Datatype RESOURCE_TYPE;
 
-    //SerialisationSupport support;
-
     /**
-     * Create resource binding. If session is not provided, this binding cannot instantiate resources.
+     * Create resource binding.
      * 
      * @param session or null
      */
-    public ResourceBinding(Session session) {
+    public ResourceBinding() {
         super(Datatypes.LONG);
-//        if (session != null) {
-//            support = session.peekService(SerialisationSupport.class);
-//        }
-    }
-
-    public ResourceBinding(SerialisationSupport serializationSupport) {
-        super(Datatypes.LONG);
-//        this.support = serializationSupport;
     }
 
     /**
@@ -56,10 +46,6 @@ public class ResourceBinding extends LongBinding {
      *             if not able to return a current {@link SerialisationSupport}
      */
     private SerialisationSupport getCurrentSupport() throws BindingException {
-        // FIXME: this is wrong but should be optimized if possible.
-//        if (support != null)
-//            return support;
-
         Session s = SimanticsInternal.peekSession();
         if ( s == null ) {
             throw new BindingException("Cannot instantiate Resource without an alive database Session.");
@@ -118,8 +104,6 @@ public class ResourceBinding extends LongBinding {
     public Long getValue(Object o) throws BindingException {
        SerialisationSupport support = getCurrentSupport();
         // NOTE: r.getResourceId() is unsafe for this purpose, it will just return 0 if it fails, thus corrupting anything serialized with this method
-//     Resource r = (Resource) o;
-//     return r.getResourceId();
         try {
             return support.getRandomAccessId((Resource)o);
         } catch (DatabaseException e) {
@@ -131,8 +115,6 @@ public class ResourceBinding extends LongBinding {
     public long getValue_(Object o) throws BindingException {
        SerialisationSupport support = getCurrentSupport();
         // NOTE: r.getResourceId() is unsafe for this purpose, it will just return 0 if it fails, thus corrupting anything serialized with this method
-//     Resource r = (Resource) o;
-//     return r.getResourceId();
         try {
             return support.getRandomAccessId((Resource)o);
         } catch (DatabaseException e) {