科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道Java 项目中应用Subversion配置与管理 3

Java 项目中应用Subversion配置与管理 3

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

在Subversion中存储数据 ??? Subversion需要使用层次结构存储数据,这样我们先要设定一下领域实体的层次结构,这里使用一个命名为“DomainObjects”的文件夹来存放领域数据

作者:中国IT实验室 来源:中国IT实验室 2007年9月9日

关键字: 企业级 编程

  • 评论
  • 分享微博
  • 分享邮件

在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();
        ...
}


检索变化历史

    为检索指定领域对象的历史版本,需要调用SVNManager类的getRevisionLog方法; SVNRepository类的getLatestRevision方法可以得到当前版本号;SVNManager.log方法可以检索每个版本的日志,日志可以包含版本修订的日期、修改人、修改的内容等信息;SVNManager.getFile方法可以从Subversion仓库中取得领域对象指定版本的所有内容。
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);
        ....
}



上一页  [1] [2] [3] [4] 下一页  

查看本文来源

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章