+ + " from URI " + uri);
+ // do not perform further initialization since we assume that the
+ // remote repository has been properly configured
+ return;
+ }
+
+ // local repository
+ if (inMemory && homeDirectory.exists()) {
+ FileUtils.deleteDirectory(homeDirectory);
+ log.warn("Deleted Jackrabbit home directory " + homeDirectory);
+ }
+
+ RepositoryConfig config;
+ Properties vars = getConfigurationProperties();
+ InputStream in = configuration.getInputStream();
+ try {
+ vars.put(RepositoryConfigurationParser.REPOSITORY_HOME_VARIABLE,
+ homeDirectory.getCanonicalPath());
+ config = RepositoryConfig.create(new InputSource(in), vars);
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot read configuration", e);
+ } finally {
+ IOUtils.closeQuietly(in);
+ }
+
+ if (inMemory)
+ repository = new TransientRepository(config);
+ else
+ repository = RepositoryImpl.create(config);
+
+ if (cndFiles != null && cndFiles.size() > 0)
+ importNodeTypeDefinitions(repository);
+
+ log.info("Initialized Jackrabbit repository " + repository + " in "
+ + homeDirectory + " with config " + configuration);
+ }
+
+ protected Properties getConfigurationProperties() {
+ InputStream propsIn = null;
+ Properties vars;
+ try {
+ vars = new Properties();
+ if (variables != null) {
+ propsIn = variables.getInputStream();
+ vars.load(propsIn);
+ }
+ // resolve system properties
+ for (Object key : vars.keySet()) {
+ // TODO: implement a smarter mechanism to resolve nested ${}
+ String newValue = SystemPropertyUtils.resolvePlaceholders(vars
+ .getProperty(key.toString()));
+ vars.put(key, newValue);