/** If logAbandoned=true, print a stack trace of the code that created this object. */
 public void printStackTrace() {
   if (createdBy != null) {
     System.out.println(format.format(new Date(createdTime)));
     createdBy.printStackTrace();
   }
   synchronized (this) {
     Iterator it = this.trace.iterator();
     while (it.hasNext()) {
       AbandonedTrace at = (AbandonedTrace) it.next();
       at.printStackTrace();
     }
   }
 }
 /**
  * Set the time in ms this object was last used.
  *
  * @param long time in ms
  */
 protected void setLastUsed(long time) {
   if (parent != null) {
     parent.setLastUsed(time);
   } else {
     lastUsed = time;
   }
 }
 /** Set the time this object was last used to the current time in ms. */
 protected void setLastUsed() {
   if (parent != null) {
     parent.setLastUsed();
   } else {
     lastUsed = System.currentTimeMillis();
   }
 }
 /**
  * If logAbandoned=true generate a stack trace for this object then add this object to the parent
  * object trace list.
  */
 protected void setStackTrace() {
   if (config == null) {
     return;
   }
   if (config.getLogAbandoned()) {
     createdBy = new Exception();
     createdTime = System.currentTimeMillis();
   }
   if (parent != null) {
     parent.addTrace(this);
   }
 }
  /**
   * Initialize abandoned tracing for this object.
   *
   * @param AbandonedTrace parent object
   */
  private void init(AbandonedTrace parent) {
    if (parent != null) {
      parent.addTrace(this);
    }

    if (config == null) {
      return;
    }
    if (config.getLogAbandoned()) {
      createdBy = new Exception();
      createdTime = System.currentTimeMillis();
    }
  }
 /**
  * Get the last time this object was used in ms.
  *
  * @return long time in ms
  */
 protected long getLastUsed() {
   if (parent != null) {
     return parent.getLastUsed();
   }
   return lastUsed;
 }
 /**
  * Construct a new AbandonedTrace with a parent object.
  *
  * @param AbandonedTrace parent object
  */
 public AbandonedTrace(AbandonedTrace parent) {
   this.config = parent.getConfig();
   init(parent);
 }