+ /**
+ * @deprecated explicitly declare {@link #dispose()} as destroy-method
+ * instead.
+ */
+ public void destroy() throws Exception {
+ if (!alreadyDisposed) {
+ log.warn("## If not already done,"
+ + " declare destroy-method=\"dispose\".");
+ disposeImpl();
+ }
+ }
+
+ public void dispose() throws Exception {
+ disposeImpl();
+ alreadyDisposed = true;
+ }
+
+ protected void disposeImpl() throws Exception {
+ if (repository != null) {
+ if (repository instanceof JackrabbitRepository)
+ ((JackrabbitRepository) repository).shutdown();
+ else if (repository instanceof RepositoryImpl)
+ ((RepositoryImpl) repository).shutdown();
+ else if (repository instanceof TransientRepository)
+ ((TransientRepository) repository).shutdown();
+ }
+
+ if (inMemory)
+ if (homeDirectory.exists()) {
+ FileUtils.deleteDirectory(homeDirectory);
+ if (log.isDebugEnabled())
+ log.debug("Deleted Jackrabbit home directory "
+ + homeDirectory);
+ }
+
+ if (uri != null && !uri.trim().equals(""))
+ log.info("Destroyed Jackrabbit repository with uri " + uri);
+ else
+ log.info("Destroyed 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);
+ }
+ // override with system properties
+ vars.putAll(System.getProperties());
+ } catch (IOException e) {
+ throw new ArgeoException("Cannot read configuration properties", e);
+ } finally {
+ IOUtils.closeQuietly(propsIn);
+ }
+ return vars;
+ }
+