cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1044907 [1/2] - in /cxf/trunk/rt/transports: http-osgi/ http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/ http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/ http/src/main/java/org/apache/cxf/transport/http/ http/src/main...
Date Sun, 12 Dec 2010 20:30:17 GMT
Author: cschneider
Date: Sun Dec 12 20:30:16 2010
New Revision: 1044907

URL: http://svn.apache.org/viewvc?rev=1044907&view=rev
Log:
CXF-3160 Extracting service list generation from ServletController and OsgiServletController. Moving some more code out of http-osgi

Added:
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListWriter.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/UnformattedServiceListWriter.java
Modified:
    cxf/trunk/rt/transports/http-osgi/   (props changed)
    cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java
    cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java
    cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
    cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistry.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractServletController.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
    cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/servlet/ServletControllerTest.java

Propchange: cxf/trunk/rt/transports/http-osgi/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Dec 12 20:30:16 2010
@@ -8,3 +8,7 @@ eclipse-classes
 .project
 .wtpmodules
 
+
+.springBeans
+
+.springWebflow

Modified: cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java?rev=1044907&r1=1044906&r2=1044907&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java (original)
+++ cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java Sun Dec 12 20:30:16 2010
@@ -58,8 +58,4 @@ public class OsgiDestination extends Abs
         return LOG;
     }
 
-    protected Bus getBus() {
-        return bus;
-    }
-
 }

Modified: cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java?rev=1044907&r1=1044906&r2=1044907&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java (original)
+++ cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java Sun Dec 12 20:30:16 2010
@@ -20,45 +20,42 @@ package org.apache.cxf.transport.http_os
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.cxf.message.ExchangeImpl;
-import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.transport.http.DestinationRegistry;
 import org.apache.cxf.transport.servlet.AbstractHTTPServlet;
