[logback-dev] svn commit: r1653 - in logback/trunk: logback-access/src/test/java/ch/qos/logback/access/jetty logback-core/src/main/java/ch/qos/logback/core/helpers logback-core/src/main/java/ch/qos/logback/core/rolling logback-core/src/test/java/ch/qos/logback/core/rolling

noreply.ceki at qos.ch noreply.ceki at qos.ch
Wed Mar 19 22:06:43 CET 2008


Author: ceki
Date: Wed Mar 19 22:06:42 2008
New Revision: 1653

Modified:
   logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicy.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicyBase.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java

Log:
- classed in c.q.l.core.rolling package made generic
- additional assertion in JettyBasicTest

Modified: logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java
==============================================================================
--- logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java	(original)
+++ logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java	Wed Mar 19 22:06:42 2008
@@ -61,6 +61,7 @@
     assertEquals("hello world", result);
 
     ListAppender appender = (ListAppender) requestLogImpl.getAppender("list");
+    assertTrue(appender.list.size()>0);
     AccessEvent event = (AccessEvent) appender.list.get(0);
     assertEquals("127.0.0.1", event.getRemoteHost());
     assertEquals("localhost", event.getServerName());

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java	Wed Mar 19 22:06:42 2008
@@ -46,6 +46,7 @@
     init(maxSize);
   }
   
+  @SuppressWarnings("unchecked")
   private void init(int maxSize) {
     this.maxSize = maxSize;
     ea = (E[]) new Object[maxSize];

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java	Wed Mar 19 22:06:42 2008
@@ -29,7 +29,7 @@
  * */
 public class RollingFileAppender<E> extends FileAppender<E> {
   File activeFileCache;
-  TriggeringPolicy triggeringPolicy;
+  TriggeringPolicy<E> triggeringPolicy;
   RollingPolicy rollingPolicy;
 
   /**
@@ -136,12 +136,12 @@
   public void setRollingPolicy(RollingPolicy policy) {
     rollingPolicy = policy;
     if(rollingPolicy instanceof TriggeringPolicy) {
-      triggeringPolicy = (TriggeringPolicy) policy;
+      triggeringPolicy = (TriggeringPolicy<E>) policy;
     }
     
   }
 
-  public void setTriggeringPolicy(TriggeringPolicy policy) {
+  public void setTriggeringPolicy(TriggeringPolicy<E> policy) {
     triggeringPolicy = policy;
     if(policy instanceof RollingPolicy) {
       rollingPolicy = (RollingPolicy) policy;

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.java	Wed Mar 19 22:06:42 2008
@@ -26,7 +26,7 @@
  * @author Ceki G&uuml;lc&uuml;
  *
  */
-public class SizeBasedTriggeringPolicy extends TriggeringPolicyBase {
+public class SizeBasedTriggeringPolicy<E> extends TriggeringPolicyBase<E> {
   
   public static final String SEE_SIZE_FORMAT = "http://logback.qos.ch/codes.html#sbtp_size_format";
   /**
@@ -44,7 +44,7 @@
       setMaxFileSize(maxFileSize);
   }
 
-  public boolean isTriggeringEvent(final File activeFile, final Object event) {
+  public boolean isTriggeringEvent(final File activeFile, final E event) {
     //System.out.println("Size"+file.length());
     return (activeFile.length() >= maxFileSize.getSize());
   }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java	Wed Mar 19 22:06:42 2008
@@ -29,7 +29,7 @@
  * 
  * @author Ceki G&uuml;lc&uuml;
  */
-public class TimeBasedRollingPolicy extends RollingPolicyBase implements TriggeringPolicy {
+public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements TriggeringPolicy<E> {
   static final String FNP_NOT_SET =
     "The FileNamePattern option must be set before using TimeBasedRollingPolicy. ";
   static final String SEE_FNP_NOT_SET =
@@ -185,7 +185,7 @@
     }
   }
 
-  public boolean isTriggeringEvent(File activeFile, final Object event) {
+  public boolean isTriggeringEvent(File activeFile, final E event) {
     long time= getCurrentTime();
 
     if (time >= nextCheck) {

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicy.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicy.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicy.java	Wed Mar 19 22:06:42 2008
@@ -23,7 +23,7 @@
  * @author Ceki G&uuml;lc&uuml;
  * */
 
-public interface TriggeringPolicy extends LifeCycle {
+public interface TriggeringPolicy<E> extends LifeCycle {
   
   /**
    * Should roll-over be triggered at this time?
@@ -32,5 +32,5 @@
    * @param event A reference to the currently event. 
    * @return true if a roll-over should occur.
    */
-  public boolean isTriggeringEvent(final File activeFile, final Object event);
+  public boolean isTriggeringEvent(final File activeFile, final E event);
 }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicyBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicyBase.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicyBase.java	Wed Mar 19 22:06:42 2008
@@ -20,7 +20,7 @@
  * @author Ceki G&uuml;lc&uuml;
  *
  */
-abstract public class TriggeringPolicyBase extends ContextAwareBase implements TriggeringPolicy {
+abstract public class TriggeringPolicyBase<E> extends ContextAwareBase implements TriggeringPolicy<E> {
   
   private boolean start;
 

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java	Wed Mar 19 22:06:42 2008
@@ -108,7 +108,7 @@
     
     FixedWindowRollingPolicy swrp = new FixedWindowRollingPolicy();
     swrp.setContext(context);
-    SizeBasedTriggeringPolicy sbtp = new SizeBasedTriggeringPolicy();
+    SizeBasedTriggeringPolicy<Object> sbtp = new SizeBasedTriggeringPolicy<Object>();
     sbtp.setContext(context);
 
     sbtp.setMaxFileSize("100");
@@ -180,7 +180,7 @@
 
     FixedWindowRollingPolicy fwrp = new FixedWindowRollingPolicy();
     fwrp.setContext(context);
-    SizeBasedTriggeringPolicy sbtp = new SizeBasedTriggeringPolicy();
+    SizeBasedTriggeringPolicy<Object> sbtp = new SizeBasedTriggeringPolicy<Object>();
     sbtp.setContext(context);
 
     sbtp.setMaxFileSize("100");



More information about the logback-dev mailing list