Source:
public void handleRequest( CarteRequest request ) throws IOException { final List<IThinServiceInformation> serviceInformation; try { serviceInformation = client.getServiceInformation(); } catch ( SQLException e ) { String msg = "Failed to retrieve service info"; logError( msg, e ); request.respond( 500 ).withMessage( msg ); return; } request.respond( 200 ) .with( "text/xml; charset=utf-8", new WriterResponse() { private void writeServiceXml( PrintWriter writer, IThinServiceInformation thinServiceInformation ) throws IOException { writer.println(XMLHandler.openTag(XML_TAG_SERVICE)); writer.println(XMLHandler.addTagValue("name", thinServiceInformation.getName())); writer.println(XMLHandler.addTagValue("streaming", thinServiceInformation.isStreaming())); writer.println(thinServiceInformation.getServiceFields().getMetaXML()); writer.println(XMLHandler.closeTag(XML_TAG_SERVICE)); } @Override public void write( PrintWriter writer ) throws IOException { writer.println( XMLHandler.getXMLHeader() ); writer.println( XMLHandler.openTag( XML_TAG_SERVICES ) ); for ( IThinServiceInformation thinServiceInformation : serviceInformation ) { String streamingParam = request.getParameter( "streaming" ); if (streamingParam == null) { writeServiceXml( writer, thinServiceInformation ); } else { boolean streaming = Boolean.parseBoolean( request.getParameter("streaming") ); if ((streaming && thinServiceInformation.isStreaming()) || (!streaming && !thinServiceInformation.isStreaming())) { writeServiceXml( writer, thinServiceInformation ); } } } writer.println( XMLHandler.closeTag( XML_TAG_SERVICES ) ); } } ); }

Target:
public void handleRequest( CarteRequest request ) throws IOException { final List<IThinServiceInformation> serviceInformation; try { serviceInformation = client.getServiceInformation(); } catch ( SQLException e ) { String msg = "Failed to retrieve service info"; logError( msg, e ); request.respond( 500 ).withMessage( msg ); return; } request.respond( 200 ) .with( "text/xml; charset=utf-8", new WriterResponse() { private void writeServiceXml( PrintWriter writer, IThinServiceInformation thinServiceInformation ) throws IOException { writer.println( XMLHandler.openTag( XML_TAG_SERVICE ) ); writer.println( XMLHandler.addTagValue( "name", thinServiceInformation.getName() ) ); writer.println( XMLHandler.addTagValue( "streaming", thinServiceInformation.isStreaming() ) ); writer.println( thinServiceInformation.getServiceFields().getMetaXML() ); writer.println( XMLHandler.closeTag( XML_TAG_SERVICE ) ); } @Override public void write( PrintWriter writer ) throws IOException { writer.println( XMLHandler.getXMLHeader() ); writer.println( XMLHandler.openTag( XML_TAG_SERVICES ) ); for ( IThinServiceInformation thinServiceInformation : serviceInformation ) { String streamingParam = request.getParameter( "streaming" ); if ( streamingParam == null ) { writeServiceXml( writer, thinServiceInformation ); } else { boolean streaming = Boolean.parseBoolean( request.getParameter( "streaming" ) ); if ( streaming == thinServiceInformation.isStreaming() ) { writeServiceXml( writer, thinServiceInformation ); } } } writer.println( XMLHandler.closeTag( XML_TAG_SERVICES ) ); } } ); }