+ /**
+ * Replaces data in sessionFile with data from file handled by another sessionFile
+ * passes up any exceptions.
+ * @param newData source for new data
+ */
+ protected void updateFrom(Lock extantLock, SessionFile newData) throws IOException {
+ log.debug("Updating "+sessionFile.getAbsolutePath()+" from "+newData.sessionFile.getAbsolutePath());
+ if (newData==null)
+ throw new IOException("Null newData object.");
+ if (newData.sessionFile==null)
+ throw new IOException("Null SessionFile in newData.");
+
+ lockFile(extantLock);
+ newData.lockFile();
+ fileLock.rafile.getChannel().transferFrom(newData.fileLock.rafile.getChannel(), 0,
+ newData.fileLock.rafile.length());
+ }
+ /**
+ * remove all trace of the sessionFile file
+ *
+ */
+ protected void eraseExistence() {
+ unlockFile();
+ if (sessionFile!=null) {
+ sessionFile.delete();
+ sessionFile = null;
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.vamsas.client.simpleclient.Lock#getBufferedInputStream(boolean)
+ */
+ public BufferedInputStream getBufferedInputStream(boolean atStart) throws IOException {
+ lockFile();
+ return fileLock.getBufferedInputStream(atStart);
+ }
+
+ /* (non-Javadoc)
+ * @see org.vamsas.client.simpleclient.Lock#getBufferedOutputStream(boolean)
+ */
+ public BufferedOutputStream getBufferedOutputStream(boolean clear) throws IOException {
+ lockFile();
+ return fileLock.getBufferedOutputStream(clear);
+ }