JavaSVN Home

org.tmatesoft.svn.core.io
Class SVNRepositoryFactory

java.lang.Object
  extended byorg.tmatesoft.svn.core.io.SVNRepositoryFactory

public abstract class SVNRepositoryFactory
extends Object

SVNRepositoryFactory is an abstract factory that is responsible for creating an appropriate SVNRepository driver specific for the protocol (svn, http) to use.

Depending on what protocol a user exactly would like to use to access the repository he should first of all set up an appropriate extension of this factory. So, if the user is going to work with the repository via the custom svn-protocol (or svn+ssh) he initially calls:

 ...
 import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
 ...      
     //do it once in your application prior to using the library
     //enables working with a repository via the svn-protocol (over svn and svn+ssh)
     SVNRepositoryFactoryImpl.setup();
 ...

That setup() method registers an SVNRepositoryFactoryImpl instance in the factory (calling registerRepositoryFactory). From this point the SVNRepositoryFactory knows how to create SVNRepository instances specific for the svn-protocol. And further the user can create an SVNRepository instance:
     ...
     //the user gets an SVNRepository not caring
     //how it's implemented for the svn-protocol
     SVNRepository repository = SVNRepositoryFactory.create(location);
     ...

All that was previously said about the svn-protocol is similar for the WebDAV-protocol:
 ...
 import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
 ...
 
     //do it once in your application prior to using the library
     //enables working with a repository via the DAV-protocol (over http and https)
     DAVRepositoryFactory.setup();
 ...

NOTE: unfortunately, at present the JavaSVN library doesn't provide an implementation for accessing a Subversion repository via the file:/// protocol (on a local machine), but in future it will be certainly realized.

Version:
1.0
Author:
TMate Software Ltd.
See Also:
SVNRepository, Examples

Constructor Summary
SVNRepositoryFactory()
           
 
Method Summary
static SVNRepository create(SVNURL url)
          Creates an SVNRepository driver according to the protocol that is to be used to access a repository.
static SVNRepository create(SVNURL url, ISVNSession options)
          Creates an SVNRepository driver according to the protocol that is to be used to access a repository.
protected abstract  SVNRepository createRepositoryImpl(SVNURL url, ISVNSession session)
           
protected static boolean hasRepositoryFactory(String protocol)
           
protected static void registerRepositoryFactory(String protocol, SVNRepositoryFactory factory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SVNRepositoryFactory

public SVNRepositoryFactory()
Method Detail

registerRepositoryFactory

protected static void registerRepositoryFactory(String protocol,
                                                SVNRepositoryFactory factory)

hasRepositoryFactory

protected static boolean hasRepositoryFactory(String protocol)

create

public static SVNRepository create(SVNURL url)
                            throws SVNException
Creates an SVNRepository driver according to the protocol that is to be used to access a repository.

The protocol is defined as the beginning part of the URL schema. Currently JavaSVN supports only svn:// (svn+ssh://) and http:// (https://) schemas.

The created SVNRepository driver can later be "reused" for another location - that is you can switch it to another repository url not to create yet one more SVNRepository object. Use the SVNRepository.setLocation() method for this purpose.

An SVNRepository driver created by this method uses a default session options driver (ISVNSession.DEFAULT) which does not allow to keep a single socket connection opened and commit log messages caching.

Parameters:
url - a repository location URL
Returns:
a protocol specific SVNRepository driver
Throws:
SVNException - if there's no implementation for the specified protocol (the user may have forgotten to register a specific factory that creates SVNRepository instances for that protocol or the JavaSVN library does not support that protocol at all)
See Also:
create(SVNURL, ISVNSession), SVNRepository

create

public static SVNRepository create(SVNURL url,
                                   ISVNSession options)
                            throws SVNException
Creates an SVNRepository driver according to the protocol that is to be used to access a repository.

The protocol is defined as the beginning part of the URL schema. Currently JavaSVN supports only svn:// (svn+ssh://) and http:// (https://) schemas.

The created SVNRepository driver can later be "reused" for another location - that is you can switch it to another repository url not to create yet one more SVNRepository object. Use the SVNRepository.setLocation() method for this purpose.

This method allows to customize a session options driver for an SVNRepository driver. A session options driver must implement the ISVNSession interface. It manages socket connections - says whether an SVNRepository driver may use a single socket connection during the runtime, or it should open a new connection per each repository access operation. And also a session options driver may cache and provide commit log messages during the runtime.

Parameters:
url - a repository location URL
options - a session options driver
Returns:
a protocol specific SVNRepository driver
Throws:
SVNException - if there's no implementation for the specified protocol (the user may have forgotten to register a specific factory that creates SVNRepository instances for that protocol or the JavaSVN library does not support that protocol at all)
See Also:
create(SVNURL), SVNRepository

createRepositoryImpl

protected abstract SVNRepository createRepositoryImpl(SVNURL url,
                                                      ISVNSession session)

JavaSVN Home

Copyright © 2004-2006 TMate Software Ltd. All Rights Reserved.