### Question:
XmlCodec { static public void encode(Object in, OutputStream os, boolean format) throws JAXBException { ClassLoader original = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(ClassFinder.class_loader()); Marshaller marshaller = context().createMarshaller(); if( format ) { marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, java.lang.Boolean.TRUE); } marshaller.marshal(in, new OutputStreamWriter(os)); } finally { Thread.currentThread().setContextClassLoader(original); } }  static T decode(Class<T> clazz, URL url); static T decode(Class<T> clazz, URL url, Properties props); static T decode(Class<T> clazz, InputStream is); static T decode(Class<T> clazz, InputStream is, Properties props); static T decode(Class<T> clazz, InputStream is, Properties props, ValidationEventHandler validationHandler); static void encode(Object in, OutputStream os, boolean format); volatile static JAXBContext _context; }### Answer:
@Test public void marshalling() throws Exception { BrokerDTO broker = new BrokerDTO(); VirtualHostDTO host = new VirtualHostDTO(); host.id = "vh-local"; host.host_names.add("localhost"); host.host_names.add("example.com"); broker.virtual_hosts.add(host); AcceptingConnectorDTO connector = new AcceptingConnectorDTO(); connector.id = "port-61616"; connector.bind = "tcp: broker.connectors.add(connector); XmlCodec.encode(broker, System.out, true); }