cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r822228 - in /cxf/trunk/rt/transports: 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/servlet/
Date Tue, 06 Oct 2009 11:50:57 GMT
Author: sergeyb
Date: Tue Oct  6 11:50:57 2009
New Revision: 822228

URL: http://svn.apache.org/viewvc?rev=822228&view=rev
Log:
Attempting to minimize the code duplication in http and osgi transports, more refactoring will have to be done later on

Added:
    cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java   (with props)
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java   (with props)
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractServletController.java   (with props)
Modified:
    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/OsgiTransportFactory.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/servlet/AbstractCXFServlet.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java

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=822228&r1=822227&r2=822228&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 Tue Oct  6 11:50:57 2009
@@ -22,12 +22,10 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 
 
@@ -93,8 +91,4 @@
         super.shutdown();
     }
 
-    public MessageObserver getMessageObserver() {
-        return this.incomingObserver;
-    }
-
 }

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=822228&r1=822227&r2=822228&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 Tue Oct  6 11:50:57 2009
@@ -18,287 +18,41 @@
  */
 package org.apache.cxf.transport.http_osgi;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.Principal;
-import java.util.Collection;
-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.HttpHeaderHelper;
 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.transport.http.AbstractHTTPDestination;
-import org.apache.cxf.transport.http.HTTPSession;
-import org.apache.cxf.transport.https.SSLUtils;
-import org.apache.cxf.transports.http.QueryHandler;
-import org.apache.cxf.transports.http.QueryHandlerRegistry;
-import org.apache.cxf.wsdl.http.AddressType;
-
-public class OsgiServlet extends HttpServlet {
-
-    private static final Logger LOG = LogUtils.getL7dLogger(OsgiServlet.class);
+import org.apache.cxf.transport.servlet.AbstractHTTPServlet;
 
+public class OsgiServlet extends AbstractHTTPServlet {
+    
     private OsgiDestinationRegistryIntf transport;
-    private String lastBase = "";
-    private boolean isHideServiceList;
-    private boolean disableAddressUpdates;
-    private String forcedBaseAddress;
-
+    private OsgiServletController controller;
+    
     public OsgiServlet(OsgiDestinationRegistryIntf transport) {
         this.transport = transport;
     }
 
-    @Override
-    public void destroy() {
+    public void init(ServletConfig servletConfig) throws ServletException {
+        super.init(servletConfig);
+        controller = new OsgiServletController(this);
     }
-
-    @Override
-    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
-        invoke(request, response);
-    }
-
-    @Override
-    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
-        invoke(request, response);
-    }
-
+    
     @Override
-    protected void doDelete(HttpServletRequest request, HttpServletResponse response)
-        throws ServletException, IOException {
-        invoke(request, response);
-    }
-
-    @Override
-    protected void doPut(HttpServletRequest request, HttpServletResponse response) 
-        throws ServletException, IOException {
-        invoke(request, response);
-    }
-
-    public void setHideServiceList(boolean generate) {
-        isHideServiceList = generate;
-    }
-
-    public void setDisableAddressUpdates(boolean noupdates) {
-        disableAddressUpdates = noupdates;
-    }
-
-    public void setForcedBaseAddress(String s) {
-        forcedBaseAddress = s;
+    public void destroy() {
     }
 
-    private synchronized void updateDests(HttpServletRequest request) {
-        if (disableAddressUpdates) {
-            return;
-        }
-        String base = forcedBaseAddress == null ? getBaseURL(request) : forcedBaseAddress;
-
-        //if (base.equals(lastBase)) {
-        //    return;
-        //}
-        Set<String> paths = transport.getDestinationsPaths();
-        for (String path : paths) {
-            OsgiDestination d2 = transport.getDestinationForPath(path);
-            String ad = d2.getEndpointInfo().getAddress();
-            if (ad.equals(path)
-                || ad.equals(lastBase + path)) {
-                d2.getEndpointInfo().setAddress(base + path);
-                if (d2.getEndpointInfo().getExtensor(AddressType.class) != null) {
-                    d2.getEndpointInfo().getExtensor(AddressType.class).setLocation(base + path);
-                }
-            }
-        }
-        lastBase = base;
+    public OsgiDestinationRegistryIntf getTransport() {
+        return transport;
     }
 
     public void invoke(HttpServletRequest request, HttpServletResponse res) throws ServletException {
-        try {
-            EndpointInfo ei = new EndpointInfo();
-            String address = request.getPathInfo() == null ? "" : request.getPathInfo();
-
-            ei.setAddress(address);
-            OsgiDestination d = (OsgiDestination) transport.getDestinationForPath(ei.getAddress());
-
-            if (d == null) {
-                if (request.getRequestURI().endsWith("/services")
-                    || request.getRequestURI().endsWith("/services/")
-                    || StringUtils.isEmpty(request.getPathInfo())
-                    || "/".equals(request.getPathInfo())) {
-                    updateDests(request);
-                    generateServiceList(request, res);
-                } else {
-                    d = checkRestfulRequest(request);
-                    if (d == null || d.getMessageObserver() == null) {
-                        LOG.warning("Can't find the the request for "
-                                    + request.getRequestURL() + "'s Observer ");
-                        generateNotFound(request, res);
-                    }  else { // the request should be a restful service request
-                        updateDests(request);
-                        invokeDestination(request, res, d);
-                    }
-                }
-            } else {
-                ei = d.getEndpointInfo();
-                Bus bus = d.getBus();
-                if (null != request.getQueryString()
-                    && request.getQueryString().length() > 0
-                    && bus.getExtension(QueryHandlerRegistry.class) != null) {
-
-                    String ctxUri = request.getPathInfo();
-                    String baseUri = request.getRequestURL().toString()
-                        + "?" + request.getQueryString();
-                    // update the EndPoint Address with request url
-                    if ("GET".equals(request.getMethod())) {
-                        updateDests(request);
-                    }
-
-                    for (QueryHandler qh : bus.getExtension(QueryHandlerRegistry.class).getHandlers()) {
-                        if (qh.isRecognizedQuery(baseUri, ctxUri, ei)) {
-
-                            res.setContentType(qh.getResponseContentType(baseUri, ctxUri));
-                            OutputStream out = res.getOutputStream();
-                            try {
-                                qh.writeResponse(baseUri, ctxUri, ei, out);
-                                out.flush();
-                                return;
-                            } catch (Exception e) {
-                                //throw new ServletException(e);
-                                LOG.warning(qh.getClass().getName()
-                                    + " Exception caught writing response: "
-                                    + e.getMessage());
-                            }
-                        }
-                    }
-                } else {
-                    invokeDestination(request, res, d);
-                }
-            }
-        } catch (IOException e) {
-            throw new ServletException(e);
-        }
-    }
-
-    private OsgiDestination checkRestfulRequest(HttpServletRequest request) throws IOException {
-
-        String address = request.getPathInfo() == null ? "" : request.getPathInfo();
-
-        for (String path : transport.getDestinationsPaths()) {
-            if (address.startsWith(path)) {
-                return transport.getDestinationForPath(path);
-            }
-        }
-        return null;
-    }
-
-    private void generateServiceList(HttpServletRequest request, HttpServletResponse response)
-        throws IOException {
-        Collection<OsgiDestination> destinations = transport.getDestinations();
-        response.setContentType("text/html");
-        response.getWriter().write("<html><body>");
-        if (!isHideServiceList) {
-            if (destinations.size() > 0) {
-                for (OsgiDestination sd : destinations) {
-                    if (null != sd.getEndpointInfo().getName()) {
-                        String address = sd.getEndpointInfo().getAddress();
-                        response.getWriter().write("<p> <a href=\"" + address + "?wsdl\">");
-                        response.getWriter().write(sd.getEndpointInfo().getName() + "</a> </p>");
-                    }
-                }
-            } else {
-                response.getWriter().write("No service was found.");
-            }
-        }
-        response.getWriter().write("</body></html>");
-    }
-
-    private String getBaseURL(HttpServletRequest request) {
-        String reqPrefix = request.getRequestURL().toString();
-        String pathInfo = request.getPathInfo() == null ? "" : request.getPathInfo();
-        //fix for CXF-898
-        if (!"/".equals(pathInfo) || reqPrefix.endsWith("/")) {
-            reqPrefix = reqPrefix.substring(0, reqPrefix.length() - pathInfo.length());
-        }
-        return reqPrefix;
+        controller.invoke(request, res);
     }
-
-    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>");
-    }
-
-    public void invokeDestination(final HttpServletRequest request, 
-                                  HttpServletResponse response, 
-                                  OsgiDestination d) throws ServletException {
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Service http request on thread: " + Thread.currentThread());
-        }
-
-        try {
-            MessageImpl inMessage = createInMessage();
-            inMessage.setContent(InputStream.class, request.getInputStream());
-            inMessage.put(AbstractHTTPDestination.HTTP_REQUEST, request);
-            inMessage.put(AbstractHTTPDestination.HTTP_RESPONSE, response);
-            inMessage.put(AbstractHTTPDestination.HTTP_CONTEXT, getServletContext());
-            inMessage.put(AbstractHTTPDestination.HTTP_CONFIG, getServletConfig());
-            inMessage.put(Message.HTTP_REQUEST_METHOD, request.getMethod());
-            inMessage.put(Message.REQUEST_URI, request.getRequestURI());
-            inMessage.put(Message.PATH_INFO, request.getPathInfo());
-            inMessage.put(Message.QUERY_STRING, request.getQueryString());
-            inMessage.put(Message.CONTENT_TYPE, request.getContentType());
-            inMessage.put(Message.ACCEPT_CONTENT_TYPE, request.getHeader("Accept"));
-            inMessage.put(Message.BASE_PATH, d.getAddress().getAddress().getValue());
-            inMessage.put(SecurityContext.class, new SecurityContext() {
-                public Principal getUserPrincipal() {
-                    return request.getUserPrincipal();
-                }
-                public boolean isUserInRole(String role) {
-                    return request.isUserInRole(role);
-                }
-            });
-
-            // work around a bug with Jetty which results in the character
-            // encoding not being trimmed correctly.
-            String enc = request.getCharacterEncoding();
-            if (enc != null && enc.endsWith("\"")) {
-                enc = enc.substring(0, enc.length() - 1);
-            }
-
-            String normalizedEncoding = HttpHeaderHelper.mapCharset(enc);
-            if (normalizedEncoding == null) {
-                String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG",
-                                                                  LOG, enc).toString();
-                LOG.log(Level.WARNING, m);
-                throw new IOException(m);
-            }
-
-            inMessage.put(Message.ENCODING, normalizedEncoding);
-            SSLUtils.propogateSecureSession(request, inMessage);
-
-            ExchangeImpl exchange = createExchange();
-            exchange.setInMessage(inMessage);
-            exchange.setSession(new HTTPSession(request));
-
-            d.doMessage(inMessage);
-        } catch (IOException e) {
-            throw new ServletException(e);
-        }
-
-    }
-
+    
     protected MessageImpl createInMessage() {
         return new MessageImpl();
     }

