Class SVNClientManager
- java.lang.Object
-
- org.tmatesoft.svn.core.wc.SVNClientManager
-
- All Implemented Interfaces:
ISVNRepositoryPool
public class SVNClientManager extends java.lang.Object implements ISVNRepositoryPool
The SVNClientManager class is used to manage SVN*Client objects as well as for providing them to a user what makes the user's work easier and his code - pretty clear and flexible.When you don't have special needs to create, keep and manage separate SVN*Client objects by yourself, you should use SVNClientManager that takes care of all that work for you. These are some of advantages of using SVNClientManager:
- If you instantiate an SVN*Client object by yourself
you need to provide a run-time configuration driver -
ISVNOptions
- as well as an authentication and network layers driver -ISVNAuthenticationManager
. When using an SVNClientManager you have multiple choices to provide and use those drivers://1.default options and authentication drivers to use SVNClientManager clientManager = SVNClientManager.newInstance(); ... //2.provided options and default authentication drivers to use ISVNOptions myOptions; ... SVNClientManager clientManager = SVNClientManager.newInstance(myOptions); ... //3.provided options and authentication drivers to use ISVNOptions myOptions; ISVNAuthenticationManager myAuthManager; ... SVNClientManager clientManager = SVNClientManager.newInstance(myOptions, myAuthManager); ... //4.provided options driver and user's credentials to make //a default authentication driver use them ISVNOptions myOptions; ... SVNClientManager clientManager = SVNClientManager.newInstance(myOptions, "name", "passw");
Having instantiated an SVNClientManager in one of these ways, all the SVN*Client objects it will provide you will share those drivers, so you don't need to code much to provide the same drivers to each SVN*Client instance by yourself. - With SVNClientManager you don't need to create and keep your SVN*Client objects by youself - SVNClientManager will do all the work for you, so this will certainly bring down your efforts on coding and your code will be clearer and more flexible. All you need is to create an SVNClientManager instance.
- Actually every SVN*Client object is instantiated only at
the moment of the first call to an appropriate SVNClientManager's
get
method:SVNClientManager clientManager; ... //an update client will be created only at that moment when you //first call this method for getting your update client, but if you //have already called it once before, then the method will return //that update client object instantiated in previous... so, it's //quite cheap, you see.. SVNUpdateClient updateClient = clientManager.getUpdateClient();
- You can provide a single event handler that will be used by all
SVN*Client objects provided by SVNClientManager:
import org.tmatesoft.svn.core.wc.ISVNEventHandler; ... ISVNEventHandler commonEventHandler; SVNClientManager clientManager = SVNClientManager.newInstance(); ... //will be used by all SVN*Client objects //obtained from your client manager clientManager.setEventHandler(commonEventHandler);
- Since:
- 1.2
- Version:
- 1.3
- Author:
- TMate Software Ltd.
- See Also:
ISVNEventHandler
, Examples
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SVNRepository
createRepository(SVNURL url, boolean mayReuse)
Creates a low-level SVN protocol driver to directly work with a repository.void
dispose()
Disposes this client object.SVNAdminClient
getAdminClient()
Returns an instance of theSVNAdminClient
class.SVNChangelistClient
getChangelistClient()
Returns an instance of theSVNChangelistClient
class.SVNCommitClient
getCommitClient()
Returns an instance of theSVNCommitClient
class.SVNCopyClient
getCopyClient()
Returns an instance of theSVNCopyClient
class.ISVNDebugLog
getDebugLog()
Returns the debug logger currently in use.SVNDiffClient
getDiffClient()
Returns an instance of theSVNDiffClient
class.SVNLogClient
getLogClient()
Returns an instance of theSVNLogClient
class.SVNLookClient
getLookClient()
Returns an instance of theSVNLookClient
class.SVNMoveClient
getMoveClient()
Returns an instance of theSVNMoveClient
class.SvnOperationFactory
getOperationFactory()
ISVNOptions
getOptions()
Returns the run-time configuration options driver which kept by this object.ISVNRepositoryPool
getRepositoryPool()
Returns the repository pool used by this client manager.SVNStatusClient
getStatusClient()
Returns an instance of theSVNStatusClient
class.SVNUpdateClient
getUpdateClient()
Returns an instance of theSVNUpdateClient
class.SVNWCClient
getWCClient()
Returns an instance of theSVNWCClient
class.protected void
initClientDefaults(SVNAdminBasicClient client)
protected void
initClientDefaults(SVNBasicClient client)
boolean
isIgnoreExternals()
Tells wheter externals are ignored or not.static SVNClientManager
newInstance()
Creates a new instance of this class using defaultISVNOptions
andISVNAuthenticationManager
drivers.static SVNClientManager
newInstance(DefaultSVNOptions options, java.lang.String userName, java.lang.String password)
Creates a new instance of this class using the providedISVNOptions
driver and user's credentials to make a default implementation ofISVNAuthenticationManager
use them.static SVNClientManager
newInstance(ISVNOptions options)
Creates a new instance of this class using the providedISVNOptions
and defaultISVNAuthenticationManager
drivers.static SVNClientManager
newInstance(ISVNOptions options, ISVNAuthenticationManager authManager)
Creates a new instance of this class using the providedISVNOptions
andISVNAuthenticationManager
drivers.static SVNClientManager
newInstance(ISVNOptions options, ISVNRepositoryPool repositoryPool)
Creates a new instance of this class using the provided config driver and creator of of SVNRepository objects.static SVNClientManager
newInstance(SvnOperationFactory operationFactory)
void
setAuthenticationManager(ISVNAuthenticationManager authManager)
Sets an authentication manager to this client manager.void
setCanceller(ISVNCanceller canceller)
Sets a canceller to this client manager.void
setDebugLog(ISVNDebugLog log)
Sets a logger to write debug log information to.void
setEventHandler(ISVNEventHandler handler)
Sets an event handler to all SVN*Client objects created and kept by this SVNClientManager.void
setIgnoreExternals(boolean isIgnoreExternals)
Sets whether externals should be ignored or not by all of the SVN*Clinet objects which this client manager will provide.void
setOptions(ISVNOptions options)
Sets global run-time configuration options to all of the SVN*Client objects provided by this client manager.void
shutdownConnections(boolean shutdownAll)
Deprecated.usedispose()
instead
-
-
-
Method Detail
-
newInstance
public static SVNClientManager newInstance()
Creates a new instance of this class using defaultISVNOptions
andISVNAuthenticationManager
drivers. That means this SVNClientManager will use the SVN's default run-time configuration area. Default options are obtained via a call toSVNWCUtil.createDefaultOptions(boolean)
.- Returns:
- a new SVNClientManager instance
-
newInstance
public static SVNClientManager newInstance(ISVNOptions options)
Creates a new instance of this class using the providedISVNOptions
and defaultISVNAuthenticationManager
drivers. That means this SVNClientManager will use the caller's configuration options (which correspond to options found in the default SVN's config file) and the default SVN's servers configuration and auth storage. Ifoptions
is null, default options are used which are obtained via a call toSVNWCUtil.createDefaultOptions(boolean)
.- Parameters:
options
- a config driver- Returns:
- a new SVNClientManager instance
-
newInstance
public static SVNClientManager newInstance(ISVNOptions options, ISVNAuthenticationManager authManager)
Creates a new instance of this class using the providedISVNOptions
andISVNAuthenticationManager
drivers. That means this SVNClientManager will use the caller's configuration options (which correspond to options found in the default SVN's config file) as well as authentication credentials and servers options (similar to options found in the default SVN's servers).- Parameters:
options
- a config driverauthManager
- an authentication driver- Returns:
- a new SVNClientManager instance
-
newInstance
public static SVNClientManager newInstance(SvnOperationFactory operationFactory)
-
newInstance
public static SVNClientManager newInstance(ISVNOptions options, ISVNRepositoryPool repositoryPool)
Creates a new instance of this class using the provided config driver and creator of of SVNRepository objects.- Parameters:
options
- a config driverrepositoryPool
- a creator of SVNRepository objects- Returns:
- a new SVNClientManager instance
-
newInstance
public static SVNClientManager newInstance(DefaultSVNOptions options, java.lang.String userName, java.lang.String password)
Creates a new instance of this class using the providedISVNOptions
driver and user's credentials to make a default implementation ofISVNAuthenticationManager
use them. That means this SVNClientManager will use the caller's configuration options (which correspond to options found in the default SVN's config file), the default SVN's servers configuration and the caller's credentials.- Parameters:
options
- a config driveruserName
- a user account namepassword
- a user password- Returns:
- a new SVNClientManager instance
-
createRepository
public SVNRepository createRepository(SVNURL url, boolean mayReuse) throws SVNException
Creates a low-level SVN protocol driver to directly work with a repository.The driver created will be set a default
ISVNAuthenticationManager
manager.Used by SVN*Client objects (managed by this SVNClientManager) to access a repository when needed.
- Specified by:
createRepository
in interfaceISVNRepositoryPool
- Parameters:
url
- a repository location to establish a connection with (will be the root directory for the working session)mayReuse
- if true then tries first tries to find a reusable driver or creates a new reusable one- Returns:
- a low-level API driver for direct interacting with a repository
- Throws:
SVNException
- See Also:
DefaultSVNRepositoryPool.createRepository(SVNURL, boolean)
-
shutdownConnections
public void shutdownConnections(boolean shutdownAll)
Deprecated.usedispose()
insteadDescription copied from interface:ISVNRepositoryPool
Forces cached SVNRepository driver objects to close their socket connections.A default implementation DefaultSVNRepositoryPool is able to cache SVNRepository objects in a common pool shared between multiple threads. This method allows to close connections of all the cached objects.
- Specified by:
shutdownConnections
in interfaceISVNRepositoryPool
- Parameters:
shutdownAll
- whether to shutdown connection that are considered active at the moment- See Also:
DefaultSVNRepositoryPool
-
dispose
public void dispose()
Disposes this client object. Call this method when you've finished working with this object. This will close any open network sessions.- Specified by:
dispose
in interfaceISVNRepositoryPool
-
getOptions
public ISVNOptions getOptions()
Returns the run-time configuration options driver which kept by this object.- Returns:
- a run-time options driver
-
setEventHandler
public void setEventHandler(ISVNEventHandler handler)
Sets an event handler to all SVN*Client objects created and kept by this SVNClientManager.The provided event handler will be set only to only those objects that have been already created (SVN*Client objects are instantiated by an SVNClientManager at the moment of the first call to a
get*Client()
method). So, the handler won't be set for those ones that have never been requested. However as they are first requested (and thus created) the handler will be set to them, too, since SVNClientManager is still keeping the handler.- Parameters:
handler
- an event handler
-
setIgnoreExternals
public void setIgnoreExternals(boolean isIgnoreExternals)
Sets whether externals should be ignored or not by all of the SVN*Clinet objects which this client manager will provide.- Parameters:
isIgnoreExternals
- whether externals should be ignored or not- Since:
- 1.2.0
-
isIgnoreExternals
public boolean isIgnoreExternals()
Tells wheter externals are ignored or not.- Returns:
- true if externals are ignored; otherwise false
- Since:
- 1.2.0
-
setOptions
public void setOptions(ISVNOptions options)
Sets global run-time configuration options to all of the SVN*Client objects provided by this client manager.- Parameters:
options
- run-time configuration options
-
getCommitClient
public SVNCommitClient getCommitClient()
Returns an instance of theSVNCommitClient
class.If it's the first time this method is being called the object is created, initialized and then returned. Further calls to this method will get the same object instantiated at that moment of the first call. SVNClientManager does not reinstantiate its SVN*Client objects.
- Returns:
- an SVNCommitClient instance
-
getAdminClient
public SVNAdminClient getAdminClient()
Returns an instance of theSVNAdminClient
class.If it's the first time this method is being called the object is created, initialized and then returned. Further calls to this method will get the same object instantiated at that moment of the first call. SVNClientManager does not reinstantiate its SVN*Client objects.
- Returns:
- an SVNAdminClient instance
-
getLookClient
public SVNLookClient getLookClient()
Returns an instance of theSVNLookClient
class.If it's the first time this method is being called the object is created, initialized and then returned. Further calls to this method will get the same object instantiated at that moment of the first call. SVNClientManager does not reinstantiate its SVN*Client objects.
- Returns:
- an SVNLookClient instance
-
getCopyClient
public SVNCopyClient getCopyClient()
Returns an instance of theSVNCopyClient
class.If it's the first time this method is being called the object is created, initialized and then returned. Further calls to this method will get the same object instantiated at that moment of the first call. SVNClientManager does not reinstantiate its SVN*Client objects.
- Returns:
- an SVNCopyClient instance
-
getDiffClient
public SVNDiffClient getDiffClient()
Returns an instance of theSVNDiffClient
class.If it's the first time this method is being called the object is created, initialized and then returned. Further calls to this method will get the same object instantiated at that moment of the first call. SVNClientManager does not reinstantiate its SVN*Client objects.
- Returns:
- an SVNDiffClient instance
-
getLogClient
public SVNLogClient getLogClient()
Returns an instance of theSVNLogClient
class.If it's the first time this method is being called the object is created, initialized and then returned. Further calls to this method will get the same object instantiated at that moment of the first call. SVNClientManager does not reinstantiate its SVN*Client objects.
- Returns:
- an SVNLogClient instance
-
getMoveClient
public SVNMoveClient getMoveClient()
Returns an instance of theSVNMoveClient
class.If it's the first time this method is being called the object is created, initialized and then returned. Further calls to this method will get the same object instantiated at that moment of the first call. SVNClientManager does not reinstantiate its SVN*Client objects.
- Returns:
- an SVNMoveClient instance
-
getStatusClient
public SVNStatusClient getStatusClient()
Returns an instance of theSVNStatusClient
class.If it's the first time this method is being called the object is created, initialized and then returned. Further calls to this method will get the same object instantiated at that moment of the first call. SVNClientManager does not reinstantiate its SVN*Client objects.
- Returns:
- an SVNStatusClient instance
-
getUpdateClient
public SVNUpdateClient getUpdateClient()
Returns an instance of theSVNUpdateClient
class.If it's the first time this method is being called the object is created, initialized and then returned. Further calls to this method will get the same object instantiated at that moment of the first call. SVNClientManager does not reinstantiate its SVN*Client objects.
- Returns:
- an SVNUpdateClient instance
-
getWCClient
public SVNWCClient getWCClient()
Returns an instance of theSVNWCClient
class.If it's the first time this method is being called the object is created, initialized and then returned. Further calls to this method will get the same object instantiated at that moment of the first call. SVNClientManager does not reinstantiate its SVN*Client objects.
- Returns:
- an SVNWCClient instance
-
getChangelistClient
public SVNChangelistClient getChangelistClient()
Returns an instance of theSVNChangelistClient
class.If it's the first time this method is being called the object is created, initialized and then returned. Further calls to this method will get the same object instantiated at that moment of the first call. SVNClientManager does not reinstantiate its SVN*Client objects.
- Returns:
- an SVNChangelistClient instance
- Since:
- 1.2.0
-
initClientDefaults
protected void initClientDefaults(SVNBasicClient client)
-
initClientDefaults
protected void initClientDefaults(SVNAdminBasicClient client)
-
getDebugLog
public ISVNDebugLog getDebugLog()
Returns the debug logger currently in use.If no debug logger has been specified by the time this call occurs, a default one (returned by
org.tmatesoft.svn.util.SVNDebugLog.getDefaultLog()
) will be created and used.- Returns:
- a debug logger
-
setDebugLog
public void setDebugLog(ISVNDebugLog log)
Sets a logger to write debug log information to. Sets this same logger object to all SVN*Client objects instantiated by this moment.- Specified by:
setDebugLog
in interfaceISVNRepositoryPool
- Parameters:
log
- a debug logger
-
setAuthenticationManager
public void setAuthenticationManager(ISVNAuthenticationManager authManager)
Sets an authentication manager to this client manager. This authentication manager will be used by all the SVN*Client objects provided by this client manager for authenticating the client side against the server side when needed (on demand) or preliminarily (if specified).- Specified by:
setAuthenticationManager
in interfaceISVNRepositoryPool
- Parameters:
authManager
- user's implementation of the authentication manager interface
-
setCanceller
public void setCanceller(ISVNCanceller canceller)
Sets a canceller to this client manager. This canceller will be used by all the SVN*Client objects provided by this client manager.- Specified by:
setCanceller
in interfaceISVNRepositoryPool
- Parameters:
canceller
- user's implementation of the canceller interface- Since:
- 1.2.0
-
getRepositoryPool
public ISVNRepositoryPool getRepositoryPool()
Returns the repository pool used by this client manager. This pool is used to create and manageSVNRepository
objects by all the SVN*Client objects provided by this client manager.- Returns:
- repository pool object
- Since:
- 1.2.0
-
getOperationFactory
public SvnOperationFactory getOperationFactory()
-
-