cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r822236 - in /cxf/branches/2.2.x-fixes: ./ rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/ rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/ rt/transports/http/src/main/java/org/apache/cxf/t...
Date Tue, 06 Oct 2009 12:13:20 GMT
Author: sergeyb
Date: Tue Oct  6 12:13:19 2009
New Revision: 822236

URL: http://svn.apache.org/viewvc?rev=822236&view=rev
Log:
Merged revisions 822228 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r822228 | sergeyb | 2009-10-06 12:50:57 +0100 (Tue, 06 Oct 2009) | 1 line
  
  Attempting to minimize the code duplication in http and osgi transports, more refactoring
will have to be done later on
........

Added:
    cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
      - copied unchanged from r822228, cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
    cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java
      - copied unchanged from r822228, cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java
    cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractServletController.java
      - copied unchanged from r822228, cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractServletController.java
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java
    cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java
    cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java
    cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java
    cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java
    cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
    cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:822228

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java?rev=822236&r1=822235&r2=822236&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java
Tue Oct  6 12:13:19 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/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java?rev=822236&r1=822235&r2=822236&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java
Tue Oct  6 12:13:19 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();
     }

Modified: cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java?rev=822236&r1=822235&r2=822236&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java
Tue Oct  6 12:13:19 2009
@@ -47,5 +47,9 @@
         }
         return d;
     }
+    
+    public void init() {
+        
+    }
 
 }

Modified: cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java?rev=822236&r1=822235&r2=822236&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java
Tue Oct  6 12:13:19 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/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java?rev=822236&r1=822235&r2=822236&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractCXFServlet.java
Tue Oct  6 12:13:19 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());

Modified: cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java?rev=822236&r1=822235&r2=822236&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
Tue Oct  6 12:13:19 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/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java?rev=822236&r1=822235&r2=822236&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
Tue Oct  6 12:13:19 2009
@@ -33,7 +33,6 @@
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.ConduitInitiator;
-import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 import org.apache.cxf.transport.http.HTTPSession;
 
@@ -110,8 +109,4 @@
         super.shutdown();
     }
     
-    public MessageObserver getMessageObserver() {
-        return this.incomingObserver;
-    }
-    
 }



Mime
View raw message