+import org.apache.cxf.transport.servlet.servicelist.ServiceListGeneratorServlet;
 
 public class OsgiServlet extends AbstractHTTPServlet {
     
-    private DestinationRegistry transport;
+    private DestinationRegistry destinationRegistry;
     private OsgiServletController controller;
+    private HttpServlet serviceListGenerator;
     
-    public OsgiServlet(DestinationRegistry transport) {
-        this.transport = transport;
+    public OsgiServlet(DestinationRegistry destinationRegistry) {
+        this(destinationRegistry, new ServiceListGeneratorServlet(destinationRegistry, null));
+    }
+    
+    public OsgiServlet(DestinationRegistry destinationRegistry, HttpServlet serviceListGenerator) {
+        this.destinationRegistry = destinationRegistry;
+        this.serviceListGenerator = serviceListGenerator;
     }
 
     public void init(ServletConfig servletConfig) throws ServletException {
         super.init(servletConfig);
-        controller = new OsgiServletController(this.getTransport(), this.getServletConfig());
+        controller = new OsgiServletController(servletConfig,
+                                               this.destinationRegistry, 
+                                               serviceListGenerator);
     }
     
     @Override
     public void destroy() {
     }
 
-    public DestinationRegistry getTransport() {
-        return transport;
-    }
-
     public void invoke(HttpServletRequest request, HttpServletResponse res) throws ServletException {
         controller.invoke(request, res);
     }
-    
-    protected MessageImpl createInMessage() {
-        return new MessageImpl();
-    }
 
-    protected ExchangeImpl createExchange() {
-        return new ExchangeImpl();
-    }
 }

Modified: cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java?rev=1044907&r1=1044906&r2=1044907&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java (original)
+++ cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java Sun Dec 12 20:30:16 2010
@@ -19,15 +19,12 @@
 package org.apache.cxf.transport.http_osgi;
 
 import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
 import java.util.Set;
 import java.util.logging.Logger;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -36,7 +33,6 @@ import org.apache.cxf.common.logging.Log
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.resource.ResourceManager;
 import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 import org.apache.cxf.transport.http.DestinationRegistry;
 import org.apache.cxf.transport.servlet.AbstractServletController;
@@ -46,11 +42,11 @@ import org.apache.cxf.wsdl.http.AddressT
 
 public class OsgiServletController extends AbstractServletController {
     private static final Logger LOG = LogUtils.getL7dLogger(OsgiServlet.class);
-      
-    private DestinationRegistry destinationRegistry;
-    public OsgiServletController(DestinationRegistry destinationRegistry, ServletConfig config) {
-        super(config);
-        this.destinationRegistry = destinationRegistry;
+
+    public OsgiServletController(ServletConfig config, 
+                                 DestinationRegistry destinationRegistry, 
+                                 HttpServlet serviceListGenerator) {
+        super(config, destinationRegistry, serviceListGenerator);
     }
 
     private synchronized void updateDests(HttpServletRequest request) {
@@ -59,7 +55,6 @@ public class OsgiServletController exten
         }
         String base = forcedBaseAddress == null ? getBaseURL(request) : forcedBaseAddress;
 
-               
         Set<String> paths = destinationRegistry.getDestinationsPaths();
         for (String path : paths) {
             AbstractHTTPDestination d2 = destinationRegistry.getDestinationForPath(path);
@@ -84,7 +79,7 @@ public class OsgiServletController exten
                     || StringUtils.isEmpty(request.getPathInfo())
                     || "/".equals(request.getPathInfo())) {
                     updateDests(request);
-                    generateServiceList(request, res);
+                    serviceListGenerator.service(request, res);
                 } else {
                     d = destinationRegistry.checkRestfulRequest(address);
                     if (d == null || d.getMessageObserver() == null) {
@@ -98,7 +93,7 @@ public class OsgiServletController exten
                 }
             } else {
                 EndpointInfo ei = d.getEndpointInfo();
-                Bus bus = ((OsgiDestination)d).getBus();
+                Bus bus = d.getBus();
                 ClassLoader orig = Thread.currentThread().getContextClassLoader();
                 try {
                     ResourceManager manager = bus.getExtension(ResourceManager.class);
@@ -109,9 +104,9 @@ public class OsgiServletController exten
                             Thread.currentThread().setContextClassLoader(loader);
                         }
                     }
-                    Iterable<QueryHandler> queryHandlers = bus.getExtension(QueryHandlerRegistry.class)
-                        .getHandlers();
-                    if (!StringUtils.isEmpty(request.getQueryString()) && queryHandlers != null) {
+                    QueryHandlerRegistry queryHandlerRegistry = bus.getExtension(QueryHandlerRegistry.class);
+
+                    if (!StringUtils.isEmpty(request.getQueryString()) && queryHandlerRegistry != null) {
                         
                         // update the EndPoint Address with request url
                         if ("GET".equals(request.getMethod())) {
@@ -122,7 +117,8 @@ public class OsgiServletController exten
                         String baseUri = request.getRequestURL().toString()
                             + "?" + request.getQueryString();
 
-                        QueryHandler selectedHandler = findQueryHandler(queryHandlers, ei, ctxUri, baseUri);
+                        QueryHandler selectedHandler = 
+                            findQueryHandler(queryHandlerRegistry, ei, ctxUri, baseUri);
                         
                         if (selectedHandler != null) {
                             respondUsingQueryHandler(selectedHandler, res, ei, ctxUri, baseUri);
@@ -142,136 +138,5 @@ public class OsgiServletController exten
         }
     }
 
-    private QueryHandler findQueryHandler(Iterable<QueryHandler> handlers, EndpointInfo ei, String ctxUri,
-                                          String baseUri) {
-        for (QueryHandler qh : handlers) {
-            if (qh.isRecognizedQuery(baseUri, ctxUri, ei)) {
-                return qh;
-            }
-        }
-        return null;
-    }
-
-    private void respondUsingQueryHandler(QueryHandler selectedHandler, HttpServletResponse res,
-                                          EndpointInfo ei, String ctxUri, String baseUri) throws IOException,
-        ServletException {
-        res.setContentType(selectedHandler.getResponseContentType(baseUri, ctxUri));
-        OutputStream out = res.getOutputStream();
-        try {
-            selectedHandler.writeResponse(baseUri, ctxUri, ei, out);
-            out.flush();
-        } catch (Exception e) {
-            LOG.warning(selectedHandler.getClass().getName()
-                + " Exception caught writing response: "
-                + e.getMessage());
-            throw new ServletException(e);
-        }
-    }
-
-    protected void generateServiceList(HttpServletRequest request, HttpServletResponse response)
-        throws IOException {        
-        response.setContentType("text/html; charset=UTF-8");        
-        
-        response.getWriter().write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" " 
-                + "\"http://www.w3.org/TR/html4/loose.dtd\">");
-        response.getWriter().write("<HTML><HEAD>");
-        if (serviceListStyleSheet != null) {
-            response.getWriter().write(
-                    "<LINK type=\"text/css\" rel=\"stylesheet\" href=\"" 
-                    + request.getContextPath() + "/" + serviceListStyleSheet + "\">");
-        } else {
-            response.getWriter().write(
-                                       "<LINK type=\"text/css\" rel=\"stylesheet\" href=\"" 
-                                       + request.getRequestURI() + "/?stylesheet=1\">");            
-        }
-        response.getWriter().write("<meta http-equiv=content-type content=\"text/html; charset=UTF-8\">");
-        response.getWriter().write("<title>CXF - Service list</title>");
-        response.getWriter().write("</head><body>");
-        
-        Collection<AbstractHTTPDestination> destinations = destinationRegistry.getDestinations();
-            
-        if (destinations.size() > 0) {
-            writeSOAPEndpoints(response, destinations);
-            writeRESTfulEndpoints(response, destinations);
-        } else {
-            response.getWriter().write("<span class=\"heading\">No services have been found.</span>");
-        }
-        
-        response.getWriter().write("</body></html>");
-    }
-
-    private void writeSOAPEndpoints(HttpServletResponse response, 
-                                    Collection<AbstractHTTPDestination> destinations)
-        throws IOException {
-        response.getWriter().write("<span class=\"heading\">Available SOAP services:</span><br/>");
-        response.getWriter().write("<table " + (serviceListStyleSheet == null
-                ? "cellpadding=\"1\" cellspacing=\"1\" border=\"1\" width=\"100%\"" : "") + ">");
-        for (AbstractHTTPDestination sd : destinations) {
-            if (null != sd.getEndpointInfo().getName() 
-                && null != sd.getEndpointInfo().getInterface()) {
-                response.getWriter().write("<tr><td>");
-                response.getWriter().write("<span class=\"porttypename\">"
-                        + sd.getEndpointInfo().getInterface().getName().getLocalPart()
-                        + "</span>");
-                response.getWriter().write("<ul>");
-                for (OperationInfo oi : sd.getEndpointInfo().getInterface().getOperations()) {
-                    response.getWriter().write("<li>" + oi.getName().getLocalPart() + "</li>");
-                }
-                response.getWriter().write("</ul>");
-                response.getWriter().write("</td><td>");
-                String address = sd.getEndpointInfo().getAddress();
-                response.getWriter().write("<span class=\"field\">Endpoint address:</span> "
-                        + "<span class=\"value\">" + address + "</span>");
-                response.getWriter().write("<br/><span class=\"field\">WSDL :</span> "
-                        + "<a href=\"" + address + "?wsdl\">"
-                        + sd.getEndpointInfo().getService().getName() + "</a>");
-                response.getWriter().write("<br/><span class=\"field\">Target namespace:</span> "
-                        + "<span class=\"value\">" 
-                        + sd.getEndpointInfo().getService().getTargetNamespace() + "</span>");
-                response.getWriter().write("</td></tr>");
-            }    
-        }
-        response.getWriter().write("</table><br/><br/>");
-    }
-    
-    
-    private void writeRESTfulEndpoints(HttpServletResponse response, 
-                                       Collection<AbstractHTTPDestination> destinations)
-        throws IOException {
-        
-        List<AbstractHTTPDestination> restfulDests = new ArrayList<AbstractHTTPDestination>();
-        for (AbstractHTTPDestination sd : destinations) {
-            // use some more reasonable check - though this one seems to be the only option at the moment
-            if (null == sd.getEndpointInfo().getInterface()) {
-                restfulDests.add(sd);
-            }
-        }
-        if (restfulDests.size() == 0) {
-            return;
-        }
-        
-        response.getWriter().write("<span class=\"heading\">Available RESTful services:</span><br/>");
-        response.getWriter().write("<table " + (serviceListStyleSheet == null
-                ? "cellpadding=\"1\" cellspacing=\"1\" border=\"1\" width=\"100%\"" : "") + ">");
-        for (AbstractHTTPDestination sd : destinations) {
-            if (null == sd.getEndpointInfo().getInterface()) {
-                response.getWriter().write("<tr><td>");
-                String address = sd.getEndpointInfo().getAddress();
-                response.getWriter().write("<span class=\"field\">Endpoint address:</span> "
-                        + "<span class=\"value\">" + address + "</span>");
-                response.getWriter().write("<br/><span class=\"field\">WADL :</span> "
-                        + "<a href=\"" + address + "?_wadl&_type=xml\">"
-                        + address + "?_wadl&type=xml" + "</a>");
-                response.getWriter().write("</td></tr>");
-            }    
-        }
-        response.getWriter().write("</table>");
-    }
-    
-    protected void generateNotFound(HttpServletRequest request, HttpServletResponse res) throws IOException {
-        res.setStatus(404);
-        res.setContentType("text/html");
-        res.getWriter().write("<html><body>No service was found.</body></html>");
-    }
 
 }

Modified: cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java?rev=1044907&r1=1044906&r2=1044907&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java (original)
+++ cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java Sun Dec 12 20:30:16 2010
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.transport.http_osgi;
 
-import java.io.InputStream;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.List;
@@ -27,29 +26,25 @@ import java.util.Set;
 import java.util.TreeSet;
 
 import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
-import javax.servlet.ServletInputStream;
 import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.message.ExchangeImpl;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageImpl;
-import org.apache.cxf.security.SecurityContext;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.InterfaceInfo;
 import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.AbstractDestination;
 import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 import org.apache.cxf.transport.http.DestinationRegistry;
-import org.apache.cxf.transport.http.HTTPSession;
 import org.apache.cxf.transports.http.QueryHandler;
 import org.apache.cxf.transports.http.QueryHandlerRegistry;
-import org.apache.cxf.wsdl.EndpointReferenceUtils;
 import org.apache.cxf.wsdl.http.AddressType;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
@@ -57,12 +52,29 @@ import org.easymock.classextension.IMock
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 
 public class OsgiServletTest extends Assert {
 
+    private final class TestOsgiServletController extends OsgiServletController {
+        private boolean invokeDestinationCalled;
+
+
+        private TestOsgiServletController(ServletConfig config, 
+                                          DestinationRegistry destinationRegistry,
+                                          HttpServlet serviceListGenerator) {
+            super(config, destinationRegistry, serviceListGenerator);
+        }
+
+        @Override
+        public void invokeDestination(HttpServletRequest req,
+                                      HttpServletResponse res,
+                                      AbstractHTTPDestination d) throws ServletException {
+            invokeDestinationCalled = true;
+        }
+    }
+
     private static final String ADDRESS = "http://bar/snafu";
     private static final String ROOT = "http://localhost:8080/";
     private static final QName QNAME = new QName(ADDRESS, "foobar");
@@ -70,25 +82,20 @@ public class OsgiServletTest extends Ass
     private static final String URI = "/cxf" + PATH;
     private static final String SERVICES = "/cxf/services";
     private static final String QUERY = "wsdl";
-    private static final String VERB = "POST";
     private static final String TEXT = "text/html";
     private static final String TEXT_LIST = "text/html; charset=UTF-8";
     private static final String XML = "text/xml";
-    private static final String ENCODING = "UTF-8";
     private static final String NO_SERVICE = 
         "<html><body>No service was found.</body></html>";
     private IMocksControl control; 
     private Bus bus;
     private DestinationRegistry registry;
-    private OsgiDestination destination;
+    private AbstractHTTPDestination destination;
     private ServletConfig config;
-    private ServletContext context;
     private HttpServletRequest request;
     private HttpServletResponse response;
-    private MessageImpl message;
     private MessageObserver observer;
     private AddressType extensor;
-    private ExchangeImpl exchange;
     private EndpointInfo endpoint;
     private Set<String> paths;
 
@@ -97,13 +104,10 @@ public class OsgiServletTest extends Ass
         control = EasyMock.createNiceControl();
         bus = control.createMock(Bus.class);
         registry = control.createMock(DestinationRegistry.class);
-        destination = control.createMock(OsgiDestination.class);
-        context = control.createMock(ServletContext.class);
+        destination = control.createMock(AbstractHTTPDestination.class);
         config = control.createMock(ServletConfig.class);
         request = control.createMock(HttpServletRequest.class);
         response = control.createMock(HttpServletResponse.class);
-        message = control.createMock(MessageImpl.class);
-        exchange = control.createMock(ExchangeImpl.class);
         observer = control.createMock(MessageObserver.class);
         extensor = control.createMock(AddressType.class);
         endpoint = new EndpointInfo();
@@ -121,14 +125,9 @@ public class OsgiServletTest extends Ass
         bus = null;
         registry = null;
         destination = null;
-        context = null;
         config = null;
         request = null;
         response = null;
-        message = null;
-        exchange = null;
-        destination = null;
-        exchange = null;
         observer = null;
         extensor = null;
     }
@@ -139,27 +138,24 @@ public class OsgiServletTest extends Ass
         setUpResponse(404, TEXT, NO_SERVICE);
 
         control.replay();
-
-        OsgiServlet servlet = setUpServlet();
-
+        OsgiServlet servlet = new OsgiServlet(registry);
+        servlet.init(config);
         servlet.invoke(request, response);
-
         control.verify();
     }
 
     @Test
     public void testInvokeGetServices() throws Exception {
         setUpRequest(SERVICES, null, 1);
-        setUpResponse(0, TEXT_LIST, 
-                      "<span class=\"field\">Endpoint address:</span> "
-                      + "<span class=\"value\">" + ADDRESS + "</span>");
 
+        HttpServlet serviceListGenerator = control.createMock(HttpServlet.class);
+        serviceListGenerator.service(EasyMock.isA(ServletRequest.class), EasyMock.isA(ServletResponse.class));
+        EasyMock.expectLastCall();
+        
         control.replay();
-
-        OsgiServlet servlet = setUpServlet();
-
+        OsgiServlet servlet = new OsgiServlet(registry, serviceListGenerator);
+        servlet.init(config);
         servlet.invoke(request, response);
-
         control.verify();
     }
 
@@ -170,11 +166,9 @@ public class OsgiServletTest extends Ass
                       "<span class=\"heading\">No services have been found.</span>");
 
         control.replay();
-
-        OsgiServlet servlet = setUpServlet();
-
+        OsgiServlet servlet = new OsgiServlet(registry);
+        servlet.init(config);
         servlet.invoke(request, response);
-
         control.verify();
     }
 
