private void build(PrintWriter xml, String id, int port) throws Exception {
                xml.println("<container version=\"1.0\" id=\"" + id + "\">");

                if (port > 0) {
                    xml.println("<http>");
                    xml.println("<server id=\"http\" port=\"" + port + "\" />");
                    xml.println("</http>");
                }

                for (ComponentItem<? extends RequestHandler> entry : handlers) {
                    xml.println("<handler id=\"" + entry.component.getName() + "\">");
                    xml.println("<binding>" + entry.id + "</binding>");
                    xml.println("</handler>");
                }

                for (ComponentItem<? extends ClientProvider> entry : clients) {
                    xml.println("<client id=\"" + entry.component.getName() + "\">");
                    xml.println("<binding>" + entry.id + "</binding>");
                    xml.println("</client>");
                }

                for (ComponentItem<? extends ServerProvider> server : servers) {
                    generateComponent(xml, server, "server");
                }

                // container scoped configs
                for (ConfigInstance config : configs) {
                    generateConfig(xml, config);
                }

                for (ComponentItem<?> component : components) {
                    generateComponent(xml, component, "component");
                }

                if (!docprocs.isEmpty()) {
                    xml.println("<document-processing>");
                    for (Map.Entry<String, List<ComponentItem<? extends DocumentProcessor>>> entry : docprocs.entrySet()) {
                        xml.println("<chain id=\"" + entry.getKey() + "\">");
                        for (ComponentItem<? extends DocumentProcessor> docproc : entry.getValue()) {
                            generateComponent(xml, docproc, "documentprocessor");
                        }
                        xml.println("</chain>");
                    }
                    xml.println("</document-processing>");
                }

                if (enableSearch || !searchers.isEmpty() || !renderers.isEmpty()) {
                    xml.println("<search>");
                    for (Map.Entry<String, List<ComponentItem<? extends Searcher>>> entry : searchers.entrySet()) {
                        xml.println("<chain id=\"" + entry.getKey() + "\">");
                        for (ComponentItem<? extends Searcher> searcher : entry.getValue()) {
                            generateComponent(xml, searcher, "searcher");
                        }
                        xml.println("</chain>");
                    }
                    for (ComponentItem<? extends Renderer> renderer : renderers) {
                        generateComponent(xml, renderer, "renderer");
                    }
                    xml.println("</search>");
                }

                xml.println("<accesslog type=\"disabled\" />");
                xml.println("</container>");
            }
@param config add this config to the application
@return builder
application/src/main/java/com/yahoo/application/Application.java