此内容没有您所选择的语言版本。
17.4. Loading Your Configuration from a Repository
The first step is to create and configure the RepositorySource instance that we'll use to access the repository where the configuration is stored. Then, create a
JcrConfiguration
instance and load from this source:
RepositorySource configSource = ... JcrConfiguration config = new JcrConfiguration(); configuration.loadFrom(configSource);
RepositorySource configSource = ...
JcrConfiguration config = new JcrConfiguration();
configuration.loadFrom(configSource);
The
loadFrom(...)
method can be called any number of times, but each time it is called it completely wipes out any current notion of the configuration and replaces it with the configuration found in the file.
There is an optional second parameter that defines the name of the workspace in the supplied source where the configuration content can be found. It is not needed if the workspace is the source's default workspace. There is an optional third parameter that defines the Path within the configuration repository identifying the parent node of the various configuration nodes. If not specified, it assumes "/". This makes it possible for the configuration content to be located at a different location in the hierarchical structure. (This is not often required, but it is very useful if you ModeShape configuration file is embedded within another XML file.)
Once the
JcrConfiguration
has been loaded from a RepositorySource , the JcrConfiguration
instance can be used to modify the configuration and then save those changes back to the repository. This technique can be used to place a configuration into a repository (such as a database) for the first time:
Now you can load this configuration in multiple processes, using the approach mentioned above.
Note
This is an advanced way of defining your configuration, so this is recommended only for those that are already very comfortable with ModeShape and its lower-level graph API and connector API.