ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Configuration Management in Java EE Applications Using Subversion
Pages: 1, 2, 3

Retrieving Differences Between Versions

To determine the differences that exist between two revisions, the SVNManager.showDifferences method is used. The JavaSVN class SVNDiffManager has the required implementation for getting the differences between two versions. A handle to this class can be obtained using the SVNClientManager class. The SVNDiffManager's doDiff method has a default implementation for returning the differences in a fixed format into the OutputStream passed in as a parameter. We can have custom implementations for getting the differences between two versions through the ISVNEditor class, but we will go with the default implementation for this example.



public String showDifferences(
                BaseTrackingObject obj,long revision1,
                long revision2) {
        ....
        //Create an instance of SVNClientManager
        //providing authentication
        SVNClientManager ourClientManager =
                        SVNClientManager.newInstance(
                        options, "name", "password");
        //Obtain the handle to DiffClient
        //from the client manager
        SVNDiffClient theDiff = ourClientManager
                        .getDiffClient();
        ....
        theDiff.doDiff(svnUrl, SVNRevision.
                create(revision1), svnUrl,
                SVNRevision.create(revision2),
                false, false, diffStream);
        ....
}

Conclusions

Enterprise applications deal with requirements to not just store and retrieve critical data assets, but also track the historical changes to such data. The traditional approaches to solve these requirements using relational databases do not present an elegant solution. Subversion, a version tracking system offers the required amount of support for tracking our sample LoanData object over time. The JavaSVN APIs were used for tasks such as storing the loan object, retrieving the object, retrieving the log of changes that are made to the object, and also showing the differences between two versions of the object.

We have examined only a basic set of features but there is plenty of support from Subversion for far more sophisticated requirements that are not uncommon for an enterprise-level application. Happy exploring!

Resources

Swaminathan Radhakrishnan works as a senior technical architect for Infosys Technologies, Ltd.


Return to ONJava.com.