Improvement of performance and reliability of BaseObjectHandler. BLD200208090100
authortzezula@netbeans.org
Thu, 08 Aug 2002 23:11:55 +0000
changeset 99652fa015c2f39
parent 995 8183a541c4a6
child 997 2e783dbcc55d
Improvement of performance and reliability of BaseObjectHandler.
Fix of isLocal of B-tree MOFID class.
mdr/src/org/netbeans/mdr/handlers/BaseObjectHandler.java
     1.1 --- a/mdr/src/org/netbeans/mdr/handlers/BaseObjectHandler.java	Thu Aug 08 18:28:17 2002 +0000
     1.2 +++ b/mdr/src/org/netbeans/mdr/handlers/BaseObjectHandler.java	Thu Aug 08 23:11:55 2002 +0000
     1.3 @@ -313,6 +313,9 @@
     1.4  //    private final StorableBaseObject storableDelegate;
     1.5      private final MOFID mofId;
     1.6      private final MdrStorage mdrStorage;
     1.7 +    // The storable hard reference is used only by transient objects
     1.8 +    // to prevent garbage collection.
     1.9 +    // For non transient objects it is null during the whole life cycle.
    1.10      private StorableBaseObject storable;
    1.11      
    1.12      /* --------------------------------------------------------------------- */
    1.13 @@ -368,10 +371,19 @@
    1.14      /* -- Extends java.lang.Object ----------------------------------------- */
    1.15      /* --------------------------------------------------------------------- */
    1.16  
    1.17 +    /** Tests this object with other object for identity.
    1.18 +     *  The object is identical if it is of RefBaseObject type
    1.19 +     *  and its mofid equals to this object mofid.
    1.20 +     *  This equals method and hashCode method are the only two
    1.21 +     *  methods guaranteed to work after the object was deleted.
    1.22 +     *  This allows developer to safely remove the deleted object from a container.
    1.23 +     *  @param Object other object
    1.24 +     *  @return true if objects are identical
    1.25 +     */ 
    1.26      public final boolean equals(Object obj) {
    1.27          if (obj instanceof BaseObjectHandler) {
    1.28              return this == obj;
    1.29 -        } else return (obj instanceof RefBaseObject) && ((BaseObjectHandler) obj)._getDelegate().getMofId().equals(_getDelegate().getMofId());
    1.30 +        } else return (obj instanceof RefBaseObject) && ((BaseObjectHandler) obj).mofId.equals(this.mofId);
    1.31      }
    1.32  
    1.33      public String toString() {
    1.34 @@ -394,8 +406,14 @@
    1.35          return className + "  ID: " + refMofId() + "  MID: " + metaId  + "  OPCKG: " + outP;
    1.36      }
    1.37  
    1.38 +    /** Returns hash code of this object.
    1.39 +     *  This hashCode method and equals method are the only two
    1.40 +     *  methods guaranteed to work after the object was deleted.
    1.41 +     *  This allows developer to safely remove the deleted object from a container.
    1.42 +     *  @return int the hash code
    1.43 +     */
    1.44      public final int hashCode() {
    1.45 -        return _getDelegate().getMofId().hashCode();
    1.46 +        return this.mofId.hashCode();
    1.47      }
    1.48      
    1.49      /* --------------------------------------------------------------------- */
    1.50 @@ -461,9 +479,9 @@
    1.51   */
    1.52          try {
    1.53              if (this.storable != null)
    1.54 -                return this.storable;
    1.55 +                return this.storable;                   // Transient object
    1.56              else
    1.57 -                return mdrStorage.getObject(mofId);
    1.58 +                return mdrStorage.getObject(mofId);     // Persistent object
    1.59          } catch (StorageBadRequestException e) {
    1.60              throw new InvalidObjectException(null, "Object with MOFID " + mofId + " no longer exists.");
    1.61          } catch (StorageException e) {