@@ -184,42 +178,42 @@ public class OsgiServletTest extends Ass
         setUpQuery();
 
         control.replay();
-
-        OsgiServlet servlet = setUpServlet();
-        
+        OsgiServlet servlet = new OsgiServlet(registry);
+        servlet.init(config);
         servlet.invoke(request, response);
-
         control.verify();
     }
 
     @Test
-    @Ignore
     public void testInvokeDestination() throws Exception {
         setUpRequest(URI, PATH, -2);
-        setUpMessage();
-
-        control.replay();
-
-        OsgiServlet servlet = setUpServlet();
+        HttpServlet serviceListGenerator = control.createMock(HttpServlet.class);
         
-        servlet.invoke(request, response);
-
+        control.replay();
+        TestOsgiServletController controller = 
+            new TestOsgiServletController(config, registry, serviceListGenerator);
+        controller.invoke(request, response);
         control.verify();
+        Assert.assertTrue(controller.invokeDestinationCalled);
     }
 
     @Test
-    @Ignore
     public void testInvokeRestful() throws Exception {
         setUpRequest(URI, null, -1);
-        setUpRestful();
-        setUpMessage();
+        paths.add(ADDRESS);
+        // TODO How can the registry first return null then destination for the same path?
+        EasyMock.expect(registry.getDestinationForPath(ADDRESS)).andReturn(null);
+        EasyMock.expect(registry.getDestinationForPath(ADDRESS)).andReturn(destination);
+        EasyMock.expect(registry.checkRestfulRequest(EasyMock.isA(String.class))).andReturn(destination);
+        EasyMock.expect(destination.getMessageObserver()).andReturn(observer);
+        endpoint.addExtensor(extensor);
+        extensor.setLocation(EasyMock.eq(ROOT + "/cxf/Soap" + ADDRESS));
+        EasyMock.expectLastCall();
 
         control.replay();
-
-        OsgiServlet servlet = setUpServlet();
-
+        OsgiServlet servlet = new OsgiServlet(registry);
+        servlet.init(config);
         servlet.invoke(request, response);
-
         control.verify();
     }
 
@@ -249,42 +243,12 @@ public class OsgiServletTest extends Ass
             for (int i = 0; i < destinationCount; i++) {
                 destinations.add(destination);
             }
-            EasyMock.expect(registry.getDestinations()).andReturn(destinations);
+            EasyMock.expect(registry.getDestinations()).andReturn(destinations).anyTimes();
+            EasyMock.expect(registry.getSortedDestinations()).
+                andReturn(destinations.toArray(new AbstractDestination[]{})).anyTimes();
         }
     }
 
