Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 76462 invoked from network); 24 Nov 2006 10:50:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Nov 2006 10:50:43 -0000 Received: (qmail 21141 invoked by uid 500); 24 Nov 2006 10:50:52 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 21054 invoked by uid 500); 24 Nov 2006 10:50:52 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 21041 invoked by uid 99); 24 Nov 2006 10:50:52 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Nov 2006 02:50:52 -0800 X-ASF-Spam-Status: No, hits=0.8 required=10.0 tests=INFO_TLD,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of James.Mao@iona.com designates 65.223.216.181 as permitted sender) Received: from [65.223.216.181] (HELO amereast-smg1.iona.com) (65.223.216.181) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Nov 2006 02:50:39 -0800 Received: from amer-ems1.IONAGLOBAL.COM ([10.65.6.25]) by amereast-smg1.iona.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id kAOAoI5F019291; Fri, 24 Nov 2006 05:50:18 -0500 (EST) Received: from [10.129.9.116] ([10.129.9.116]) by amer-ems1.IONAGLOBAL.COM with Microsoft SMTPSVC(6.0.3790.1830); Fri, 24 Nov 2006 05:50:17 -0500 Message-ID: <4566CDFE.30609@iona.com> Date: Fri, 24 Nov 2006 18:48:30 +0800 From: James Mao User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: cxf-dev@incubator.apache.org CC: cxf-commits@incubator.apache.org Subject: Re: svn commit: r478826 - in /incubator/cxf/trunk/rt/frontend/jaxws/src: main/java/org/apache/cxf/jaxws/servlet/ test/java/org/apache/cxf/jaxws/servlet/ References: <20061124101134.9193F1A9846@eris.apache.org> In-Reply-To: <20061124101134.9193F1A9846@eris.apache.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 24 Nov 2006 10:50:17.0618 (UTC) FILETIME=[544D8720:01C70FB6] X-Virus-Checked: Checked by ClamAV on apache.org Hi Willem, I suggest we use ?serviceList to retrieve the service list just like we use ?wsdl to retrieve the wsdl Cheers, James. > Author: ningjiang > Date: Fri Nov 24 02:11:33 2006 > New Revision: 478826 > > URL: http://svn.apache.org/viewvc?view=rev&rev=478826 > Log: > [JIRA CXF-266] Let servlet control can return list of services which are published by servlet > Now we can get the services list from http://localhost/services > > Modified: > incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java > incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletController.java > incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java > incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletTransportFactory.java > incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/servlet/CXFServletTest.java > > Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java > URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java?view=diff&rev=478826&r1=478825&r2=478826 > ============================================================================== > --- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java (original) > +++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java Fri Nov 24 02:11:33 2006 > @@ -59,7 +59,7 @@ > * > */ > public class CXFServlet extends HttpServlet { > - > + static final String ADDRESS_PERFIX = "http://localhost/services"; > static final Map> BUS_MAP = new Hashtable>(); > static final Logger LOG = Logger.getLogger(CXFServlet.class.getName()); > protected Bus bus; > @@ -189,28 +189,7 @@ > String urlPat) throws ServletException { > > try { > - > - // TODO: This wasn't doing anything before. We need to pass this to > - // the > - // EndpointImpl so the service factory can use it... > - // URL url = null; > - // if (wsdlName != null && wsdlName.length() > 0) { > - // try { > - // url = > - // getServletConfig().getServletContext().getResource(wsdlName); > - // } catch (MalformedURLException ex) { > - // try { > - // url = new URL(wsdlName); > - // } catch (MalformedURLException ex2) { > - // try { > - // url = getServletConfig().getServletContext().getResource("/" + > - // wsdlName); > - // } catch (MalformedURLException ex3) { > - // url = null; > - // } > - // } > - // } > - // } > + > Class cls = ClassLoaderUtils.loadClass(implName, getClass()); > Object impl = cls.newInstance(); > > @@ -218,7 +197,7 @@ > LOG.info("publish the servcie to {context}/ " + (urlPat.charAt(0) == '/' ? "" : "/") + urlPat); > > // TODO we may need to get the url-pattern from servlet context > - ep.publish("http://localhost/services" + (urlPat.charAt(0) == '/' ? "" : "/") + urlPat); > + ep.publish(ADDRESS_PERFIX + (urlPat.charAt(0) == '/' ? "" : "/") + urlPat); > > } catch (ClassNotFoundException ex) { > throw new ServletException(ex); > > Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletController.java > URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletController.java?view=diff&rev=478826&r1=478825&r2=478826 > ============================================================================== > --- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletController.java (original) > +++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletController.java Fri Nov 24 02:11:33 2006 > @@ -70,7 +70,7 @@ > boolean xsd = false; > if (request.getQueryString() != null && request.getQueryString().trim().equalsIgnoreCase("wsdl")) { > wsdl = true; > - } > + } > String xsdName = request.getRequestURI().substring( > request.getRequestURI().lastIndexOf("/") + 1); > if (xsdName != null > @@ -86,11 +86,15 @@ > if (d.getMessageObserver() == null) { > if (xsd) { > generateXSD(request, res, xsdName); > - } else { > - LOG.warning("Can't find the the request for" > - + "http://localhost" + request.getServletPath() > - + request.getPathInfo() + " 's Observer "); > - generateNotFound(request, res); > + } else { > + if (request.getRequestURI().endsWith("services")) { > + generateServiceList(request, res); > + } else { > + LOG.warning("Can't find the the request for" > + + "http://localhost" + request.getServletPath() > + + request.getPathInfo() + " 's Observer "); > + generateNotFound(request, res); > + } > } > } else if (wsdl) { > generateWSDL(request, res, d); > @@ -100,6 +104,28 @@ > } catch (IOException e) { > throw new ServletException(e); > } > + } > + > + private void generateServiceList(HttpServletRequest request, HttpServletResponse response) > + throws IOException { > + List destinations = transport.getDestinations(); > + response.setContentType("text/html"); > + response.getWriter().write(""); > + if (destinations.size() > 0) { > + for (ServletDestination sd : destinations) { > + if (null != sd.getEndpointInfo().getName()) { > + String address = sd.getAddress().getAddress().getValue(); > + int bi = address.indexOf(CXFServlet.ADDRESS_PERFIX); > + address = request.getRequestURL() > + + address.substring(bi + CXFServlet.ADDRESS_PERFIX.length()); > + response.getWriter().write(""); > + response.getWriter().write(sd.getEndpointInfo().getName() + ""); > + } > + } > + } else { > + response.getWriter().write("No service was found."); > + } > + response.getWriter().write(""); > } > > private void generateXSD(HttpServletRequest request, HttpServletResponse response, String xsdName) > > Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java > URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java?view=diff&rev=478826&r1=478825&r2=478826 > ============================================================================== > --- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java (original) > +++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java Fri Nov 24 02:11:33 2006 > @@ -155,7 +155,7 @@ > * @param observer the observer to notify on receipt of incoming > */ > public synchronized void setMessageObserver(MessageObserver observer) { > - LOG.info("!!! set the observer for address " + getAddress().getAddress().getValue()); > + LOG.info("set the observer for address " + getAddress().getAddress().getValue()); > incomingObserver = observer; > } > > @@ -262,8 +262,7 @@ > > setHeaders(inMessage); > > - inMessage.setDestination(this); > - > + inMessage.setDestination(this); > > incomingObserver.onMessage(inMessage); > > > Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletTransportFactory.java > URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletTransportFactory.java?view=diff&rev=478826&r1=478825&r2=478826 > ============================================================================== > --- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletTransportFactory.java (original) > +++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletTransportFactory.java Fri Nov 24 02:11:33 2006 > @@ -21,8 +21,10 @@ > package org.apache.cxf.jaxws.servlet; > > import java.io.IOException; > -import java.util.HashMap; > +import java.util.ArrayList; > +import java.util.List; > import java.util.Map; > +import java.util.concurrent.ConcurrentHashMap; > > import javax.annotation.Resource; > > @@ -36,7 +38,8 @@ > implements DestinationFactory { > > private Bus bus; > - private Map destinations = new HashMap(); > + private Map destinations = > + new ConcurrentHashMap(); > > public ServletTransportFactory(Bus b) { > bus = b; > @@ -54,7 +57,7 @@ > this.bus = bus; > } > > - public synchronized Destination getDestination(EndpointInfo endpointInfo) > + public Destination getDestination(EndpointInfo endpointInfo) > throws IOException { > ServletDestination d = destinations.get(endpointInfo.getAddress()); > if (d == null) { > @@ -62,5 +65,13 @@ > destinations.put(endpointInfo.getAddress(), d); > } > return d; > + } > + > + public List getDestinations() { > + List result = new ArrayList(); > + for (ServletDestination sd : destinations.values()) { > + result.add(sd); > + } > + return result; > } > } > > Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/servlet/CXFServletTest.java > URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/servlet/CXFServletTest.java?view=diff&rev=478826&r1=478825&r2=478826 > ============================================================================== > --- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/servlet/CXFServletTest.java (original) > +++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/servlet/CXFServletTest.java Fri Nov 24 02:11:33 2006 > @@ -24,6 +24,7 @@ > > import com.meterware.httpunit.GetMethodWebRequest; > import com.meterware.httpunit.PostMethodWebRequest; > +import com.meterware.httpunit.WebLink; > import com.meterware.httpunit.WebRequest; > import com.meterware.httpunit.WebResponse; > import com.meterware.servletunit.ServletUnitClient; > @@ -72,6 +73,32 @@ > > assertValid("/s:Envelope/s:Body", doc); > assertValid("//h:sayHiResponse", doc); > + } > + > + public void testGetServiceList() throws Exception { > + ServletUnitClient client = newClient(); > + > + JaxWsServerFactoryBean svr = new JaxWsServerFactoryBean(); > + URL resource = getClass().getResource("/wsdl/hello_world.wsdl"); > + assertNotNull(resource); > + svr.getServiceFactory().setWsdlURL(resource); > + svr.setBus(getBus()); > + svr.setServiceClass(GreeterImpl.class); > + svr.setAddress("http://localhost/services/Greeter"); > + > + GreeterImpl greeter = new GreeterImpl(); > + BeanInvoker invoker = new BeanInvoker(greeter); > + svr.getServiceFactory().setInvoker(invoker); > + > + svr.create(); > + > + client.setExceptionsThrownOnErrorStatus(false); > + > + WebResponse res = client.getResponse("http://localhost/services"); > + WebLink[] links = res.getLinks(); > + assertEquals("There should get one link for service", links.length, 1); > + assertEquals(links[0].getURLString(), "http://localhost/services/Greeter"); > + assertEquals("text/html", res.getContentType()); > } > > public void testInvalidServiceUrl() throws Exception { > > > >