@Override public ConfigurationItem create(String id, Object model, ConfigurationContext context) throws Exception { // Obtain the XmlMarshaller for the Model XmlMarshaller marshaller = this.obtainMarshaller(model.getClass()); // Create the writer to output contents ByteArrayOutputStream marshalledModel = new ByteArrayOutputStream(); final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(marshalledModel)); // Create the XML Output XmlOutput xmlOutput = new XmlOutput() { public void write(String xmlSnippet) throws IOException { writer.write(xmlSnippet); } }; // Store the Model marshaller.marshall(model, xmlOutput); // Ensure byte array contains all marshalled details of model writer.flush(); // Create the configuration with the marshalled model return context.createConfigurationItem( id, new ByteArrayInputStream(marshalledModel.toByteArray())); }