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
- Sample code for this article and related installation instructions
- The Subversion website has the required information
- Version Control with Subversion is also available online
- Code samples and API specs for JavaSVN
Swaminathan Radhakrishnan works as a senior technical architect for Infosys Technologies, Ltd.
Return to ONJava.com.
-
Requires Two-Phase Commit
2008-07-29 16:35:51 Andrew Swan [View]
-
Good idea but ...
2006-05-31 01:03:49 Paul Browne |
[View]
-
Good idea but ...
2008-07-29 16:39:29 Andrew Swan [View]
-
svn: Malformed network data?
2006-05-05 09:57:28 justes [View]
-
svn: Malformed network data?
2006-05-05 10:03:36 justes [View]
-
Application which does this
2006-05-04 08:29:54 michal.dobisek [View]
-
interesting idea
2006-05-04 02:23:45 grahamoregan [View]