コード例 #1
0
 /** 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();
     }
   }
 }
コード例 #2
0
 /**
  * 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;
   }
 }
コード例 #3
0
 /** 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();
   }
 }
コード例 #4
0
 /**
  * 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);
   }
 }
コード例 #5
0
  /**
   * 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();
    }
  }
コード例 #6
0
 /**
  * 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;
 }
コード例 #7
0
 /**
  * Construct a new AbandonedTrace with a parent object.
  *
  * @param AbandonedTrace parent object
  */
 public AbandonedTrace(AbandonedTrace parent) {
   this.config = parent.getConfig();
   init(parent);
 }