FileHistoryCache.java revision 5321cd178c121fcb737d72986ab0c991b9e6ffca
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
class FileHistoryCache implements HistoryCache {
static class FilePersistenceDelegate extends PersistenceDelegate {
}
}
/**
* Get a <code>File</code> object describing the cache file.
*
* @param file the file to find the cache for
* @return file that might contain cached history for <code>file</code>
*/
if (sourceRoot == null) {
return null;
}
try {
}
} catch (IOException ex) {
}
}
/**
* Read history from a file.
*/
XMLDecoder d = new XMLDecoder(
d.close();
}
if (!dir.isDirectory()) {
throw new IOException(
}
}
// We have a problem that multiple threads may access the cache layer
// at the same time. Since I would like to avoid read-locking, I just
// serialize the write access to the cache file. The generation of the
// cache file would most likely be executed during index generation, and
// that happens sequencial anyway....
// Generate the file with a temporary name and move it into place when
// I'm done so I don't have to protect the readers for partially updated
// files...
XMLEncoder e = new XMLEncoder(
e.writeObject(history);
e.close();
synchronized (lock) {
}
throw new IOException(
"Cachefile exists, and I could not delete it.");
}
}
throw new IOException("Failed to rename cache tmpfile.");
}
}
}
try {
} catch (Exception e) {
cache + "':");
e.printStackTrace();
}
}
long time;
try {
} catch (UnsupportedOperationException e) {
// In this case, we've found a file for which the SCM has no history
// An example is a non-SCCS file somewhere in an SCCS-controlled
// workspace.
return null;
}
catch (Exception e) {
e.printStackTrace();
throw e;
}
// Don't cache history-information for directories, since the
// history information on the directory may change if a file in
// a sub-directory change. This will cause us to present a stale
// history log until a the current directory is updated and
// invalidates the cache entry.
if (env.useHistoryCache()) {
// retrieving the history takes too long, cache it!
try {
} catch (Exception e) {
cache + "':");
e.printStackTrace();
}
}
}
}
return history;
}
}