Added: 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=822228&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java (added)
+++ cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java Tue Oct  6 11:50:57 2009
@@ -0,0 +1,333 @@
+/**
+ * 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.http_osgi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.servlet.ServletException;
+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.HttpHeaderHelper;
+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.OperationInfo;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.HTTPSession;
+import org.apache.cxf.transport.https.SSLUtils;
+import org.apache.cxf.transport.servlet.AbstractServletController;
+import org.apache.cxf.transports.http.QueryHandler;
+import org.apache.cxf.transports.http.QueryHandlerRegistry;
+import org.apache.cxf.wsdl.http.AddressType;
+
+public class OsgiServletController extends AbstractServletController {
+    private static final Logger LOG = LogUtils.getL7dLogger(OsgiServlet.class);
+    
+    private String lastBase = "";
+    private OsgiServlet servlet;
+    public OsgiServletController(OsgiServlet servlet) {
+        super(servlet.getServletConfig());
+        this.servlet = servlet;
+    }
+
+    private synchronized void updateDests(HttpServletRequest request) {
+        if (disableAddressUpdates) {
+            return;
+        }
+        String base = forcedBaseAddress == null ? getBaseURL(request) : forcedBaseAddress;
+
+        //if (base.equals(lastBase)) {
+        //    return;
+        //}
+        Set<String> paths = servlet.getTransport().getDestinationsPaths();
+        for (String path : paths) {
+            OsgiDestination d2 = servlet.getTransport().getDestinationForPath(path);
+            String ad = d2.getEndpointInfo().getAddress();
+            if (ad.equals(path)
+                || ad.equals(lastBase + path)) {
+                d2.getEndpointInfo().setAddress(base + path);
+                if (d2.getEndpointInfo().getExtensor(AddressType.class) != null) {
+                    d2.getEndpointInfo().getExtensor(AddressType.class).setLocation(base + path);
+                }
+            }
+        }
+        lastBase = base;
+    }
+
+    public void invoke(HttpServletRequest request, HttpServletResponse res) throws ServletException {
+        try {
+            EndpointInfo ei = new EndpointInfo();
+            String address = request.getPathInfo() == null ? "" : request.getPathInfo();
+
+            ei.setAddress(address);
+            OsgiDestination d = 
+                (OsgiDestination)servlet.getTransport().getDestinationForPath(ei.getAddress());
+
+            if (d == null) {
+                if (!isHideServiceList && (request.getRequestURI().endsWith(serviceListRelativePath)
+                    || request.getRequestURI().endsWith(serviceListRelativePath + "/"))
+                    || StringUtils.isEmpty(request.getPathInfo())
+                    || "/".equals(request.getPathInfo())) {
+                    updateDests(request);
+                    generateServiceList(request, res);
+                } else {
+                    d = checkRestfulRequest(request);
+                    if (d == null || d.getMessageObserver() == null) {
+                        LOG.warning("Can't find the the request for "
+                                    + request.getRequestURL() + "'s Observer ");
+                        generateNotFound(request, res);
+                    }  else { // the request should be a restful service request
+                        updateDests(request);
+                        invokeDestination(request, res, d);
+                    }
+                }
+            } else {
+                ei = d.getEndpointInfo();
+                Bus bus = d.getBus();
+                if (null != request.getQueryString()
+                    && request.getQueryString().length() > 0
+                    && bus.getExtension(QueryHandlerRegistry.class) != null) {
+
+                    String ctxUri = request.getPathInfo();
+                    String baseUri = request.getRequestURL().toString()
+                        + "?" + request.getQueryString();
+                    // update the EndPoint Address with request url
+                    if ("GET".equals(request.getMethod())) {
+                        updateDests(request);
+                    }
+
+                    for (QueryHandler qh : bus.getExtension(QueryHandlerRegistry.class).getHandlers()) {
+                        if (qh.isRecognizedQuery(baseUri, ctxUri, ei)) {
+
+                            res.setContentType(qh.getResponseContentType(baseUri, ctxUri));
+                            OutputStream out = res.getOutputStream();
+                            try {
+                                qh.writeResponse(baseUri, ctxUri, ei, out);
+                                out.flush();
+                                return;
+                            } catch (Exception e) {
+                                LOG.warning(qh.getClass().getName()
+                                    + " Exception caught writing response: "
+                                    + e.getMessage());
+                                throw new ServletException(e);
+                            }
+                        }
+                    }
+                } 
+                invokeDestination(request, res, d);
+                
+            }
+        } catch (IOException e) {
+            throw new ServletException(e);
+        }
+    }
+
+    private OsgiDestination checkRestfulRequest(HttpServletRequest request) throws IOException {
+
+        String address = request.getPathInfo() == null ? "" : request.getPathInfo();
+
+        for (String path : servlet.getTransport().getDestinationsPaths()) {
+            if (address.startsWith(path)) {
+                return servlet.getTransport().getDestinationForPath(path);
+            }
+        }
+        return null;
+    }
+
+    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<OsgiDestination> destinations = servlet.getTransport().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<OsgiDestination> 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 (OsgiDestination 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<OsgiDestination> destinations)
+        throws IOException {
+        
+        List<OsgiDestination> restfulDests = new ArrayList<OsgiDestination>();
+        for (OsgiDestination 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 (OsgiDestination 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>");
+    }
+
+    public void invokeDestination(final HttpServletRequest request, 
+                                  HttpServletResponse response, 
+                                  OsgiDestination d) throws ServletException {
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Service http request on thread: " + Thread.currentThread());
+        }
+
+        try {
+            MessageImpl inMessage = servlet.createInMessage();
+            inMessage.setContent(InputStream.class, request.getInputStream());
+            inMessage.put(AbstractHTTPDestination.HTTP_REQUEST, request);
+            inMessage.put(AbstractHTTPDestination.HTTP_RESPONSE, response);
+            inMessage.put(AbstractHTTPDestination.HTTP_CONTEXT, 
+                          servletConfig == null ? null : servletConfig.getServletContext());
+            inMessage.put(AbstractHTTPDestination.HTTP_CONFIG, servletConfig);
+            inMessage.put(Message.HTTP_REQUEST_METHOD, request.getMethod());
+            inMessage.put(Message.REQUEST_URI, request.getRequestURI());
+            inMessage.put(Message.PATH_INFO, request.getPathInfo());
+            inMessage.put(Message.QUERY_STRING, request.getQueryString());
+            inMessage.put(Message.CONTENT_TYPE, request.getContentType());
+            inMessage.put(Message.ACCEPT_CONTENT_TYPE, request.getHeader("Accept"));
+            inMessage.put(Message.BASE_PATH, d.getAddress().getAddress().getValue());
+            inMessage.put(SecurityContext.class, new SecurityContext() {
+                public Principal getUserPrincipal() {
+                    return request.getUserPrincipal();
+                }
+                public boolean isUserInRole(String role) {
+                    return request.isUserInRole(role);
+                }
+            });
+
+            // work around a bug with Jetty which results in the character
+            // encoding not being trimmed correctly.
+            String enc = request.getCharacterEncoding();
+            if (enc != null && enc.endsWith("\"")) {
+                enc = enc.substring(0, enc.length() - 1);
+            }
+
+            String normalizedEncoding = HttpHeaderHelper.mapCharset(enc);
+            if (normalizedEncoding == null) {
+                String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG",
+                                                                  LOG, enc).toString();
+                LOG.log(Level.WARNING, m);
+                throw new IOException(m);
+            }
+
+            inMessage.put(Message.ENCODING, normalizedEncoding);
+            SSLUtils.propogateSecureSession(request, inMessage);
+
+            ExchangeImpl exchange = servlet.createExchange();
+            exchange.setInMessage(inMessage);
+            exchange.setSession(new HTTPSession(request));
+
+            d.doMessage(inMessage);
+        } catch (IOException e) {
+            throw new ServletException(e);
+        }
+
+    }
+
+    
+}

Propchange: cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java?rev=822228&r1=822227&r2=822228&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java (original)
+++ cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java Tue Oct  6 11:50:57 2009
@@ -47,5 +47,9 @@
         }
         return d;
     }
+    
+    public void init() {
+        
+    }
 
 }

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=822228&r1=822227&r2=822228&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 Tue Oct  6 11:50:57 2009
@@ -28,6 +28,7 @@
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
 import javax.servlet.ServletInputStream;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
@@ -40,6 +41,8 @@
 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.MessageObserver;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 import org.apache.cxf.transport.http.HTTPSession;
@@ -47,7 +50,6 @@
 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;
 
@@ -68,14 +70,11 @@
     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 static final String HEADER = "<html><body>";
-    private static final String SERVICE = "<p> <a href=\"" + ADDRESS + "?wsdl\">";
-    private static final String NAME = QNAME.toString() + "</a> </p>";
-    private static final String FOOTER = "</body></html>";
     private IMocksControl control; 
     private Bus bus;
     private OsgiDestinationRegistryIntf registry;
@@ -108,6 +107,10 @@
         endpoint = new EndpointInfo();
         endpoint.setAddress(ADDRESS);
         endpoint.setName(QNAME);
+        ServiceInfo service = new ServiceInfo();
+        service.setInterface(new InterfaceInfo(service, QNAME));
+        endpoint.setService(service);
+        
         paths = new TreeSet<String>();
     }
 
@@ -145,7 +148,9 @@
     @Test
     public void testInvokeGetServices() throws Exception {
         setUpRequest(SERVICES, null, 1);
-        setUpResponse(0, TEXT, HEADER, SERVICE, NAME, FOOTER);
+        setUpResponse(0, TEXT_LIST, 
+                      "<span class=\"field\">Endpoint address:</span> "
+                      + "<span class=\"value\">" + ADDRESS + "</span>");
 
         control.replay();
 
@@ -159,7 +164,8 @@
     @Test
     public void testInvokeGetServicesNoService() throws Exception {
         setUpRequest(SERVICES, null, 0);
-        setUpResponse(0, TEXT, HEADER, FOOTER);
+        setUpResponse(0, TEXT_LIST, 
+                      "<span class=\"heading\">No services have been found.</span>");
 
         control.replay();
 
@@ -329,7 +335,7 @@
     }
 
     private OsgiServlet setUpServlet() { 
-        return new OsgiServlet(registry) {
+        OsgiServlet servlet = new OsgiServlet(registry) {
             public ServletContext getServletContext() {
                 return context;
             }
@@ -343,5 +349,11 @@
                 return exchange;
             }            
         };
+        try {
+            servlet.init(config);
+        } catch (ServletException ex) {
+            // ignore
+        }
+        return servlet;
     }
 }

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=822228&r1=822227&r2=822228&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 Tue Oct  6 11:50:57 2009
@@ -18,19 +18,13 @@
  */
 package org.apache.cxf.transport.servlet;
 