-    private void setUpMessage() throws Exception {
-        ServletInputStream sis = control.createMock(ServletInputStream.class);
-        EasyMock.expect(request.getInputStream()).andReturn(sis);
-        message.setContent(EasyMock.eq(InputStream.class), EasyMock.same(sis));
-        EasyMock.expectLastCall();
-        setUpProperty(AbstractHTTPDestination.HTTP_REQUEST, request);
-        setUpProperty(AbstractHTTPDestination.HTTP_RESPONSE, response);
-        setUpProperty(AbstractHTTPDestination.HTTP_CONTEXT, context);
-        setUpProperty(AbstractHTTPDestination.HTTP_CONFIG, config);
-        EasyMock.expect(request.getMethod()).andReturn(VERB);
-        setUpProperty(Message.HTTP_REQUEST_METHOD, VERB);
-        setUpProperty(Message.REQUEST_URI, URI);
-        setUpProperty(Message.QUERY_STRING, QUERY);
-        EasyMock.expect(request.getContentType()).andReturn(XML);
-        setUpProperty(Message.CONTENT_TYPE, XML);
-        EasyMock.expect(request.getHeader("Accept")).andReturn(XML);
-        setUpProperty(Message.ACCEPT_CONTENT_TYPE, XML);
-        destination.getAddress();
-        EasyMock.expectLastCall().andReturn(EndpointReferenceUtils.getEndpointReference(PATH));
-        setUpProperty(Message.BASE_PATH, PATH);
-        message.put(EasyMock.eq(SecurityContext.class), EasyMock.isA(SecurityContext.class));
-        EasyMock.expect(request.getCharacterEncoding()).andReturn(ENCODING);
-        setUpProperty(Message.ENCODING, ENCODING);
-        exchange.setSession(EasyMock.isA(HTTPSession.class));
-        EasyMock.expectLastCall();
-    }
-
-    private void setUpProperty(String name, Object value) {
-        message.put(EasyMock.eq(name), EasyMock.same(value));
-        EasyMock.expectLastCall().andReturn(null).anyTimes();
-    }
-
     private void setUpResponse(int status, 
                                String responseType,
                                String ... responseMsgs) throws Exception {
@@ -328,23 +292,4 @@ public class OsgiServletTest extends Ass
         EasyMock.expectLastCall();
     }
 
-    private void setUpRestful() {
-        paths.add(ADDRESS);
-        EasyMock.expect(registry.getDestinationForPath(ADDRESS)).andReturn(null);
-        EasyMock.expect(registry.getDestinationForPath(ADDRESS)).andReturn(destination).times(2);
-        EasyMock.expect(destination.getMessageObserver()).andReturn(observer);
-        endpoint.addExtensor(extensor);
-        extensor.setLocation(EasyMock.eq(ROOT + "/cxf/Soap" + ADDRESS));
-        EasyMock.expectLastCall();
-    }
-
-    private OsgiServlet setUpServlet() { 
-        OsgiServlet servlet = new OsgiServlet(registry);
-        try {
-            servlet.init(config);
-        } catch (ServletException ex) {
-            // ignore
-        }
-        return servlet;
-    }
 }

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=1044907&r1=1044906&r2=1044907&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java Sun Dec 12 20:30:16 2010
@@ -135,6 +135,10 @@ public abstract class AbstractHTTPDestin
         initConfig();
     }
     
