From 53be459570937bf6e737729e18142d5bb13de73c Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 24 Mar 2006 19:03:00 +0000 Subject: [PATCH] simple test of locked IO based on ArchiveWatcher. Extend this to quickly incorporate vamsas dataset updates into a program (? really) git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@209 be28352e-c001-0410-b1a7-c7978e42abec --- .../vamsas/test/simpleclient/ArchiveClient.java | 77 ++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/org/vamsas/test/simpleclient/ArchiveClient.java diff --git a/src/org/vamsas/test/simpleclient/ArchiveClient.java b/src/org/vamsas/test/simpleclient/ArchiveClient.java new file mode 100644 index 0000000..a5deb87 --- /dev/null +++ b/src/org/vamsas/test/simpleclient/ArchiveClient.java @@ -0,0 +1,77 @@ +/** + * + */ +package org.vamsas.test.simpleclient; + +import java.io.File; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.client.ClientHandle; +import org.vamsas.client.UserHandle; +import org.vamsas.client.simpleclient.FileWatcher; +import org.vamsas.client.simpleclient.SessionFile; +import org.vamsas.client.simpleclient.VamsasArchive; +import org.vamsas.client.simpleclient.VamsasFile; + +/** + * @author jimp + * test the VamsasFile routines for watching, reading and updating a vamsas document jar file. + */ +public class ArchiveClient { + Log log = LogFactory.getLog(ArchiveClient.class); + UserHandle user=null; + ClientHandle me = new ClientHandle("ArchiveClient","0.01"); + VamsasFile vsess; + + /** + * @param user + * @param vsess + */ + public ArchiveClient(UserHandle user, VamsasFile vsess) { + super(); + this.user = user; + this.vsess = vsess; + } + public ArchiveClient(String username, String organization, String vsess) { + super(); + this.user = new UserHandle(username, organization); + try { + this.vsess = new VamsasFile(new File(vsess)); + } catch (Exception e) { + log.error("Couldn't open session on file "+vsess,e); + this.vsess=null; + } + } + public void valid() { + if (vsess==null) + throw new Error("ArchiveClient instance is invalid!."); + } + /** + * + * @param time - length of time to watch for. + * @return IO interface for session document. + */ + public VamsasArchive watch(long time) { + valid(); + // wait around watching for a change. + VamsasArchive varch=null; + // FileWatcher w = new FileWatcher(vsess); + return varch; + } + + /** + * @param args + */ + public static void usage() { + throw new Error("Usage: Username Organization VamsasFile [command,args]*"); + } + public static void main(String[] args) { + // really simple. + if (args.length<3) + usage(); + ArchiveClient client = new ArchiveClient(args[0],args[1], args[2]); + + } + +} -- 1.7.10.2