1 8 package org.jivesoftware.util.log.output.io.rotate; 9 10 import java.io.File ; 11 12 17 public class RotateStrategyByTime 18 implements RotateStrategy { 19 private long m_timeInterval; 21 22 private long m_startingTime; 24 25 private long m_currentRotation; 27 28 32 public RotateStrategyByTime() { 33 this(1000 * 60 * 60 * 24); 34 } 35 36 41 public RotateStrategyByTime(final long timeInterval) { 42 m_startingTime = System.currentTimeMillis(); 43 m_currentRotation = 0; 44 m_timeInterval = timeInterval; 45 } 46 47 50 public void reset() { 51 m_startingTime = System.currentTimeMillis(); 52 m_currentRotation = 0; 53 } 54 55 64 public boolean isRotationNeeded(final String data, final File file) { 65 final long newRotation = 66 (System.currentTimeMillis() - m_startingTime) / m_timeInterval; 67 68 if (newRotation > m_currentRotation) { 69 m_currentRotation = newRotation; 70 return true; 71 } 72 else { 73 return false; 74 } 75 } 76 } 77 78 79 | Popular Tags |