You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2013/07/22 17:33:17 UTC

svn commit: r1505719 - in /cxf/branches/2.7.x-fixes: ./ rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/

Author: sergeyb
Date: Mon Jul 22 15:33:17 2013
New Revision: 1505719

URL: http://svn.apache.org/r1505719
Log:
Merged revisions 1505717 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1505717 | sergeyb | 2013-07-22 16:25:52 +0100 (Mon, 22 Jul 2013) | 1 line
  
  [CXF-5144] Reusing the original ServletConfig reference
........

Added:
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/SpringServletConfigStore.java
      - copied unchanged from r1505717, cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/SpringServletConfigStore.java
Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/web.xml

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1505717

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

Modified: cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java?rev=1505719&r1=1505718&r2=1505719&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java (original)
+++ cxf/branches/2.7.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java Mon Jul 22 15:33:17 2013
@@ -22,10 +22,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Method;
 import java.util.Collection;
-import java.util.Enumeration;
 
 import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 
 import org.apache.cxf.Bus;
@@ -50,18 +48,18 @@ public class CXFServlet extends CXFNonSp
     }
 
     @Override
-    protected void loadBus(ServletConfig sc) {
+    protected void loadBus(ServletConfig servletConfig) {
         ApplicationContext wac = WebApplicationContextUtils.
-            getWebApplicationContext(sc.getServletContext());
+            getWebApplicationContext(servletConfig.getServletContext());
         
         if (wac instanceof AbstractApplicationContext) {
             addListener((AbstractApplicationContext)wac);
         }
         
-        String configLocation = sc.getInitParameter("config-location");
+        String configLocation = servletConfig.getInitParameter("config-location");
         if (configLocation == null) {
             try {
-                InputStream is = sc.getServletContext().getResourceAsStream("/WEB-INF/cxf-servlet.xml");
+                InputStream is = servletConfig.getServletContext().getResourceAsStream("/WEB-INF/cxf-servlet.xml");
                 if (is != null && is.available() > 0) {
                     is.close();
                     configLocation = "/WEB-INF/cxf-servlet.xml";
@@ -71,7 +69,7 @@ public class CXFServlet extends CXFNonSp
             }
         }
         if (configLocation != null) {
-            wac = createSpringContext(wac, sc.getServletContext(), configLocation);
+            wac = createSpringContext(wac, servletConfig, configLocation);
         }
         if (wac != null) {
             setBus((Bus)wac.getBean("cxf", Bus.class));
@@ -104,24 +102,12 @@ public class CXFServlet extends CXFNonSp
      * @return
      */
     private ApplicationContext createSpringContext(ApplicationContext ctx,
-                                                   final ServletContext sc,
+                                                   ServletConfig servletConfig,
                                                    String location) {
         XmlWebApplicationContext ctx2 = new XmlWebApplicationContext();
         createdContext = ctx2;
-        ctx2.setServletConfig(new ServletConfig() {
-            public String getServletName() {
-                return "CXF";
-            }
-            public ServletContext getServletContext() {
-                return sc;
-            }
-            public String getInitParameter(String name) {
-                return sc.getInitParameter(name);
-            }
-            public Enumeration<String> getInitParameterNames() {
-                return sc.getInitParameterNames();
-            }
-        });
+        
+        ctx2.setServletConfig(servletConfig);
         Resource r = ctx2.getResource(location);
         try {
             InputStream in = r.getInputStream();

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java?rev=1505719&r1=1505718&r2=1505719&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java Mon Jul 22 15:33:17 2013
@@ -83,7 +83,7 @@ public class JAXRSClientServerResourceCr
     @Test
     public void testMultipleRootsWadl() throws Exception {
         List<Element> resourceEls = getWadlResourcesInfo("http://localhost:" + PORT + "/webapp/resources",
-                                                         "http://localhost:" + PORT + "/webapp/resources", 2);
+                                                         "http://localhost:" + PORT + "/webapp/resources", 3);
         String path1 = resourceEls.get(0).getAttribute("path");
         int bookStoreInd = path1.contains("/bookstore") ? 0 : 1;
         int petStoreInd = bookStoreInd == 0 ? 1 : 0;
@@ -149,6 +149,17 @@ public class JAXRSClientServerResourceCr
     }
     
     @Test
+    public void testServletConfigInitParam() throws Exception {
+        
+        String endpointAddress =
+            "http://localhost:" + PORT + "/webapp/resources/servlet/config/a"; 
+        WebClient wc = WebClient.create(endpointAddress);
+        wc.accept("text/plain");
+
+        assertEquals("avalue", wc.get(String.class));
+    }
+    
+    @Test
     public void testGetBook123() throws Exception {
         
         String endpointAddress =

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml?rev=1505719&r1=1505718&r2=1505719&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml Mon Jul 22 15:33:17 2013
@@ -32,6 +32,7 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
         <jaxrs:serviceBeans>
             <ref bean="petstore"/>
             <ref bean="bookstore"/>
+            <ref bean="servletconfigstore"/>
         </jaxrs:serviceBeans>
         <jaxrs:providers>
             <bean class="org.apache.cxf.systest.jaxrs.BadgerFishProvider"/>
@@ -40,8 +41,9 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
             <ref bean="plainTextProvider"/>
         </jaxrs:providers>
     </jaxrs:server>
-    <bean id="bookstore" scope="prototype" class="org.apache.cxf.systest.jaxrs.BookStore"/>
-    <bean id="petstore" scope="prototype" class="org.apache.cxf.systest.jaxrs.PetStore"/>
+    <bean id="bookstore" class="org.apache.cxf.systest.jaxrs.BookStore"/>
+    <bean id="petstore" class="org.apache.cxf.systest.jaxrs.PetStore"/>
+    <bean id="servletconfigstore" class="org.apache.cxf.systest.jaxrs.SpringServletConfigStore"/>
     <bean id="exceptionMapper" class="org.apache.cxf.systest.jaxrs.BookExceptionMapper">
         <property name="toHandle" value="true"/>
     </bean>   

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/web.xml?rev=1505719&r1=1505718&r2=1505719&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/web.xml (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/web.xml Mon Jul 22 15:33:17 2013
@@ -32,6 +32,10 @@
 			org.apache.cxf.transport.servlet.CXFServlet
 		</servlet-class>
 		<init-param>
+		      <param-name>a</param-name>
+		      <param-value>avalue</param-value>    
+		</init-param>
+		<init-param>
 		      <param-name>config-location</param-name>
 		      <param-value>/WEB-INF/beans.xml</param-value>    
 		</init-param>