[Webfunds-commits] java/webfunds/store AppendFileStore.java Store.java
Ian Grigg
iang@cypherpunks.ai
Sat, 30 Sep 2000 14:41:18 -0400 (AST)
iang 00/09/30 14:41:18
Modified: webfunds/store AppendFileStore.java Store.java
Log:
mods to permit class loader to pass from store to store
Revision Changes Path
1.14 +37 -13 java/webfunds/store/AppendFileStore.java
Index: AppendFileStore.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/store/AppendFileStore.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- AppendFileStore.java 2000/06/05 02:43:23 1.13
+++ AppendFileStore.java 2000/09/30 18:41:17 1.14
@@ -1,5 +1,5 @@
/*
- * $Id: AppendFileStore.java,v 1.13 2000/06/05 02:43:23 gelderen Exp $
+ * $Id: AppendFileStore.java,v 1.14 2000/09/30 18:41:17 iang Exp $
*
* Copyright (c) Systemics Ltd 1995-2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -86,16 +86,43 @@
* Open an empty, new AppendFileStore.
* Note this is for internal use only as there is no
* easy way to have a new empty object. Use getInstance instead.
+ *
+ * But, why would you want one?
+ * Opened up due to ClassLoader inheriting problems.
*/
- protected AppendFileStore(File dir, PrintWriter pw, String logfix)
+ public AppendFileStore(File dir, PrintWriter pw, String logfix)
throws StoreException
{
super();
+ init(dir, pw, logfix);
+ }
+
+ /**
+ * An uninitialised object, for ClassLoader.
+ */
+ public AppendFileStore()
+ throws StoreException
+ {
+ super();
+ }
+
+ /**
+ * Has to be a non-existant file.
+ */
+ public /* temp */ void init(File dir, PrintWriter pw, String logfix)
+ throws StoreException
+ {
this.dir = dir;
+ if (!dir.exists())
+ dir.mkdirs();
+ if (!dir.isDirectory() || !dir.canRead())
+ throw new StoreException("Cannot read as directory: " + dir);
+
this.name = dir.getPath();
this.bug = pw;
this.fix = logfix;
+ initFiles();
}
/**
@@ -143,13 +170,7 @@
throws StoreException
{
- if (!dir.exists())
- dir.mkdirs();
- if (!dir.isDirectory() || !dir.canRead())
- throw new StoreException("Cannot read as directory: " + dir);
-
AppendFileStore store = new AppendFileStore(dir, pw, logfix);
- store.init();
return store;
}
@@ -169,14 +190,14 @@
return num.intValue() ;
}
- protected void init()
+ protected void initFiles()
throws StoreException
{
//
// Find the latest file in the sequence.
// If nothing found, starts at 0.
//
- logmsg("init() " + dir.getPath());
+ logmsg("initFiles() " + dir.getPath());
int filenum = 0;
int lastfile = -1;
boolean found = false;
@@ -313,12 +334,15 @@
// OK, now try and recover this object.
// First get the class, then recover the object of that class.
//
+ ClassLoader cl = getClassLoader();
Class clss;
try {
- clss = Class.forName(className);
+ if (cl == null)
+ clss = Class.forName(className);
+ else // must be a 3rd party plugin
+ clss = cl.loadClass(className);
} catch (ClassNotFoundException ex) {
- logmsg("ignoring unknown class: CNFEx" + s);
- continue ;
+ throw new StoreException("CNFEx" + s + " cl=" + cl);
}
Object obj ;
1.22 +12 -1 java/webfunds/store/Store.java
Index: Store.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/store/Store.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Store.java 2000/05/27 02:54:13 1.21
+++ Store.java 2000/09/30 18:41:17 1.22
@@ -1,4 +1,4 @@
-/* $Id: Store.java,v 1.21 2000/05/27 02:54:13 iang Exp $
+/* $Id: Store.java,v 1.22 2000/09/30 18:41:17 iang Exp $
*
* Copyright (c) Systemics Ltd 1995-2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -31,6 +31,17 @@
protected String name;
protected Hashtable hash;
+
+ /**
+ * Get the ClassLoader, for 3rd party wallets.
+ * If the store is held by a classloader-instantiated wallet,
+ * store also needs explicit access to the classloader, in
+ * order to recover the classes specific to the wallet.
+ */
+ public ClassLoader getClassLoader() { return classLoader ; }
+ private ClassLoader classLoader = null;
+ public void setClassLoader(ClassLoader cl) { classLoader = cl; }
+
public Store()
{