1 17 package org.apache.log.output.io.rotate; 18 19 import java.io.File ; 20 21 26 public class RotateStrategyByTime 27 implements RotateStrategy 28 { 29 private long m_timeInterval; 31 32 private long m_startingTime; 34 35 private long m_currentRotation; 37 38 42 public RotateStrategyByTime() 43 { 44 this( 1000 * 60 * 60 * 24 ); 45 } 46 47 52 public RotateStrategyByTime( final long timeInterval ) 53 { 54 m_startingTime = System.currentTimeMillis(); 55 m_currentRotation = 0; 56 m_timeInterval = timeInterval; 57 } 58 59 62 public void reset() 63 { 64 m_startingTime = System.currentTimeMillis(); 65 m_currentRotation = 0; 66 } 67 68 78 public boolean isRotationNeeded( final String data, final File file ) 79 { 80 final long newRotation = 81 ( System.currentTimeMillis() - m_startingTime ) / m_timeInterval; 82 83 if( newRotation > m_currentRotation ) 84 { 85 m_currentRotation = newRotation; 86 return true; 87 } 88 else 89 { 90 return false; 91 } 92 } 93 } 94 95 96 | Popular Tags |