扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
在Subversion中存储数据
Subversion需要使用层次结构存储数据,这样我们先要设定一下领域实体的层次结构,这里使用一个命名为“DomainObjects”的文件夹来存放领域数据。领域对象类将会检测这个目录下存放领域对象的所有子目录,而每个独立的域对象被以XML格式进行存储,并以其主键进行命名。
为存储LoanData域对象,我们先要执行SVNManager对象的checkInObject方法,通过SVNRepository 执行的ISVNEditor对象来在Subversion仓库中的建立和更新域对象的版本,但只有在closeEdit被调用后,才会提交所有的操作。SVNDeltaGenerator类用于获取当前版本与被更新版本之间的差异,Subversion通过存储版本间差异部分的形式存放新的版本,这样会使提高网络效率。
public SVNResult checkInObject(
BaseTrackingObject obj){
.....
//Obtain the editor handle from the
//repository
ISVNEditor editor = theRepository.
getCommitEditor(obj.
getModificationReason(), null);
....
//create the file at the specified path
editor.addFile(path, null, -1);
}
else {
//file is already present, so open
//the file in the repository
editor.openFile(path, -1);
}
....
String checksum = deltaGenerator.
sendDelta(path,
new ByteArrayInputStream(
obj.getXmlRepresentation().
getBytes()),
editor, true);
.....
editor.closeEdit();
...
}
public List getRevisionLog(BaseTrackingObject
obj, long startRevision,
long endRevision) {
.....
if(endRevision==-1) {
//obtain the latest revision from
//the repository
endRevision =
theRepository.getLatestRevision();
}
//retrieve the various log entries for
//the particular object path
Collection revisionLogs = theRepository.
log(new String[] {path}, null,
startRevision, endRevision,
false, true);
....
//Obtain the contents of the object at
//the specified revision
theRepository.getFile(path, revisionInfo.
getRevisionNumber(),
new Properties(),
xmlFileContentsStream);
....
}
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者