JBoss.orgCommunity Documentation
This connector provides read and write access to the directories and folders within a Subversion repository, providing that content in
the form of nt:file
and nt:folder
nodes.
This source considers a workspace name to be the path to the directory on the repository's root directory location
that represents the root of that workspace (e.g., "trunk" or "branches").
New workspaces can be created, as long as the names represent valid existing directories within the SVN repository.
The SvnRepositorySource
class provides a number of JavaBean properties that control its behavior:
Table 17.1. SvnRepositorySource
properties
Property | Description |
---|---|
cachePolicy | Optional property that, if used, defines the cache policy to use for caching information in the repository. When not used, this source will not define a specific duration for caching information. |
creatingWorkspaceAllowed | Optional property that defines whether clients can create additional workspaces. The default value is "true". |
defaultWorkspaceName | Optional property that, if used, specifies the name of the workspace to use when no workspace name is specified in an operation. Each workspace name is treated as a path relative to the SVN repository being exposed (e.g., a workspace name of "trunk" will map to the URL "http://acme.com/repo/trunk" if the repository root URL is "http://acme.com/repo/"). |
name | The name of the repository source, which is used by the RepositoryService when obtaining a RepositoryConnection by name. |
password | The password that should be used to establish a connection to the repository. This is not required if the URL represents an anonymous SVN repository address. |
predefinedWorkspaceNames | Optional property that, if used, defines names of the workspaces that are predefined and need not be created before being used. Each workspace name is treated as a path relative to the SVN repository being exposed (e.g., a workspace name of "trunk" will map to the URL "http://acme.com/repo/trunk" if the repository root URL is "http://acme.com/repo/"). This can be coupled with a "false" value for the "creatingWorkspaceAllowed" property to allow only the use of predefined workspaces. |
repositoryRootURL | Required property that should be set with the URL to the Subversion repository. |
retryLimit | Optional property that, if used, defines the number of times that any single operation on a RepositoryConnection to this source should be retried following a communication failure. The default value is '0'. |
username | The username that should be used to establish a connection to the repository. |
One way to configure the Subversion connector is to create JcrConfiguration
instance with a repository source that uses the SvnRepositorySource
class.
For example:
JcrConfiguration config = ...
config.repositorySource("SVN Store")
.usingClass(SVNRepositorySource.class)
.setDescription("The ModeShape SVN repository (anonymous access)")
.setProperty("repositoryRootUrl", "http://anonsvn.jboss.org/repos/modeshape");
.setProperty("defaultWorkspaceName", "trunk");
.setProperty("predefinedWorkspaceNames", new String[] {"trunk" });
Another way to configure the Subversion connector is to create JcrConfiguration
instance and load an XML configuration file that contains a repository source that
uses the SvnRepositorySource
class.
For example a file named configRepository.xml can be created with these contents:
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:mode="http://www.modeshape.org/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
<!--
Define the sources for the content. These sources are directly accessible using the
ModeShape-specific Graph API. In fact, this is how the ModeShape JCR implementation works. You
can think of these as being similar to JDBC DataSource objects, except that they expose
graph content via the Graph API instead of records via SQL or JDBC.
-->
<mode:sources jcr:primaryType="nt:unstructured">
<!--
The 'SVN Store' repository is an Subversion source with one workspace (although others could
be defined).
-->
<mode:source jcr:name="SVN Store"
mode:classname="org.modeshape.connector.svn.SVNRepositorySource"
mode:description="The ModeShape SVN repository (anonymous access)"
mode:repositoryRootUrl="http://anonsvn.jboss.org/repos/modeshape"
mode:defaultWorkspaceName="trunk"
mode:predefinedWorkspaceNames="trunk"
mode:defaultWorkspaceName="default" >
<!--
If desired, specify a cache policy that caches items in memory for 5 minutes (300000 ms).
This fragment can be left out if the connector should not cache any content.
-->
<mode:cachePolicy jcr:name="cachePolicy"
mode:classname="org.modeshape.graph.connector.path.cache.InMemoryWorkspaceCache$InMemoryCachePolicy"
mode:timeToLiveInMilliseconds="300000" />
</mode:source>
</mode:sources>
<!-- MIME type detectors and JCR repositories would be defined below -->
</configuration>
The configuration can then be loaded from Java like this:
JcrConfiguration config = new JcrConfiguration().loadFrom("/configRepository.xml");