+ log.info("Destroyed Jackrabbit repository in " + duration
+ + " s, home: " + getHomeDirectory() + ", config "
+ + configuration);
+ }
+
+ /**
+ * @deprecated explicitly declare {@link #dispose()} as destroy-method
+ * instead.
+ */
+ public void destroy() throws Exception {
+ log.error("## Declare destroy-method=\"dispose\". in the Jackrabbit container bean");
+ }
+
+ /** @deprecated explicitly declare {@link #init()} as init-method instead. */
+ public void afterPropertiesSet() throws Exception {
+ log.error("## Declare init-method=\"init\". in the Jackrabbit container bean");
+ }
+
+ 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());
+
+ if (log.isTraceEnabled()) {
+ log.trace("Jackrabbit config variables:");
+ for (Object key : new TreeSet<Object>(vars.keySet()))
+ log.trace(key + "=" + vars.getProperty(key.toString()));
+ }
+
+ } catch (IOException e) {
+ throw new ArgeoException("Cannot read configuration properties", e);
+ } finally {
+ IOUtils.closeQuietly(propsIn);
+ }
+ return vars;
+ }
+
+ /**
+ * Import declared node type definitions, trying to update them if they have
+ * changed. In case of failures an error will be logged but no exception
+ * will be thrown.
+ */
+ protected void importNodeTypeDefinitions(final Repository repository) {
+ Runnable action = new Runnable() {
+ public void run() {
+ Reader reader = null;
+ Session session = null;
+ try {
+ session = repository.login();
+ processNewSession(session);
+ // Load cnds as resources
+ for (String resUrl : cndFiles) {
+ Resource res = resourceLoader.getResource(resUrl);
+ byte[] arr = IOUtils.toByteArray(res.getInputStream());
+ reader = new InputStreamReader(
+ new ByteArrayInputStream(arr));
+ CndImporter.registerNodeTypes(reader, session, true);
+ }
+ session.save();
+ } catch (Exception e) {
+ log.error(
+ "Cannot import node type definitions " + cndFiles,
+ e);
+ JcrUtils.discardQuietly(session);
+ } finally {
+ IOUtils.closeQuietly(reader);
+ JcrUtils.logoutQuietly(session);
+ }
+ }
+ };
+
+ if (systemExecutor != null)
+ systemExecutor.execute(action);
+ else
+ action.run();