/* * Generated by Savara. */ package %PACKAGE%; import java.io.StringWriter; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.namespace.QName; import org.switchyard.common.xml.QNameUtil; import org.switchyard.transform.Transformer; public class %CLASSNAME% extends org.switchyard.transform.BaseTransformer<%FAULTCLASS%,String> implements Transformer<%FAULTCLASS%,String> { public QName getTo() { return (QName.valueOf("%FAULTQNAME%")); } public String transform(%FAULTCLASS% type) { Marshaller marshaller; JAXBContext _jaxbContext; try { _jaxbContext = JAXBContext.newInstance("%FAULTTYPEPACKAGE%"); } catch (JAXBException e) { throw new RuntimeException("Failed to create JAXBContext for '" + getFrom() + "'.", e); } try { marshaller = _jaxbContext.createMarshaller(); } catch (JAXBException e) { throw new RuntimeException("Failed to create Marshaller for type '" + getFrom() + "'.", e); } try { StringWriter resultWriter = new StringWriter(); Object javaObject = type.getFaultInfo(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(javaObject, resultWriter); return (resultWriter.toString()); } catch (JAXBException e) { throw new RuntimeException("Failed to unmarshall for type '" + getFrom() + "'.", e); } } }