public String serializeConfigBean(ConfigBeanProxy configBean) {
if (configBean == null) return null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance();
XMLStreamWriter writer = null;
IndentingXMLStreamWriter indentingXMLStreamWriter = null;
String s = null;
try {
writer = xmlFactory.createXMLStreamWriter(new BufferedOutputStream(bos));
indentingXMLStreamWriter = new IndentingXMLStreamWriter(writer);
Dom configBeanDom = Dom.unwrap(configBean);
configBeanDom.writeToXml();
configBeanDom.writeTo(configBeanDom.model.getTagName(), indentingXMLStreamWriter);
indentingXMLStreamWriter.flush();
s = bos.toString();
} catch (XMLStreamException e) {
LOG.log(Level.FINE, "Cannot serialize the configbean: " + configBean.toString(), e);
return null;
} finally {
try {
if (bos != null)
bos.close();
if (writer != null)
writer.close();
if (indentingXMLStreamWriter != null)
indentingXMLStreamWriter.close();
} catch (IOException e) {
LOG.log(Level.FINE, "Cannot serialize the configbean: " + configBean.toString(), e);
} catch (XMLStreamException e) {
LOG.log(Level.FINE, "Cannot serialize the configbean: " + configBean.toString(), e);
}