Coverage Report - org.mule.module.launcher.AbstractFileWatcher
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractFileWatcher
0%
0/13
0%
0/2
1.667
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.module.launcher;
 8  
 
 9  
 import java.io.File;
 10  
 
 11  
 import org.apache.commons.logging.Log;
 12  
 import org.apache.commons.logging.LogFactory;
 13  
 
 14  
 public abstract class AbstractFileWatcher implements Runnable
 15  
 {
 16  
 
 17  0
     protected Log logger = LogFactory.getLog(getClass());
 18  
 
 19  
     private long timeStamp;
 20  
     private File file;
 21  
 
 22  
     public AbstractFileWatcher(File file)
 23  0
     {
 24  0
         this.file = file;
 25  0
         this.timeStamp = file.lastModified();
 26  0
     }
 27  
 
 28  
     public final void run()
 29  
     {
 30  0
         long timeStamp = file.lastModified();
 31  
 
 32  0
         if (this.timeStamp != timeStamp)
 33  
         {
 34  0
             this.timeStamp = timeStamp;
 35  
             try
 36  
             {
 37  0
                 onChange(file);
 38  
             }
 39  0
             catch (Throwable t)
 40  
             {
 41  0
                 logger.error(String.format("Monitor for %s threw an exception", file), t);
 42  0
             }
 43  
         }
 44  0
     }
 45  
 
 46  
     protected abstract void onChange(File file);
 47  
 }