From df8bab6b727d07e1ac16af40e08249a975b32ace Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Sat, 17 Mar 2012 21:55:05 +0000
Subject: [PATCH]   * Streaming: Scheduler cleanup

---
 .../net/i2p/client/streaming/SchedulerChooser.java    | 11 ++++++-----
 .../src/net/i2p/client/streaming/SchedulerClosed.java |  3 ---
 .../net/i2p/client/streaming/SchedulerClosing.java    |  3 +--
 .../i2p/client/streaming/SchedulerConnectedBulk.java  |  3 +--
 .../net/i2p/client/streaming/SchedulerConnecting.java |  2 --
 .../src/net/i2p/client/streaming/SchedulerDead.java   |  4 +---
 .../client/streaming/SchedulerHardDisconnected.java   |  4 +---
 .../src/net/i2p/client/streaming/SchedulerImpl.java   |  6 +++---
 .../net/i2p/client/streaming/SchedulerPreconnect.java |  2 --
 .../net/i2p/client/streaming/SchedulerReceived.java   |  4 +---
 10 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerChooser.java b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerChooser.java
index c9c9e0d38a..b0167809ab 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerChooser.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerChooser.java
@@ -11,11 +11,11 @@ import net.i2p.util.Log;
  *
  */
 class SchedulerChooser {
-    private I2PAppContext _context;
-    private Log _log;
-    private TaskScheduler _nullScheduler;
+    private final I2PAppContext _context;
+    private final Log _log;
+    private final TaskScheduler _nullScheduler;
     /** list of TaskScheduler objects */
-    private List _schedulers;
+    private final List _schedulers;
     
     public SchedulerChooser(I2PAppContext context) {
         _context = context;
@@ -48,8 +48,9 @@ class SchedulerChooser {
         rv.add(new SchedulerDead(_context));
         return rv;
     }
+
     private class NullScheduler implements TaskScheduler {
-        private Log _log;
+        private final Log _log;
         public NullScheduler() {
             _log = _context.logManager().getLog(NullScheduler.class);
         }
diff --git a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerClosed.java b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerClosed.java
index df09ff6d86..c9e8cae9b4 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerClosed.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerClosed.java
@@ -1,7 +1,6 @@
 package net.i2p.client.streaming;
 
 import net.i2p.I2PAppContext;
-import net.i2p.util.Log;
 
 /**
  * <p>Scheduler used for after both sides have had their close packets
@@ -25,10 +24,8 @@ import net.i2p.util.Log;
  *
  */
 class SchedulerClosed extends SchedulerImpl {
-    private Log _log;
     public SchedulerClosed(I2PAppContext ctx) {
         super(ctx);
-        _log = ctx.logManager().getLog(SchedulerClosed.class);
     }
     
     public boolean accept(Connection con) {
diff --git a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerClosing.java b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerClosing.java
index d3bc3d4471..29e69f6fa3 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerClosing.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerClosing.java
@@ -27,10 +27,9 @@ import net.i2p.util.Log;
  *
  */
 class SchedulerClosing extends SchedulerImpl {
-    private Log _log;
+
     public SchedulerClosing(I2PAppContext ctx) {
         super(ctx);
-        _log = ctx.logManager().getLog(SchedulerClosing.class);
     }
     
     public boolean accept(Connection con) {
diff --git a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerConnectedBulk.java b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerConnectedBulk.java
index fcbaa5b2c9..6edb3a17cb 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerConnectedBulk.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerConnectedBulk.java
@@ -30,10 +30,9 @@ import net.i2p.util.Log;
  *
  */
 class SchedulerConnectedBulk extends SchedulerImpl {
-    private Log _log;
+
     public SchedulerConnectedBulk(I2PAppContext ctx) {
         super(ctx);
-        _log = ctx.logManager().getLog(SchedulerConnectedBulk.class);
     }
     
     public boolean accept(Connection con) {
diff --git a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerConnecting.java b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerConnecting.java
index 5e4930116d..1df4ecdfd9 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerConnecting.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerConnecting.java
@@ -27,11 +27,9 @@ import net.i2p.util.Log;
  *
  */
 class SchedulerConnecting extends SchedulerImpl {
-    private Log _log;
     
     public SchedulerConnecting(I2PAppContext ctx) {
         super(ctx);
-        _log = ctx.logManager().getLog(SchedulerConnecting.class);
     }
     
     public boolean accept(Connection con) {
diff --git a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerDead.java b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerDead.java
index 4fb78df20a..9aa70ea8e3 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerDead.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerDead.java
@@ -1,7 +1,6 @@
 package net.i2p.client.streaming;
 
 import net.i2p.I2PAppContext;
-import net.i2p.util.Log;
 
 /**
  * <p>Scheduler used for after the final timeout has passed or the
@@ -24,10 +23,9 @@ import net.i2p.util.Log;
  *
  */
 class SchedulerDead extends SchedulerImpl {
-    private Log _log;
+
     public SchedulerDead(I2PAppContext ctx) {
         super(ctx);
-        _log = ctx.logManager().getLog(SchedulerDead.class);
     }
     
     public boolean accept(Connection con) {
diff --git a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerHardDisconnected.java b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerHardDisconnected.java
index 249fea21bd..597e2c6ca6 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerHardDisconnected.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerHardDisconnected.java
@@ -1,7 +1,6 @@
 package net.i2p.client.streaming;
 
 import net.i2p.I2PAppContext;
-import net.i2p.util.Log;
 
 /**
  * <p>Scheduler used after we've locally done a hard disconnect, 
@@ -25,10 +24,9 @@ import net.i2p.util.Log;
  *
  */
 class SchedulerHardDisconnected extends SchedulerImpl {
-    private Log _log;
+
     public SchedulerHardDisconnected(I2PAppContext ctx) {
         super(ctx);
-        _log = ctx.logManager().getLog(SchedulerHardDisconnected.class);
     }
     
     public boolean accept(Connection con) {
diff --git a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerImpl.java b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerImpl.java
index e02a1b413e..511c774e32 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerImpl.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerImpl.java
@@ -8,8 +8,8 @@ import net.i2p.util.SimpleScheduler;
  * Base scheduler
  */
 abstract class SchedulerImpl implements TaskScheduler {
-    protected I2PAppContext _context;
-    private Log _log;
+    protected final I2PAppContext _context;
+    protected final Log _log;
     
     public SchedulerImpl(I2PAppContext ctx) {
         _context = ctx;
@@ -17,6 +17,6 @@ abstract class SchedulerImpl implements TaskScheduler {
     }
     
     protected void reschedule(long msToWait, Connection con) {
-        SimpleScheduler.getInstance().addEvent(con.getConnectionEvent(), msToWait);
+        _context.simpleScheduler().addEvent(con.getConnectionEvent(), msToWait);
     }
 }
diff --git a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerPreconnect.java b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerPreconnect.java
index 091a7131f6..fdbefe1c3b 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerPreconnect.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerPreconnect.java
@@ -22,11 +22,9 @@ import net.i2p.util.Log;
  * </ul>
  */
 class SchedulerPreconnect extends SchedulerImpl {
-    private Log _log;
     
     public SchedulerPreconnect(I2PAppContext ctx) {
         super(ctx);
-        _log = ctx.logManager().getLog(SchedulerPreconnect.class);
     }
     
     public boolean accept(Connection con) {
diff --git a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerReceived.java b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerReceived.java
index 343b716201..e44c68d116 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerReceived.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerReceived.java
@@ -9,11 +9,9 @@ import net.i2p.util.Log;
  *
  */
 class SchedulerReceived extends SchedulerImpl {
-    private Log _log;
     
     public SchedulerReceived(I2PAppContext ctx) {
         super(ctx);
-        _log = ctx.logManager().getLog(SchedulerReceived.class);
     }
     
     public boolean accept(Connection con) {
@@ -46,4 +44,4 @@ class SchedulerReceived extends SchedulerImpl {
             reschedule(timeTillSend, con);
         }
     }
-}
\ No newline at end of file
+}
-- 
GitLab