private String reIndent(int depth, String initialString) { StringReader stringReader = new StringReader(initialString); BufferedReader reader = new BufferedReader(stringReader); StringBuilder builder = new StringBuilder(); String line; try { while ((line = reader.readLine()) != null) { if (builder.length() != 0) { builder.append(Misc.LINE_SEPARATOR); } builder.append(getIndent(depth)).append(line); } } catch (IOException e) { Misc.unreachableStatement(); } finally { Misc.close(reader); Misc.close(stringReader); } return builder.toString(); } /**
result.append(getIndent(indentDepth) + "<environment-factory>" + Misc.LINE_SEPARATOR); .append(getIndent(indentDepth)).append("</environment-factory>" + Misc.LINE_SEPARATOR + Misc.LINE_SEPARATOR); .append(getIndent(indentDepth)).append("<environment>" + Misc.LINE_SEPARATOR); indentDepth++; .append(getIndent(indentDepth)).append("<!-- DbJournal cannot be shared by several environments." + Misc.LINE_SEPARATOR) .append(getIndent(indentDepth)).append("It contains a session cache that needs to be recreated for each environment -->") .append(Misc.LINE_SEPARATOR) .append(getIndent(indentDepth)).append("<chainer name='").append(Recorder.DEFAULT_KEY + "'>" + Misc.LINE_SEPARATOR) .append(reIndent(indentDepth + 1, recorderXml)).append(Misc.LINE_SEPARATOR) .append(getIndent(indentDepth + 1)).append("<ref object='" + JOURNAL_DEFAULT_KEY + "' />").append(Misc.LINE_SEPARATOR) .append(getIndent(indentDepth)).append("</chainer>" + Misc.LINE_SEPARATOR); .append(getIndent(indentDepth)).append("<chainer name='").append(Archiver.DEFAULT_KEY + "'>" + Misc.LINE_SEPARATOR) .append(reIndent(indentDepth + 1 , archiverXml)).append(Misc.LINE_SEPARATOR) .append(getIndent(indentDepth + 1)).append("<ref object='" + HISTORY_DEFAULT_KEY + "' />").append(Misc.LINE_SEPARATOR) .append(getIndent(indentDepth)).append("</chainer>" + Misc.LINE_SEPARATOR); .append(getIndent(indentDepth)).append("<!-- Query Api has an object reference to the journal,").append(Misc.LINE_SEPARATOR) .append(getIndent(indentDepth)).append("so it cannot be shared by multiple environments -->").append(Misc.LINE_SEPARATOR) .append(getIndent(indentDepth)).append("<queryApi name='" + Querier.DEFAULT_KEY + "'>").append(Misc.LINE_SEPARATOR) .append(getIndent(indentDepth + 1)).append("<ref object='" + JOURNAL_DEFAULT_KEY + "' />").append(Misc.LINE_SEPARATOR) .append(getIndent(indentDepth + 1)).append("<ref object='" + HISTORY_DEFAULT_KEY + "' />").append(Misc.LINE_SEPARATOR) .append(getIndent(indentDepth)).append("</queryApi>").append(Misc.LINE_SEPARATOR); .append(getIndent(indentDepth)).append("<!-- DbRepository cannot be shared " + "by several environments.").append(Misc.LINE_SEPARATOR)