-import java.io.IOException;
 import java.lang.ref.WeakReference;
-import java.util.Arrays;
 import java.util.Hashtable;
-import java.util.List;
 import java.util.Map;
 import java.util.logging.Logger;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -43,17 +37,11 @@
 
 
 
-public abstract class AbstractCXFServlet extends HttpServlet {
+public abstract class AbstractCXFServlet extends AbstractHTTPServlet {
     
     static final Map<String, WeakReference<Bus>> BUS_MAP = new Hashtable<String, WeakReference<Bus>>();
     static final Logger LOG = getLogger();
     
-    /**
-     * List of well-known HTTP 1.1 verbs, with POST and GET being the most used verbs at the top 
-     */
-    private static final List<String> KNOWN_HTTP_VERBS = 
-        Arrays.asList(new String[]{"POST", "GET", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE"});
-    
     protected Bus bus;
     protected ServletTransportFactory servletTransportFactory;
     protected ServletController controller;
@@ -147,73 +135,7 @@
         BUS_MAP.remove(s);
         bus.shutdown(true);
     }
-    
-    protected void doPost(HttpServletRequest request, HttpServletResponse response) 
-        throws ServletException {
-        invoke(request, response);
-    }
-
-    protected void doGet(HttpServletRequest request, HttpServletResponse response) 
-        throws ServletException {
-        invoke(request, response);
-    }
-
-    @Override
-    protected void doDelete(HttpServletRequest request, HttpServletResponse response)
-        throws ServletException, IOException {
-        invoke(request, response);
-    }
-
-    @Override
-    protected void doPut(HttpServletRequest request, HttpServletResponse response) 
-        throws ServletException, IOException {
-        invoke(request, response);
-    }
-    
-    @Override
-    protected void doHead(HttpServletRequest request, HttpServletResponse response) 
-        throws ServletException, IOException {
-        invoke(request, response);
-    }
-    
-    @Override
-    protected void doOptions(HttpServletRequest request, HttpServletResponse response) 
-        throws ServletException, IOException {
-        invoke(request, response);
-    }
-    
-    
-    
-    /**
-     * {@inheritDoc}
-     * 
-     * javax.http.servlet.HttpServlet does not let to override the code which deals with
-     * unrecognized HTTP verbs such as PATCH (being standardized), WebDav ones, etc.
-     * Thus we let CXF servlets process unrecognized HTTP verbs directly, otherwise we delegate
-     * to HttpService  
-     */
-    @Override
-    public void service(ServletRequest req, ServletResponse res)
-        throws ServletException, IOException {
-        
-        HttpServletRequest      request;
-        HttpServletResponse     response;
         
-        try {
-            request = (HttpServletRequest) req;
-            response = (HttpServletResponse) res;
-        } catch (ClassCastException e) {
-            throw new ServletException("Unrecognized HTTP request or response object");
-        }
-        
-        String method = request.getMethod();
-        if (KNOWN_HTTP_VERBS.contains(method)) {
-            super.service(request, response);
-        } else {
-            invoke(request, response);
-        }
-    }
-    
     protected void invoke(HttpServletRequest request, HttpServletResponse response) throws ServletException {
         try {
             BusFactory.setThreadDefaultBus(getBus());

Added: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java?rev=822228&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java (added)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java Tue Oct  6 11:50:57 2009
@@ -0,0 +1,110 @@
+/**
+ * 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;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+
+public abstract class AbstractHTTPServlet extends HttpServlet {
+    
+    /**
+     * List of well-known HTTP 1.1 verbs, with POST and GET being the most used verbs at the top 
+     */
+    private static final List<String> KNOWN_HTTP_VERBS = 
+        Arrays.asList(new String[]{"POST", "GET", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE"});
+    
+    
+    protected void doPost(HttpServletRequest request, HttpServletResponse response) 
+        throws ServletException {
+        invoke(request, response);
+    }
+
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) 
+        throws ServletException {
+        invoke(request, response);
+    }
+
+    @Override
+    protected void doDelete(HttpServletRequest request, HttpServletResponse response)
+        throws ServletException, IOException {
+        invoke(request, response);
+    }
+
+    @Override
+    protected void doPut(HttpServletRequest request, HttpServletResponse response) 
+        throws ServletException, IOException {
+        invoke(request, response);
+    }
+    
+    @Override
+    protected void doHead(HttpServletRequest request, HttpServletResponse response) 
+        throws ServletException, IOException {
+        invoke(request, response);
+    }
+    
+    @Override
+    protected void doOptions(HttpServletRequest request, HttpServletResponse response) 
+        throws ServletException, IOException {
+        invoke(request, response);
+    }
+    
+    /**
+     * {@inheritDoc}
+     * 
+     * javax.http.servlet.HttpServlet does not let to override the code which deals with
+     * unrecognized HTTP verbs such as PATCH (being standardized), WebDav ones, etc.
+     * Thus we let CXF servlets process unrecognized HTTP verbs directly, otherwise we delegate
+     * to HttpService  
+     */
+    @Override
+    public void service(ServletRequest req, ServletResponse res)
+        throws ServletException, IOException {
+        
+        HttpServletRequest      request;
+        HttpServletResponse     response;
+        
+        try {
+            request = (HttpServletRequest) req;
+            response = (HttpServletResponse) res;
+        } catch (ClassCastException e) {
+            throw new ServletException("Unrecognized HTTP request or response object");
+        }
+        
+        String method = request.getMethod();
+        if (KNOWN_HTTP_VERBS.contains(method)) {
+            super.service(request, response);
+        } else {
+            invoke(request, response);
+        }
+    }
+    
+    protected abstract void invoke(HttpServletRequest request, HttpServletResponse response) 
+        throws ServletException;
+
+}

Propchange: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 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=822228&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractServletController.java (added)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractServletController.java Tue Oct  6 11:50:57 2009
@@ -0,0 +1,125 @@
+/**
+ * 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;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cxf.common.util.UrlUtils;
+
+public abstract class AbstractServletController {
+    
+    protected static final String DEFAULT_LISTINGS_CLASSIFIER = "/services";
+    protected boolean isHideServiceList;
+    protected boolean disableAddressUpdates;
+    protected String forcedBaseAddress;
+    protected String serviceListStyleSheet;
+    protected String serviceListRelativePath = DEFAULT_LISTINGS_CLASSIFIER;
+    protected ServletConfig servletConfig;
+    
+    protected AbstractServletController() {
+        
+    }
+    
+    protected AbstractServletController(ServletConfig config) {
+        this.servletConfig = config;
+        init();
+    }
+    
+    public void setHideServiceList(boolean generate) {
+        isHideServiceList = generate;
+    }
+    
+    public void setServiceListRelativePath(String relativePath) {
+        serviceListRelativePath = relativePath;
+    }
+    
+    public void setDisableAddressUpdates(boolean noupdates) {
+        disableAddressUpdates = noupdates;
+    }
+    public void setForcedBaseAddress(String s) {
+        forcedBaseAddress = s;
+    }
+    public void setServiceListStyleSheet(String serviceListStyleSheet) {
+        this.serviceListStyleSheet = serviceListStyleSheet;
+    }
+    
+    private void init() {
+        if (servletConfig == null) {
+            return;
+        }
+        
+        String hideServiceList = servletConfig.getInitParameter("hide-service-list-page");
+        if (hideServiceList != null) {
+            isHideServiceList = Boolean.valueOf(hideServiceList);
+        }
+        String isDisableAddressUpdates = servletConfig.getInitParameter("disable-address-updates");
+        if (isDisableAddressUpdates != null) {
+            disableAddressUpdates = Boolean.valueOf(isDisableAddressUpdates);
+        }
+        String isForcedBaseAddress = servletConfig.getInitParameter("base-address");
+        if (isForcedBaseAddress != null) {
+            forcedBaseAddress = isForcedBaseAddress;
+        }
+        String serviceListTransform = servletConfig.getInitParameter("service-list-stylesheet");
+        if (serviceListTransform != null) {
+            serviceListStyleSheet = serviceListTransform;
+        }
+        String serviceListPath = servletConfig.getInitParameter("service-list-path");
+        if (serviceListPath != null) {
+            serviceListRelativePath = serviceListPath;
+        }
+    }
+    
+    protected String getBaseURL(HttpServletRequest request) {
+        String reqPrefix = request.getRequestURL().toString();        
+        String pathInfo = request.getPathInfo() == null ? "" : request.getPathInfo();
+        //fix for CXF-898
+        if (!"/".equals(pathInfo) || reqPrefix.endsWith("/")) {
+            // needs to be done given that pathInfo is decoded
+            // TODO : it's unlikely servlet path will contain encoded values so we're most 
+            // likely safe however we need to ensure if it happens then this code works properly too
+            reqPrefix = UrlUtils.pathDecode(reqPrefix);
+            // pathInfo drops matrix parameters attached to a last path segment
+            int offset = 0;
+            int index = getMatrixParameterIndex(reqPrefix, pathInfo);
+            if (index >= pathInfo.length()) {
+                offset = reqPrefix.length() - index;
+            }
+            reqPrefix = reqPrefix.substring(0, reqPrefix.length() - pathInfo.length() - offset);
+        }
+        return reqPrefix;
+    }
+    
+    private int getMatrixParameterIndex(String reqPrefix, String pathInfo) {
+        int index = reqPrefix.lastIndexOf(';');
+        int lastIndex = -1;
+        while (index >= pathInfo.length()) {
+            lastIndex = index;
+            reqPrefix = reqPrefix.substring(0, index);
+            if (reqPrefix.endsWith(pathInfo)) {
+                break;
+            }
+            index = reqPrefix.lastIndexOf(';');
+        }
+        return lastIndex;
+    }
+   
+}

Propchange: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractServletController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractServletController.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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=822228&r1=822227&r2=822228&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 Tue Oct  6 11:50:57 2009
@@ -39,7 +39,6 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.common.util.UrlUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -48,55 +47,30 @@
 import org.apache.cxf.transports.http.QueryHandlerRegistry;
 import org.apache.cxf.wsdl.http.AddressType;
 
-public class ServletController {
+public class ServletController extends AbstractServletController {
     
     private static final Logger LOG = LogUtils.getL7dLogger(ServletController.class);
-    private static final String DEFAULT_LISTINGS_CLASSIFIER = "/services";
     
     private ServletTransportFactory transport;
     private ServletContext servletContext;
     private ServletConfig servletConfig;
     private Bus bus;
     private String lastBase = "";
-    private boolean isHideServiceList;
-    private boolean disableAddressUpdates;
-    private String forcedBaseAddress;
-    private String serviceListStyleSheet;
-    private String serviceListRelativePath = DEFAULT_LISTINGS_CLASSIFIER;
- 
+    
     public ServletController(ServletTransportFactory df,
                              ServletConfig config,
                              ServletContext context, 
                              Bus b) {
+        super(config);
         this.transport = df;
         this.servletConfig = config;
         this.servletContext = context;
         this.bus = b;
-        init();
     }
     
     ServletController() {
-        
     }
         
-    public void setHideServiceList(boolean generate) {
-        isHideServiceList = generate;
-    }
-    
-    public void setServiceListRelativePath(String relativePath) {
-        serviceListRelativePath = relativePath;
-    }
-    
-    public void setDisableAddressUpdates(boolean noupdates) {
-        disableAddressUpdates = noupdates;
-    }
-    public void setForcedBaseAddress(String s) {
-        forcedBaseAddress = s;
-    }
-    public void setServiceListStyleSheet(String serviceListStyleSheet) {
-        this.serviceListStyleSheet = serviceListStyleSheet;
-    }
-    
     String getLastBaseURL() {
         return lastBase;
     }
@@ -402,40 +376,6 @@
         }
     }
     
-    protected String getBaseURL(HttpServletRequest request) {
-        String reqPrefix = request.getRequestURL().toString();        
-        String pathInfo = request.getPathInfo() == null ? "" : request.getPathInfo();
-        //fix for CXF-898
-        if (!"/".equals(pathInfo) || reqPrefix.endsWith("/")) {
-            // needs to be done given that pathInfo is decoded
-            // TODO : it's unlikely servlet path will contain encoded values so we're most 
-            // likely safe however we need to ensure if it happens then this code works properly too
-            reqPrefix = UrlUtils.pathDecode(reqPrefix);
-            // pathInfo drops matrix parameters attached to a last path segment
-            int offset = 0;
-            int index = getMatrixParameterIndex(reqPrefix, pathInfo);
-            if (index >= pathInfo.length()) {
-                offset = reqPrefix.length() - index;
-            }
-            reqPrefix = reqPrefix.substring(0, reqPrefix.length() - pathInfo.length() - offset);
-        }
-        return reqPrefix;
-    }
-    
-    private int getMatrixParameterIndex(String reqPrefix, String pathInfo) {
-        int index = reqPrefix.lastIndexOf(';');
-        int lastIndex = -1;
-        while (index >= pathInfo.length()) {
-            lastIndex = index;
-            reqPrefix = reqPrefix.substring(0, index);
-            if (reqPrefix.endsWith(pathInfo)) {
-                break;
-            }
-            index = reqPrefix.lastIndexOf(';');
-        }
-        return lastIndex;
-    }
-
     protected void generateNotFound(HttpServletRequest request, HttpServletResponse res) throws IOException {
         res.setStatus(404);
         res.setContentType("text/html");
@@ -460,29 +400,4 @@
 
     }
     
-    private void init() {
-        
-        transport.setServletController(this);
-        
-        String hideServiceList = servletConfig.getInitParameter("hide-service-list-page");
-        if (hideServiceList != null) {
-            isHideServiceList = Boolean.valueOf(hideServiceList);
-        }
-        String isDisableAddressUpdates = servletConfig.getInitParameter("disable-address-updates");
-        if (isDisableAddressUpdates != null) {
-            disableAddressUpdates = Boolean.valueOf(isDisableAddressUpdates);
-        }
-        String isForcedBaseAddress = servletConfig.getInitParameter("base-address");
-        if (isForcedBaseAddress != null) {
-            forcedBaseAddress = isForcedBaseAddress;
-        }
-        String serviceListTransform = servletConfig.getInitParameter("service-list-stylesheet");
-        if (serviceListTransform != null) {
-            serviceListStyleSheet = serviceListTransform;
-        }
-        String serviceListPath = servletConfig.getInitParameter("service-list-path");
-        if (serviceListPath != null) {
-            serviceListRelativePath = serviceListPath;
-        }
-    }
 }

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java?rev=822228&r1=822227&r2=822228&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java Tue Oct  6 11:50:57 2009
@@ -32,7 +32,6 @@
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 import org.apache.cxf.transport.http.HTTPSession;
 
@@ -108,8 +107,4 @@
         super.shutdown();
     }
     
-    public MessageObserver getMessageObserver() {
-        return this.incomingObserver;
-    }
-    
 }



Mime
View raw message