001 package biz.hammurapi.jms; 002 003 import java.io.StringWriter; 004 005 import javax.xml.transform.Result; 006 007 import org.apache.xmlbeans.XmlObject; 008 009 public abstract class XmlBeansMessageProcessor extends StylingXmlMessageProcessor { 010 011 protected Result createResult() { 012 return new XmlBeansSaxResult(); 013 } 014 015 protected String processResult(Result result) { 016 try { 017 XmlObject ret = processObject(((XmlBeansSaxResult) result).getObject()); 018 if (ret==null) { 019 return null; 020 } 021 022 StringWriter sw = new StringWriter(); 023 ret.save(sw); 024 sw.close(); 025 return sw.toString(); 026 } catch (Exception e) { 027 throw new MessageProcessingException(e); 028 } 029 } 030 031 protected abstract XmlObject processObject(XmlObject obj); 032 033 }