+    public Bus getBus() {
+        return bus;
+    }
+
     private AuthorizationPolicy getAuthorizationPolicyFromMessage(String credentials) {
         if (credentials == null || StringUtils.isEmpty(credentials.trim())) {
             return null;
@@ -169,12 +173,6 @@ public abstract class AbstractHTTPDestin
         return ex == null ? false : ex.isOneWay();
     }
     
-    public void invoke(final ServletContext context, 
-                       final HttpServletRequest req, 
-                       final HttpServletResponse resp) throws IOException {
-        invoke(null, context, req, resp);
-    }
-    
     public void invoke(final ServletConfig config,
                        final ServletContext context, 
                        final HttpServletRequest req, 

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistry.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistry.java?rev=1044907&r1=1044906&r2=1044907&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistry.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistry.java Sun Dec 12 20:30:16 2010
@@ -19,9 +19,10 @@
 package org.apache.cxf.transport.http;
 
 import java.util.Collection;
-import java.util.List;
 import java.util.Set;
 
+import org.apache.cxf.transport.AbstractDestination;
+
 
 public interface DestinationRegistry {
     void addDestination(String path, AbstractHTTPDestination destination);
@@ -36,7 +37,7 @@ public interface DestinationRegistry {
     
     Collection<AbstractHTTPDestination> getDestinations();
     
-    List<AbstractHTTPDestination> getSortedDestinations();
+    AbstractDestination[] getSortedDestinations();
 
     Set<String> getDestinationsPaths();
 

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java?rev=1044907&r1=1044906&r2=1044907&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java Sun Dec 12 20:30:16 2010
@@ -30,6 +30,8 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
+import org.apache.cxf.transport.AbstractDestination;
+
 public class DestinationRegistryImpl implements DestinationRegistry {
 
     private ConcurrentMap<String, AbstractHTTPDestination> destinations 
@@ -94,7 +96,7 @@ public class DestinationRegistryImpl imp
     }
     
 
-    public List<AbstractHTTPDestination> getSortedDestinations() {
+    public AbstractDestination[] getSortedDestinations() {
         List<AbstractHTTPDestination> dest2 = new LinkedList<AbstractHTTPDestination>(
                 getDestinations());
         Collections.sort(dest2, new Comparator<AbstractHTTPDestination>() {
@@ -112,7 +114,7 @@ public class DestinationRegistryImpl imp
             }
         });
 
-        return dest2;
+        return dest2.toArray(new AbstractDestination[]{});
     }
 
     public Set<String> getDestinationsPaths() {

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java?rev=1044907&r1=1044906&r2=1044907&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java Sun Dec 12 20:30:16 2010
@@ -25,6 +25,7 @@ import java.util.logging.Logger;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -34,6 +35,7 @@ import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.transport.DestinationFactory;
 import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.transport.servlet.servicelist.ServiceListGeneratorServlet;
 
 
 
@@ -53,10 +55,12 @@ public abstract class AbstractCXFServlet
     }
     
     public ServletController createServletController(ServletConfig servletConfig) {
+        HttpServlet serviceListGeneratorServlet = 
+            new ServiceListGeneratorServlet(servletTransportFactory.getRegistry(), bus);
         ServletController newController =
             new ServletController(servletTransportFactory.getRegistry(),
                                   servletConfig,
-                                  bus);
+                                  serviceListGeneratorServlet);
         servletTransportFactory.setServletController(newController);
         if (servletConfig.getInitParameter("disable-address-updates") == null) {
             newController.setDisableAddressUpdates(disableAddressUpdates);

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractServletController.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractServletController.java?rev=1044907&r1=1044906&r2=1044907&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractServletController.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractServletController.java Sun Dec 12 20:30:16 2010
@@ -20,17 +20,23 @@
 package org.apache.cxf.transport.servlet;
 
 import java.io.IOException;
+import java.io.OutputStream;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.UrlUtils;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.DestinationRegistry;
+import org.apache.cxf.transports.http.QueryHandler;
+import org.apache.cxf.transports.http.QueryHandlerRegistry;
 
 public abstract class AbstractServletController {
     protected static final String DEFAULT_LISTINGS_CLASSIFIER = "/services";
@@ -43,13 +49,15 @@ public abstract class AbstractServletCon
     protected String title;
     protected String serviceListRelativePath = DEFAULT_LISTINGS_CLASSIFIER;
     protected ServletConfig servletConfig;
-    
-    protected AbstractServletController() {
-        
-    }
-    
-    protected AbstractServletController(ServletConfig config) {
+    protected DestinationRegistry destinationRegistry;
+    protected HttpServlet serviceListGenerator;
+
+    protected AbstractServletController(ServletConfig config, 
+                                        DestinationRegistry destinationRegistry,
+                                        HttpServlet serviceListGenerator) {
         this.servletConfig = config;
+        this.destinationRegistry = destinationRegistry;
+        this.serviceListGenerator = serviceListGenerator;
         init();
     }
     
@@ -81,27 +89,24 @@ public abstract class AbstractServletCon
         
         String hideServiceList = servletConfig.getInitParameter("hide-service-list-page");
         if (hideServiceList != null) {
-            isHideServiceList = Boolean.valueOf(hideServiceList);
+            this.isHideServiceList = Boolean.valueOf(hideServiceList);
         }
         String isDisableAddressUpdates = servletConfig.getInitParameter("disable-address-updates");
         if (isDisableAddressUpdates != null) {
-            disableAddressUpdates = Boolean.valueOf(isDisableAddressUpdates);
+            this.disableAddressUpdates = Boolean.valueOf(isDisableAddressUpdates);
         }
         String isForcedBaseAddress = servletConfig.getInitParameter("base-address");
         if (isForcedBaseAddress != null) {
-            forcedBaseAddress = isForcedBaseAddress;
+            this.forcedBaseAddress = isForcedBaseAddress;
         }
-        String serviceListTransform = servletConfig.getInitParameter("service-list-stylesheet");
-        if (serviceListTransform != null) {
-            serviceListStyleSheet = serviceListTransform;
+        try {
+            serviceListGenerator.init(servletConfig);
+        } catch (ServletException e) {
+            throw new RuntimeException(e.getMessage(), e);
         }
         String serviceListPath = servletConfig.getInitParameter("service-list-path");
         if (serviceListPath != null) {
-            serviceListRelativePath = serviceListPath;
-        }
-        String configTitle = servletConfig.getInitParameter("service-list-title");
-        if (configTitle != null) {
-            title = configTitle;
+            this.serviceListRelativePath = serviceListPath;
         }
     }
     
@@ -154,7 +159,44 @@ public abstract class AbstractServletCon
                 LOG.fine("Finished servicing http request on thread: " + Thread.currentThread());
             }
         }
+    }
+    
+    protected QueryHandler findQueryHandler(QueryHandlerRegistry queryHandlerRegistry, 
+                                            EndpointInfo ei, 
+                                            String ctxUri,
+                                            String baseUri) {
+        if (queryHandlerRegistry == null) {
+            return null;
+        }
+        Iterable<QueryHandler> handlers = queryHandlerRegistry.getHandlers();
+        for (QueryHandler qh : handlers) {
+            if (qh.isRecognizedQuery(baseUri, ctxUri, ei)) {
+                return qh;
+            }
+        }
+        return null;
+    }
 
+    protected void respondUsingQueryHandler(QueryHandler selectedHandler, HttpServletResponse res,
+                                          EndpointInfo ei, String ctxUri, String baseUri) throws IOException,
+        ServletException {
+        res.setContentType(selectedHandler.getResponseContentType(baseUri, ctxUri));
+        OutputStream out = res.getOutputStream();
+        try {
+            selectedHandler.writeResponse(baseUri, ctxUri, ei, out);
+            out.flush();
+        } catch (Exception e) {
+            LOG.warning(selectedHandler.getClass().getName()
+                + " Exception caught writing response: "
+                + e.getMessage());
+            throw new ServletException(e);
+        }
     }
 
+    protected void generateNotFound(HttpServletRequest request, HttpServletResponse res) throws IOException {
+        res.setStatus(404);
+        res.setContentType("text/html");
+        res.getWriter().write("<html><body>No service was found.</body></html>");
+    }
+    
 }

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java?rev=1044907&r1=1044906&r2=1044907&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java Sun Dec 12 20:30:16 2010
@@ -20,27 +20,21 @@ package org.apache.cxf.transport.servlet
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 import org.apache.cxf.transport.http.DestinationRegistry;
 import org.apache.cxf.transports.http.QueryHandler;
@@ -49,19 +43,13 @@ import org.apache.cxf.wsdl.http.AddressT
 
 public class ServletController extends AbstractServletController {
     
-    private static final Logger LOG = LogUtils.getL7dLogger(ServletController.class);
-    
-    private Bus bus;
+    private static final Logger LOG = LogUtils.getL7dLogger(ServletController.class);  
     private volatile String lastBase = "";
-
-    private final DestinationRegistry destinationRegistry;
     
     public ServletController(DestinationRegistry destinationRegistry,
-                             ServletConfig config,
-                             Bus b) {
-        super(config);
-        this.destinationRegistry = destinationRegistry;
-        this.bus = b;
+                             ServletConfig config, 
+                             HttpServlet serviceListGeneratorServlet) {
+        super(config, destinationRegistry, serviceListGeneratorServlet);
     }
         
     String getLastBaseURL() {
@@ -121,14 +109,7 @@ public class ServletController extends A
                     || StringUtils.isEmpty(request.getPathInfo())
                     || "/".equals(request.getPathInfo()))) {
                     updateDests(request);
-                    
-                    if (request.getParameter("stylesheet") != null) {
-                        renderStyleSheet(request, res);
-                    } else if ("false".equals(request.getParameter("formatted"))) {
-                        generateUnformattedServiceList(request, res);
-                    } else {
-                        generateServiceList(request, res);
-                    }
+                    serviceListGenerator.service(request, res);
                 } else {
                     d = destinationRegistry.checkRestfulRequest(address);
                     if (d == null) {                        
@@ -142,7 +123,7 @@ public class ServletController extends A
                 }
             } else {
                 ei = d.getEndpointInfo();
-                
+                Bus bus = d.getBus();
                 if ("GET".equals(request.getMethod())
                     && null != request.getQueryString() 
                     && request.getQueryString().length() > 0
@@ -189,221 +170,4 @@ public class ServletController extends A
         } 
     }
 
-
-    
-    @SuppressWarnings("unchecked")
-    protected void generateServiceList(HttpServletRequest request, HttpServletResponse response)
-        throws IOException {        
-        response.setContentType("text/html; charset=UTF-8");        
-        
-        response.getWriter().write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" " 
-                + "\"http://www.w3.org/TR/html4/loose.dtd\">");
-        response.getWriter().write("<HTML><HEAD>");
-        if (serviceListStyleSheet != null) {
-            response.getWriter().write(
-                    "<LINK type=\"text/css\" rel=\"stylesheet\" href=\"" 
-                    + request.getContextPath() + "/" + serviceListStyleSheet + "\">");
-        } else {
-            response.getWriter().write(
-                                       "<LINK type=\"text/css\" rel=\"stylesheet\" href=\"" 
-                                       + request.getRequestURI() + "/?stylesheet=1\">");            
-        }
-        response.getWriter().write("<meta http-equiv=content-type content=\"text/html; charset=UTF-8\">");
-        if (title != null) {
-            response.getWriter().write("<title>" + title + "</title>");
-        } else {
-            response.getWriter().write("<title>CXF - Service list</title>");
-        }
-        response.getWriter().write("</head><body>");
-        
-        List<AbstractHTTPDestination> destinations = destinationRegistry.getSortedDestinations();
-            
-        if (destinations.size() > 0) {
-            List<String> privateEndpoints = 
-                (List<String>)bus.getProperty("org.apache.cxf.private.endpoints");
-            //TODO : we may introduce a bus extension instead
-            Map<String, String> atomMap = 
-                (Map<String, String>)bus.getProperty("org.apache.cxf.extensions.logging.atom.pull");
-            writeSOAPEndpoints(response, destinations, privateEndpoints, atomMap);
-            writeRESTfulEndpoints(response, destinations, privateEndpoints, atomMap);
-        } else {
-            response.getWriter().write("<span class=\"heading\">No services have been found.</span>");
-        }
-        
-        response.getWriter().write("</body></html>");
-    }
-
-    private void writeSOAPEndpoints(HttpServletResponse response, List<AbstractHTTPDestination> destinations,
-                                    List<String> privateEndpoints, Map<String, String> atomMap)
-        throws IOException {
-        response.getWriter().write("<span class=\"heading\">Available SOAP services:</span><br/>");
-        response.getWriter().write("<table " + (serviceListStyleSheet == null
-                ? "cellpadding=\"1\" cellspacing=\"1\" border=\"1\" width=\"100%\"" : "") + ">");
-        for (AbstractHTTPDestination sd : destinations) {
-            
-            if (null != sd.getEndpointInfo().getName() 
-                && null != sd.getEndpointInfo().getInterface()
-                && !isPrivate(sd.getEndpointInfo(), privateEndpoints)) {
-                response.getWriter().write("<tr><td>");
-                response.getWriter().write("<span class=\"porttypename\">"
-                        + sd.getEndpointInfo().getInterface().getName().getLocalPart()
-                        + "</span>");
-                response.getWriter().write("<ul>");
-                for (OperationInfo oi : sd.getEndpointInfo().getInterface().getOperations()) {
-                    if (oi.getProperty("operation.is.synthetic") != Boolean.TRUE) {
-                        response.getWriter().write("<li>" + oi.getName().getLocalPart() + "</li>");
-                    }
-                }
-                response.getWriter().write("</ul>");
-                response.getWriter().write("</td><td>");
-                String address = sd.getEndpointInfo().getAddress();
-                response.getWriter().write("<span class=\"field\">Endpoint address:</span> "
-                        + "<span class=\"value\">" + address + "</span>");
-                response.getWriter().write("<br/><span class=\"field\">WSDL :</span> "
-                        + "<a href=\"" + address + "?wsdl\">"
-                        + sd.getEndpointInfo().getService().getName() + "</a>");
-                response.getWriter().write("<br/><span class=\"field\">Target namespace:</span> "
-                        + "<span class=\"value\">" 
-                        + sd.getEndpointInfo().getService().getTargetNamespace() + "</span>");
-                addAtomLinkIfNeeded(address, atomMap, response.getWriter());
-                response.getWriter().write("</td></tr>");
-            }    
-        }
-        response.getWriter().write("</table><br/><br/>");
-    }
-    
-    
-    private void writeRESTfulEndpoints(HttpServletResponse response, 
-                                       List<AbstractHTTPDestination> destinations,
-                                       List<String> privateEndpoints, 
-                                       Map<String, String> atomMap)
-        throws IOException {
-        
-        List<AbstractHTTPDestination> restfulDests = new ArrayList<AbstractHTTPDestination>();
-        for (AbstractHTTPDestination sd : destinations) {
-            // use some more reasonable check - though this one seems to be the only option at the moment
-            if (null == sd.getEndpointInfo().getInterface() 
-                && !isPrivate(sd.getEndpointInfo(), privateEndpoints)) {
-                restfulDests.add(sd);
-            }
-        }
-        if (restfulDests.size() == 0) {
-            return;
-        }
-        
-        response.getWriter().write("<span class=\"heading\">Available RESTful services:</span><br/>");
-        response.getWriter().write("<table " + (serviceListStyleSheet == null
-                ? "cellpadding=\"1\" cellspacing=\"1\" border=\"1\" width=\"100%\"" : "") + ">");
-        for (AbstractHTTPDestination sd : restfulDests) {
-            response.getWriter().write("<tr><td>");
-            String address = sd.getEndpointInfo().getAddress();
-            response.getWriter().write("<span class=\"field\">Endpoint address:</span> "
-                    + "<span class=\"value\">" + address + "</span>");
-            response.getWriter().write("<br/><span class=\"field\">WADL :</span> "
-                    + "<a href=\"" + address + "?_wadl&_type=xml\">"
-                    + address + "?_wadl&type=xml" + "</a>");
-            addAtomLinkIfNeeded(address, atomMap, response.getWriter());
-            response.getWriter().write("</td></tr>");
-        }
-        response.getWriter().write("</table>");
-    }
-    
-    private boolean isPrivate(EndpointInfo ei, List<String> privateAddresses) {
-        if (privateAddresses != null) {
-            for (String s : privateAddresses) {
-                if (ei.getAddress().endsWith(s)) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-    
-    private static void addAtomLinkIfNeeded(String address, Map<String, String> extMap,
-                                            PrintWriter pw) {
-        String atomAddress = getExtensionEndpointAddress(address, extMap);
-        if (atomAddress != null) {
-            pw.write("<br/><span class=\"field\">Atom Log Feed :</span> "
-                + "<a href=\"" + atomAddress + "\">" + atomAddress + "</a>");
-        }
-    }
-    
-    private static String getExtensionEndpointAddress(String endpointAddress, Map<String, String> extMap) {
-        if (extMap != null) {
-            for (Map.Entry<String, String> entry : extMap.entrySet()) {
-                if (endpointAddress.endsWith(entry.getKey())) {    
-                    endpointAddress = 
-                        endpointAddress.substring(0, endpointAddress.length() - entry.getKey().length());
-                    endpointAddress += entry.getValue();
-                    return endpointAddress;
-                }
-            }
-        }
-        return null;
-    }
-    
-    private void renderStyleSheet(HttpServletRequest request,
-            HttpServletResponse response) throws IOException {
-        response.setContentType("text/css; charset=UTF-8");
-
-        URL url = this.getClass().getResource("servicelist.css");
-        if (url != null) {
-            IOUtils.copy(url.openStream(), response.getOutputStream());
-        }
-    }
-
-
-    protected void generateUnformattedServiceList(HttpServletRequest request,
-            HttpServletResponse response) throws IOException {
-        response.setContentType("text/plain; charset=UTF-8");
-
-        List<AbstractHTTPDestination> destinations = destinationRegistry.getSortedDestinations();
-        if (destinations.size() > 0) {
-            writeUnformattedSOAPEndpoints(response, destinations, request.getParameter("wsdlList"));
-            writeUnformattedRESTfulEndpoints(response, destinations);
-        } else {
-            response.getWriter().write("No services have been found.");
-        }
-    }
-    
-    private void writeUnformattedSOAPEndpoints(HttpServletResponse response,
-                                               List<AbstractHTTPDestination> destinations,
-                                               Object renderParam) 
-        throws IOException {
-        boolean renderWsdlList = "true".equals(renderParam);
-        
-        for (AbstractHTTPDestination sd : destinations) {
-            
-            if (null != sd.getEndpointInfo().getInterface()) {
-            
-                String address = sd.getEndpointInfo().getAddress();
-                response.getWriter().write(address);
-                
-                if (renderWsdlList) {
-                    response.getWriter().write("?wsdl");
-                }
-                response.getWriter().write('\n');
-            }
-        }
-        response.getWriter().write('\n');
-    }
-    
-    private void writeUnformattedRESTfulEndpoints(HttpServletResponse response,
-                                                  List<AbstractHTTPDestination> destinations) 
-        throws IOException {
-        for (AbstractHTTPDestination sd : destinations) {
-            if (null == sd.getEndpointInfo().getInterface()) {
-                String address = sd.getEndpointInfo().getAddress();
-                response.getWriter().write(address + "?_wadl&_type=xml");
-                response.getWriter().write('\n');
-            }
-        }
-    }
-    
-    protected void generateNotFound(HttpServletRequest request, HttpServletResponse res) throws IOException {
-        res.setStatus(404);
-        res.setContentType("text/html");
-        res.getWriter().write("<html><body>No service was found.</body></html>");
-    }
-
 }

Added: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java?rev=1044907&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java (added)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/FormattedServiceListWriter.java Sun Dec 12 20:30:16 2010
@@ -0,0 +1,148 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.transport.servlet.servicelist;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Map;
+
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.transport.AbstractDestination;
+
+public class FormattedServiceListWriter implements ServiceListWriter {
+    private String styleSheetPath;
+    private String title;
+    private Map<String, String> atomMap;
+
+    public FormattedServiceListWriter(String styleSheetPath, 
+                                      String title, 
+                                      Map<String, String> atomMap) {
+        this.styleSheetPath = styleSheetPath;
+        this.title = title;
+        this.atomMap = atomMap;
+    }
+
+    public String getContentType() {
+        return "text/html; charset=UTF-8";
+    }
+
+    public void writeServiceList(PrintWriter writer,
+                                 AbstractDestination[] soapDestinations,
+                                 AbstractDestination[] restDestinations) throws IOException {
+        writer.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" "
+                     + "\"http://www.w3.org/TR/html4/loose.dtd\">");
+        writer.write("<HTML><HEAD>");
+        writer.write("<LINK type=\"text/css\" rel=\"stylesheet\" href=\"" + styleSheetPath + "\">");
+        writer.write("<meta http-equiv=content-type content=\"text/html; charset=UTF-8\">");
+        if (title != null) {
+            writer.write("<title>" + title + "</title>");
+        } else {
+            writer.write("<title>CXF - Service list</title>");
+        }
+        writer.write("</head><body>");
+
+        if (soapDestinations.length > 0 || restDestinations.length > 0) {
+            writeSOAPEndpoints(writer, soapDestinations);
+            writeRESTfulEndpoints(writer, restDestinations);
+        } else {
+            writer.write("<span class=\"heading\">No services have been found.</span>");
+        }
+
+        writer.write("</body></html>");
+    }
+
+    private void writeSOAPEndpoints(PrintWriter writer, 
+                                    AbstractDestination[] destinations)
+        throws IOException {
+        writer.write("<span class=\"heading\">Available SOAP services:</span><br/>");
+        writer.write("<table>");
+        for (AbstractDestination sd : destinations) {
+            writerSoapEndpoint(writer, sd);
+        }
+        writer.write("</table><br/><br/>");
+    }
+
+    private void writerSoapEndpoint(PrintWriter writer, AbstractDestination sd) {
+        writer.write("<tr><td>");
+        writer.write("<span class=\"porttypename\">"
+                     + sd.getEndpointInfo().getInterface().getName().getLocalPart() + "</span>");
+        writer.write("<ul>");
+        for (OperationInfo oi : sd.getEndpointInfo().getInterface().getOperations()) {
+            if (oi.getProperty("operation.is.synthetic") != Boolean.TRUE) {
+                writer.write("<li>" + oi.getName().getLocalPart() + "</li>");
+            }
+        }
+        writer.write("</ul>");
+        writer.write("</td><td>");
+        String address = sd.getEndpointInfo().getAddress();
+        writer.write("<span class=\"field\">Endpoint address:</span> " + "<span class=\"value\">"
+                     + address + "</span>");
+        writer.write("<br/><span class=\"field\">WSDL :</span> " + "<a href=\"" + address
+                     + "?wsdl\">" + sd.getEndpointInfo().getService().getName() + "</a>");
+        writer.write("<br/><span class=\"field\">Target namespace:</span> "
+                     + "<span class=\"value\">"
+                     + sd.getEndpointInfo().getService().getTargetNamespace() + "</span>");
+        addAtomLinkIfNeeded(address, atomMap, writer);
+        writer.write("</td></tr>");
+    }
+
+    private void writeRESTfulEndpoints(PrintWriter writer, AbstractDestination[] restfulDests)
+        throws IOException {
+        writer.write("<span class=\"heading\">Available RESTful services:</span><br/>");
+        writer.write("<table>");
+        for (AbstractDestination sd : restfulDests) {
+            writeRESTfulEndpoint(writer, sd);
+        }
+        writer.write("</table>");
+    }
+
+    private void writeRESTfulEndpoint(PrintWriter writer, AbstractDestination sd) {
+        writer.write("<tr><td>");
+        String address = sd.getEndpointInfo().getAddress();
+        writer.write("<span class=\"field\">Endpoint address:</span> " + "<span class=\"value\">"
+                     + address + "</span>");
+        writer.write("<br/><span class=\"field\">WADL :</span> " + "<a href=\"" + address
+                     + "?_wadl&_type=xml\">" + address + "?_wadl&type=xml" + "</a>");
+        addAtomLinkIfNeeded(address, atomMap, writer);
+        writer.write("</td></tr>");
+    }
+
+    private static void addAtomLinkIfNeeded(String address, Map<String, String> extMap, PrintWriter pw) {
+        String atomAddress = getExtensionEndpointAddress(address, extMap);
+        if (atomAddress != null) {
+            pw.write("<br/><span class=\"field\">Atom Log Feed :</span> " + "<a href=\"" + atomAddress
+                     + "\">" + atomAddress + "</a>");
+        }
+    }
+
+    private static String getExtensionEndpointAddress(String endpointAddress, Map<String, String> extMap) {
+        if (extMap != null) {
+            for (Map.Entry<String, String> entry : extMap.entrySet()) {
+                if (endpointAddress.endsWith(entry.getKey())) {
+                    endpointAddress = endpointAddress.substring(0, endpointAddress.length()
+                                                                   - entry.getKey().length());
+                    endpointAddress += entry.getValue();
+                    return endpointAddress;
+                }
+            }
+        }
+        return null;
+    }
+
+}

Added: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java?rev=1044907&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java (added)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java Sun Dec 12 20:30:16 2010
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.transport.servlet.servicelist;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.AbstractDestination;
+import org.apache.cxf.transport.http.DestinationRegistry;
+
+public class ServiceListGeneratorServlet extends HttpServlet {
+    private DestinationRegistry destinationRegistry;
+    private Bus bus;
+    private String serviceListStyleSheet;
+    private String title;
+
+    public ServiceListGeneratorServlet(DestinationRegistry destinationRegistry, Bus bus) {
+        this.destinationRegistry = destinationRegistry;
+        this.bus = bus;
+        this.title = "CXF - Service list";
+    }
+
+    public void setServiceListStyleSheet(String serviceListStyleSheet) {
+        this.serviceListStyleSheet = serviceListStyleSheet;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+    
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void service(HttpServletRequest request, 
+                        HttpServletResponse response) throws ServletException, IOException {
+        PrintWriter writer = response.getWriter();
+        AbstractDestination[] destinations = destinationRegistry.getSortedDestinations();
+        if (request.getParameter("stylesheet") != null) {
+            renderStyleSheet(request, response);
+            return;
+        }
+        List<String> privateEndpoints;
+        Map<String, String> atomMap;
+        
+        if (bus != null) {
+            privateEndpoints = (List<String>)bus.getProperty("org.apache.cxf.private.endpoints");
+            // TODO : we may introduce a bus extension instead
+
+            atomMap = (Map<String, String>)bus
+                .getProperty("org.apache.cxf.extensions.logging.atom.pull");
+        } else {
+            privateEndpoints = new ArrayList<String>();
+            atomMap = new HashMap<String, String>();
+        }
+        
+        AbstractDestination[] soapEndpoints = getSOAPEndpoints(destinations, privateEndpoints);
+        AbstractDestination[] restEndpoints = getRestEndpoints(destinations, privateEndpoints);
+        ServiceListWriter serviceListWriter;
+        if ("false".equals(request.getParameter("formatted"))) {
+            boolean renderWsdlList = "true".equals(request.getParameter("wsdlList"));
+            serviceListWriter = new UnformattedServiceListWriter(renderWsdlList);
+        } else {
+            String styleSheetPath;
+            if (serviceListStyleSheet != null) {
+                styleSheetPath = request.getContextPath() + "/" + serviceListStyleSheet;
+                
+            } else {
+                styleSheetPath = request.getRequestURI() + "/?stylesheet=1";
+            }
+            serviceListWriter = new FormattedServiceListWriter(styleSheetPath, title, atomMap);
+            
+        }
+        response.setContentType(serviceListWriter.getContentType());
+        serviceListWriter.writeServiceList(writer, soapEndpoints, restEndpoints);
+    }
+    
+
+    private boolean isPrivate(EndpointInfo ei, List<String> privateEndpoints) {
+        if (privateEndpoints != null) {
+            for (String s : privateEndpoints) {
+                if (ei.getAddress().endsWith(s)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    private AbstractDestination[] getSOAPEndpoints(AbstractDestination[] destinations,
+                                                   List<String> privateEndpoints) {
+        List<AbstractDestination> soapEndpoints = new ArrayList<AbstractDestination>();
+        for (AbstractDestination sd : destinations) {
+            if (null != sd.getEndpointInfo().getName() && null != sd.getEndpointInfo().getInterface()
+                && !isPrivate(sd.getEndpointInfo(), privateEndpoints)) {
+                soapEndpoints.add(sd);
+            }
+        }
+        return soapEndpoints.toArray(new AbstractDestination[]{});
+    }
+    
+    private AbstractDestination[] getRestEndpoints(AbstractDestination[] destinations,
+                                                   List<String> privateEndpoints) {
+        List<AbstractDestination> restfulDests = new ArrayList<AbstractDestination>();
+        for (AbstractDestination sd : destinations) {
+            // use some more reasonable check - though this one seems to be the only option at the moment
+            if (null == sd.getEndpointInfo().getInterface()
+                && !isPrivate(sd.getEndpointInfo(), privateEndpoints)) {
+                restfulDests.add(sd);
+            }
+        }
+        return restfulDests.toArray(new AbstractDestination[]{});
+    }
+    
+
+    private void renderStyleSheet(HttpServletRequest request, HttpServletResponse response)
+        throws IOException {
+        response.setContentType("text/css; charset=UTF-8");
+        URL url = this.getClass().getResource("servicelist.css");
+        if (url != null) {
+            IOUtils.copy(url.openStream(), response.getOutputStream());
+        }
+    }
+
+    public void init(ServletConfig servletConfig) {
+        String configServiceListStyleSheet = servletConfig.getInitParameter("service-list-stylesheet");
+        if (configServiceListStyleSheet != null) {
+            this.serviceListStyleSheet = configServiceListStyleSheet;
+        }
+        String configTitle = servletConfig.getInitParameter("service-list-title");
+        if (configTitle != null) {
+            this.title = configTitle;
+        }
+    }
+
+    public ServletConfig getServletConfig() {
+        return null;
+    }
+
+    public String getServletInfo() {
+        return null;
+    }
+
+    public void destroy() { 
+    }
+}

Added: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListWriter.java?rev=1044907&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListWriter.java (added)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListWriter.java Sun Dec 12 20:30:16 2010
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.transport.servlet.servicelist;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import org.apache.cxf.transport.AbstractDestination;
+
+public interface ServiceListWriter {
+    String getContentType();
+    void writeServiceList(PrintWriter writer, 
+                          AbstractDestination[] soapDestinations,
+                          AbstractDestination[] restDestinations) throws IOException;
+    
+}

Added: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/UnformattedServiceListWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/UnformattedServiceListWriter.java?rev=1044907&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/UnformattedServiceListWriter.java (added)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/UnformattedServiceListWriter.java Sun Dec 12 20:30:16 2010
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.transport.servlet.servicelist;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import org.apache.cxf.transport.AbstractDestination;
+
+public class UnformattedServiceListWriter implements ServiceListWriter {
+    boolean renderWsdlList;
+
+    public UnformattedServiceListWriter(boolean renderWsdlList) {
+        this.renderWsdlList = renderWsdlList;
+    }
+
+    public String getContentType() {
+        return "text/plain; charset=UTF-8";
+    }
+
+    public void writeServiceList(PrintWriter writer, 
+                                 AbstractDestination[] soapDestinations,
+                                 AbstractDestination[] restDestinations) throws IOException {
+        if (soapDestinations.length > 0 && restDestinations.length > 0) {
+            writeUnformattedSOAPEndpoints(writer, soapDestinations);
+            writeUnformattedRESTfulEndpoints(writer, restDestinations);
+        } else {
+            writer.write("No services have been found.");
+        }
+    }
+    
+    private void writeUnformattedSOAPEndpoints(PrintWriter writer,
+                                               AbstractDestination[] destinations) throws IOException {
+        for (AbstractDestination sd : destinations) {
+            String address = sd.getEndpointInfo().getAddress();
+            writer.write(address);
+
+            if (renderWsdlList) {
+                writer.write("?wsdl");
+            }
+            writer.write('\n');
+        }
+        writer.write('\n');
+    }
+
+    private void writeUnformattedRESTfulEndpoints(PrintWriter writer,
+                                                  AbstractDestination[] destinations) throws IOException {
+        for (AbstractDestination sd : destinations) {
+            String address = sd.getEndpointInfo().getAddress();
+            writer.write(address + "?_wadl&_type=xml\n");
+        }
+    }
+
+}



Mime
View raw message