[Webfunds-commits] java/webfunds/sox/server DirSSDStore.java SSD.java SimpleServer.java SmartServer.java Test.java
Ian Grigg
iang@cypherpunks.ai
Thu, 12 Apr 2001 00:48:02 -0400 (AST)
iang 01/04/12 00:48:02
Modified: webfunds/sox/server DirSSDStore.java SSD.java
SimpleServer.java SmartServer.java Test.java
Log:
all changed to Log, from PrintWriter,
fixed up formatting,
changed some "issuer" words to "server"s.
Revision Changes Path
1.3 +6 -6 java/webfunds/sox/server/DirSSDStore.java
Index: DirSSDStore.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/server/DirSSDStore.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DirSSDStore.java 2001/04/08 19:41:58 1.2
+++ DirSSDStore.java 2001/04/12 04:48:01 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: DirSSDStore.java,v 1.2 2001/04/08 19:41:58 iang Exp $
+ * $Id: DirSSDStore.java,v 1.3 2001/04/12 04:48:01 iang Exp $
*
* Copyright (c) 1995-2001 Systemics Inc on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -8,7 +8,6 @@
import java.io.File;
import java.io.IOException;
-import java.io.PrintWriter;
import java.util.Hashtable;
import java.util.Enumeration;
@@ -17,6 +16,7 @@
import java.net.MalformedURLException;
import webfunds.util.Panic;
+import webfunds.util.Log;
import webfunds.utils.Debug;
@@ -83,7 +83,7 @@
* @param dir a directory with server files
* @param bug place to put debugging during construction
*/
- public DirSSDStore(CommsManager comms, File dir, PrintWriter bug)
+ public DirSSDStore(CommsManager comms, File dir, Log bug)
{
debug(bug, " dS: ");
this.comms = comms;
@@ -134,7 +134,7 @@
{
SSD ssdfile;
try {
- ssdfile = SSD.getInstance(f, getDebug());
+ ssdfile = SSD.getInstance(f, getLog());
} catch (SSDException ex) {
ex.printStackTrace(System.err);
logmsg("removing " + name);
@@ -441,7 +441,7 @@
URL url = urls[i];
logmsg("net <" + i + "> " + url);
- ssd = SSD.getInstance(url, comms, getDebug());
+ ssd = SSD.getInstance(url, comms, getLog());
if (ssd != null)
return ssd ;
// might want to keep searching here, if we are refreshing
@@ -461,7 +461,7 @@
//return ssds.get(name);
File f = new File(dir, name);
- SSD ssdfile = SSD.getInstance(f, getDebug());
+ SSD ssdfile = SSD.getInstance(f, getLog());
return ssdfile ;
}
1.3 +9 -11 java/webfunds/sox/server/SSD.java
Index: SSD.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/server/SSD.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SSD.java 2001/04/08 19:41:58 1.2
+++ SSD.java 2001/04/12 04:48:01 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: SSD.java,v 1.2 2001/04/08 19:41:58 iang Exp $
+ * $Id: SSD.java,v 1.3 2001/04/12 04:48:01 iang Exp $
*
* Copyright (c) 1995-2001 Systemics Inc on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -21,6 +21,7 @@
import webfunds.util.IniFileReader;
import webfunds.util.FormattedFileException;
import webfunds.util.Support;
+import webfunds.util.Log;
import webfunds.comms.RawHttp;
import webfunds.comms.URLSupport;
@@ -71,13 +72,11 @@
// implements Diagnostics - EXPERIMENTAL !!!
// mixing these classes is a bit non-OO. But, it seems many need both.
// another option would be to extend from Debug.
- protected PrintWriter bug = null;
+ protected Log bug = null;
protected String fix = " ss- ";
public void logmsg(String s) { if (bug != null) bug.println(fix + s); }
public PrintWriter getDebug() { return bug ; }
- // hmm, no autoflush.
- public PrintWriter err()
- { return (bug == null) ? new PrintWriter(System.err, true) : bug ; }
+ public PrintWriter err() { return (bug == null) ? new Log() : bug ; }
@@ -96,11 +95,11 @@
/////// Constructors /////////////////////////////////////////////
- public SSD(byte[] fileData, String name, PrintWriter bug)
+ public SSD(byte[] fileData, String name, Log bug)
throws SSDException
{
if (bug != null)
- this.bug = new PrintWriter(bug, true);
+ this.bug = new Log(bug, true);
this.fileData = fileData;
this.originalName = name;
init();
@@ -187,7 +186,7 @@
*
* @param file name for SSD file
*/
- public static SSD getInstance(File serverfile, PrintWriter bug)
+ public static SSD getInstance(File serverfile, Log bug)
throws SSDException
{
@@ -217,7 +216,7 @@
* @param comms where to get a comms requestor from
*/
public static SSD getInstance(URL url, CommsManager comms,
- PrintWriter bug)
+ Log bug)
throws SSDException, SOXLaterException
{
String proto = url.getProtocol();
@@ -691,7 +690,7 @@
String name = arg[0];
SSD ssd = null;
- PrintWriter bug = new PrintWriter(System.err);
+ Log bug = new Log();
CommsManager comms = new BasicCommsManager(bug);
try
@@ -712,7 +711,6 @@
ex.printStackTrace(bug);
System.exit(1);
}
- // ssd.debug(new PrintWriter(System.err, true));
System.err.println("SSD: " + ssd.getName());
String[] names = ssd.getAllNames();
for (int i = 0; i < names.length; i++)
1.4 +5 -4 java/webfunds/sox/server/SimpleServer.java
Index: SimpleServer.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/server/SimpleServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SimpleServer.java 2001/04/11 19:33:04 1.3
+++ SimpleServer.java 2001/04/12 04:48:01 1.4
@@ -13,6 +13,7 @@
import cryptix.openpgp.*;
import cryptix.openpgp.util.PGPArmoury;
+import webfunds.util.Log;
import webfunds.utils.Debug;
import webfunds.comms.*;
@@ -38,14 +39,14 @@
* This class is a "Server Agent" that passes basic requests to the Server.
* It should be passive until requested.
*
- * @version $Id: SimpleServer.java,v 1.3 2001/04/11 19:33:04 iang Exp $
+ * @version $Id: SimpleServer.java,v 1.4 2001/04/12 04:48:01 iang Exp $
*/
public final class SimpleServer
extends Debug
implements Server
{
protected final static String TAB = " ";
- protected String logfix = TAB + "i-";
+ protected String logfix = TAB + "s ";
/**
* The name of the server.
@@ -102,9 +103,9 @@
* @param agent the comms agent that sends requests at the transport layer
*/
public SimpleServer(String name, Certificate signer, CommsAgent agent,
- PrintWriter bug)
+ Log bug)
{
- debug(bug, " i ");
+ debug(bug, logfix);
this.name = name;
this.signer = signer;
1.4 +15 -11 java/webfunds/sox/server/SmartServer.java
Index: SmartServer.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/server/SmartServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SmartServer.java 2001/04/11 19:33:20 1.3
+++ SmartServer.java 2001/04/12 04:48:01 1.4
@@ -4,7 +4,6 @@
*/
package webfunds.sox.server;
-import java.io.PrintWriter;
import java.net.URL;
import java.net.MalformedURLException;
import java.security.cert.Certificate;
@@ -13,6 +12,7 @@
import webfunds.utils.Debug;
import webfunds.util.Panic;
+import webfunds.util.Log;
import webfunds.comms.*;
@@ -30,11 +30,14 @@
* switch whenever a problem is detected.
*
* This was webfunds.sox.SmartIssuer.
- * @version $Id: SmartServer.java,v 1.3 2001/04/11 19:33:20 iang Exp $
+ * @version $Id: SmartServer.java,v 1.4 2001/04/12 04:48:01 iang Exp $
*/
public class SmartServer
extends Debug implements Server // , IssuerFinder
{
+ protected final static String TAB = " ";
+ protected String logfix = TAB + "S-";
+
protected URL[] urls;
protected URL[] others;
protected int which;
@@ -91,10 +94,10 @@
DirSSDStore ssds,
Certificate cert,
CommsManager comms,
- PrintWriter bug)
+ Log bug)
throws SOXServerException
{
- debug(bug, " I ");
+ debug(bug, logfix);
this.name = name;
this.ssds = ssds;
@@ -119,7 +122,7 @@
/**
* Do the things necessary for being ready for a request.
- * On return, current is set to a hopefully valid Issuer.
+ * On return, current is set to a hopefully valid Server.
*/
public void startSimpleServers(URL[] urls)
{
@@ -130,8 +133,9 @@
URL url = urls[which % len];
logmsg("new Simple at " + url);
- CommsAgent agent = new HttpSocketAgent(url, comms, getDebug());
- SimpleServer simp = new SimpleServer(""+i, cert, agent, getDebug());
+ CommsAgent agent = new HttpSocketAgent(url, comms, getLog());
+ SimpleServer simp = new SimpleServer(""+i, cert, agent,
+ (Log)getDebug());
servers[i] = simp;
}
@@ -169,7 +173,7 @@
/**
* Do the things necessary for being ready for a request.
- * On return, current is set to a hopefully valid Issuer.
+ * On return, current is set to a hopefully valid Server.
*/
public void getReadyToRequest()
throws SOXLaterException, SOXServerException
@@ -264,7 +268,7 @@
checkNet();
if (failures == 0 && laters == 0) // cannot happen?
- throw new Panic("failures == laters == 0: no Issuers?");
+ throw new Panic("failures == laters == 0: no Servers?");
if (failures == 0)
throw new SOXLaterException(SOXLaterException.LATER_DOWN,
@@ -308,7 +312,7 @@
checkNet();
if (failures == 0 && laters == 0)
- throw new Panic("failures == laters == 0: no Issuers?");
+ throw new Panic("failures == laters == 0: no Servers?");
if (failures == 0)
throw new SOXLaterException(SOXLaterException.LATER_DOWN,
"tried them all, but all are down");
@@ -408,7 +412,7 @@
return good ;
if (failures == 0) // cannot happen?
- throw new Panic("failures == laters == 0: no Issuers?");
+ throw new Panic("failures == laters == 0: no Servers?");
throw new SOXLaterException(SOXLaterException.LATER_NET,
"cannot see net, check your connectivity");
1.2 +4 -3 java/webfunds/sox/server/Test.java
Index: Test.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/server/Test.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Test.java 2001/04/08 19:41:58 1.1
+++ Test.java 2001/04/12 04:48:01 1.2
@@ -1,5 +1,5 @@
/*
- * $Id: Test.java,v 1.1 2001/04/08 19:41:58 iang Exp $
+ * $Id: Test.java,v 1.2 2001/04/12 04:48:01 iang Exp $
*
* Copyright (c) 2001 Systemics Inc on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -8,8 +8,9 @@
import java.io.File;
import java.io.IOException;
-import java.io.PrintWriter;
+import webfunds.util.Log;
+
import webfunds.comms.CommsManager;
import webfunds.comms.BasicCommsManager;
@@ -45,7 +46,7 @@
File testDir = new File(arg[1]);
testDir.mkdir();
- PrintWriter bug = new PrintWriter(System.err, true);
+ Log bug = new Log();
DirContractStore cons = new DirContractStore(contractsDir, bug);
CommsManager cm = new BasicCommsManager(bug);
DirSSDStore store = new DirSSDStore(cm, testDir, bug);