Differences between revisions 5 and 6
Revision 5 as of 2007-02-16 11:39:48
Size: 5217
Editor: 85
Comment:
Revision 6 as of 2007-02-16 11:44:50
Size: 5401
Editor: 85
Comment:
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
Line 29: Line 30:
{{{
#!java
{{{#!java
Line 33: Line 33:
            SVNURL url = SVNURL.parseURIDecoded( "svn://host/path_to_repository_root/inner_path" );
            SVNRepository repository = SVNRepositoryFactory.create( url , null );
            SVNURL url = SVNURL.parseURIDecoded(                                                                      "svn://host/path_to_repository_root/inner_path" );
            SVNRepository repository = SVNRepositoryFactory.create( url
                                                               
, null );
Line 36: Line 38:
       } catch (SVNException e) {        } catch ( SVNException e ) {
Line 40: Line 42:
Line 44: Line 47:
The diagram above illustrates how different drivers are created for different repository paths: one for the repository root (''svn://host/path_to_root''), one for a directory (''svn://host/path_to_root/dirA'') and one for a file (''svn://host/path_to_root/dirB/fileB1''). Most operations which [SVNRepository | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepository.html] driver can perform against a repository, accept a repository path which may be one of two types: * path that does not start with '/' - is always relative to the location the driver is bound to * path that does start with '/' - is always absolute to the repository root (always starts at the top of the repository tree) !!!Using high-level layer When you use __SVNKit__ for managing Working Copies you also should set up appropriate factory classes since the high-level layer uses the low-level one for working with a repository. If you miss this initialization step you may get an exception saying that __SVNKit__ could not create an [SVNRepository | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepository.html] object for the provided url. !!SVN*Client classes All high-level operations for managing Working Copies are logically divided to [SVN*Client | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/wc/package-summary.html] classes: each __SVN*Client__ class joins a separate group of operations (for example, [SVNUpdateClient | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/wc/SVNUpdateClient.html] provides API on update operations, such as checkout, update, switch, export). There're two different ways of instantiating objects of these classes: * Create only necessary __SVN*Client__ objects. * Create a single [SVNClientManager | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/wc/SVNClientManager.html] instance which provides objects of necessary __SVN*Client__ types. The diagram above illustrates how different drivers are created for different repository paths: one for the repository root ({{{svn://host/path_to_root}}}), one for a directory ({{{svn://host/path_to_root/dirA}}}) and one for a file ({{{svn://host/path_to_root/dirB/fileB1}}}). Most operations which [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepository.html SVNRepository] driver can perform against a repository, accept a repository path which may be one of two types:
   
* path that does not start with {{{'/'}}} - is always relative to the         location the driver is bound to
 
* path that does start with {{{'/'}}} - is always absolute to the
   
repository root (always starts at the top of the repository tree)

==
Using high-level layer When you use SVNKit for managing Working ==

Copies you also should set up appropriate factory classes since the high-level layer uses the low-level one for working with a repository. If you miss this initialization step you may get an exception saying that __SVNKit__ could not create an [SVNRepository | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepository.html] object for the provided url. !!SVN*Client classes All high-level operations for managing Working Copies are logically divided to [SVN*Client | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/wc/package-summary.html] classes: each __SVN*Client__ class joins a separate group of operations (for example, [SVNUpdateClient | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/wc/SVNUpdateClient.html] provides API on update operations, such as checkout, update, switch, export). There're two different ways of instantiating objects of these classes: * Create only necessary __SVN*Client__ objects. * Create a single [SVNClientManager | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/wc/SVNClientManager.html] instance which provides objects of necessary __SVN*Client__ types.

[:SVNKit Architecture:<< Previous Page]

[:Authentication:Next Page >>]

TableOfContents

How to use different repository access protocols in SVNKit?

When you have downloaded [http://svnkit.com/download/index.php the latest SVNKit binaries] and ready to start using it, a question arises: what initialization steps should be performed in order to set up the library? Direct interacting with a Subversion repository is carried out by a low-level layer, where the main class representing a repository access driver interface is an abstract [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepository.html SVNRepository] class. There are several protocol specific realizations of this driver, one for each protocol. Each driver is created by an abstract factory class - [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepositoryFactory.html SVNRepositoryFactory], which also has several protocol specific realizations, each one for each protocol. The following table matches a protocol against a corresponding SVNRepositoryFactory realization:

protocol

SVNRepositoryFactory realization

svn://

SVNRepositoryFactoryImpl

http://

DAVRepositoryFactory

file:///

FSRepositoryFactory

Instructions on initializing SVNKit

Prior to using the library you must set up an appropriate [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepositoryFactory.html SVNRepositoryFactory] realization for a particular protocol. For example, if you would like to work with a repository via the svn:// protocol, you must register the following factory:

   1        try {
   2             SVNRepositoryFactoryImpl.setup();
   3             ...
   4        } catch (SVNException e) {
   5             //handle exception
   6        }

After this step [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepositoryFactory.html SVNRepositoryFactory] knows how to create [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepository.html SVNRepository] drivers specific for the svn:// protocol since it now contains the registered factory. And further you create a driver itself:

   1        try {
   2             ...
   3             SVNURL url = SVNURL.parseURIDecoded(                                               
   4                       "svn://host/path_to_repository_root/inner_path" );
   5             SVNRepository repository = SVNRepositoryFactory.create( url 
   6                                                                , null );
   7             ...
   8        } catch ( SVNException e ) {
   9             //handle exception
  10        }

In SVNKit all repository urls are represented by the [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/SVNURL.html SVNURL] class. If a path string is not UTF-8 encoded yet, use the SVNURL's [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/SVNURL.html#parseURIDecoded(java.lang.String) parseURIDecoded()] method to create a new url representation (it will be encoded if necessary). Then you pass the url representation to the [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepositoryFactory.html SVNRepositoryFactory] to create a new [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepository.html SVNRepository] driver. So, this way you can bind your driver to any repository location you would like.

attachment:SVNRepository_connection2.png

The diagram above illustrates how different drivers are created for different repository paths: one for the repository root (svn://host/path_to_root), one for a directory (svn://host/path_to_root/dirA) and one for a file (svn://host/path_to_root/dirB/fileB1). Most operations which [http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepository.html SVNRepository] driver can perform against a repository, accept a repository path which may be one of two types:

  • path that does not start with '/' - is always relative to the

    • location the driver is bound to
  • path that does start with '/' - is always absolute to the

    • repository root (always starts at the top of the repository tree)

Using high-level layer When you use SVNKit for managing Working

Copies you also should set up appropriate factory classes since the high-level layer uses the low-level one for working with a repository. If you miss this initialization step you may get an exception saying that SVNKit could not create an [SVNRepository | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/io/SVNRepository.html] object for the provided url. !!SVN*Client classes All high-level operations for managing Working Copies are logically divided to [SVN*Client | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/wc/package-summary.html] classes: each SVN*Client class joins a separate group of operations (for example, [SVNUpdateClient | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/wc/SVNUpdateClient.html] provides API on update operations, such as checkout, update, switch, export). There're two different ways of instantiating objects of these classes: * Create only necessary SVN*Client objects. * Create a single [SVNClientManager | http://svnkit.com/kb/javadoc/org/tmatesoft/svn/core/wc/SVNClientManager.html] instance which provides objects of necessary SVN*Client types.

Getting_Started_With_SVNKit (last edited 2008-02-20 19:21:29 by nat7)