cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r506928 - in /incubator/cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/ rt/transports/http/ rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ sys...
Date Tue, 13 Feb 2007 09:32:30 GMT
Author: ningjiang
Date: Tue Feb 13 01:32:26 2007
New Revision: 506928

URL: http://svn.apache.org/viewvc?view=rev&rev=506928
Log:
[CXF-342] Supporting jaxws:endpoint in CXFServlet , also update the EndpointFactoryBean and
EndpointImpl for setting the wsdlLocation  


Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java
    incubator/cxf/trunk/rt/transports/http/pom.xml
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
    incubator/cxf/trunk/systests/pom.xml
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?view=diff&rev=506928&r1=506927&r2=506928
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
Tue Feb 13 01:32:26 2007
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.jaxws;
 
+import java.net.URL;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Executor;
@@ -85,7 +86,7 @@
     }
     
     @SuppressWarnings("unchecked")
-    public EndpointImpl(Bus b, Object i, String uri) {
+    public EndpointImpl(Bus b, Object i, String uri, URL wsdl) {
         bus = b;
         implementor = i;
         bindingURI = uri;
@@ -98,6 +99,9 @@
             serviceFactory = new JaxWsServiceFactoryBean(implInfo);
         }
         serviceFactory.setBus(bus);
+        if (null != wsdl) {
+            serviceFactory.setWsdlURL(wsdl);
+        }
         service = serviceFactory.create();
         
         configureObject(service);
@@ -110,8 +114,15 @@
             service.setInvoker(new JAXWSMethodInvoker(i));
         }
         
-        doInit = true;
+        doInit = true; 
+    }
+    
+    
+    public EndpointImpl(Bus b, Object i, String uri) {
+        this(b, i, uri, (URL)null);
     }
+   
+   
 
     public EndpointImpl(Bus bus, Object implementor) {
         this(bus, implementor, (String) null);

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java?view=diff&rev=506928&r1=506927&r2=506928
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java
Tue Feb 13 01:32:26 2007
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.jaxws.spring;
 
+import java.net.URL;
 import java.util.Map;
 import java.util.concurrent.Executor;
 
@@ -26,6 +27,7 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.jaxws.support.AbstractJaxWsServiceFactoryBean;
 import org.springframework.beans.BeansException;
@@ -54,7 +56,7 @@
         throws BeansException {
         this.context = c;
     }
-
+   
     public Object getObject() throws Exception {
         if (endpoint != null) {
             return endpoint;
@@ -71,7 +73,13 @@
         }
 
         if (serviceFactory == null) {
-            endpoint = new EndpointImpl(bus, implementor, binding);
+            //TODO support to lookup wsdl from classpath
+            if (null != wsdlLocation && wsdlLocation.length() > 0) {
+                //if wsdl can't be found, we will try to init Endpoint without wsdl
+                URL wsdl = ClassLoaderUtils.getResource(wsdlLocation, this.getClass()); 
              
+                endpoint = new EndpointImpl(bus, implementor, binding, wsdl);
+            }
+            endpoint = new EndpointImpl(bus, implementor, binding);            
         } else {
             endpoint = new EndpointImpl(bus, implementor, serviceFactory);
         }

Modified: incubator/cxf/trunk/rt/transports/http/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/pom.xml?view=diff&rev=506928&r1=506927&r2=506928
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/pom.xml (original)
+++ incubator/cxf/trunk/rt/transports/http/pom.xml Tue Feb 13 01:32:26 2007
@@ -75,8 +75,10 @@
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
         </dependency>
-
-
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+        </dependency>
         <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java?view=diff&rev=506928&r1=506927&r2=506928
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
Tue Feb 13 01:32:26 2007
@@ -64,6 +64,7 @@
     static final String ADDRESS_PERFIX = "http://localhost/services";
     static final Map<String, WeakReference<Bus>> BUS_MAP = new Hashtable<String,
WeakReference<Bus>>();
     static final Logger LOG = Logger.getLogger(CXFServlet.class.getName());
+    static final String JAXWS_ENDPOINT_FACTORY_BEAN = "org.apache.cxf.jaxws.spring.EndpointFactoryBean";
     
     private Bus bus;
     private ServletTransportFactory servletTransportFactory;
@@ -110,16 +111,20 @@
             // If the ctx is null, we need to load the cxf-servlet as default
             if (ctx == null) {
                 bus = new SpringBusFactory().createBus("/META-INF/cxf/cxf-servlet.xml");
+                
             } else {
                 bus = new SpringBusFactory(ctx).createBus();
             }
             
             SpringBusFactory.setDefaultBus(bus);
+            
+            initEndpointsFromContext(ctx);
+             
         }
         if (null != busid) {
             BUS_MAP.put(busid, new WeakReference<Bus>(bus));
         }
-
+                
         replaceDestionFactory();
 
         // Set up the servlet as the default server side destination factory
@@ -128,6 +133,25 @@
         // build endpoints from the web.xml or a config file
         buildEndpoints(servletConfig);
     }
+    
+    // Need to get to know all frontend's endpoint information
+    private void initEndpointsFromContext(ApplicationContext ctx) throws ServletException
{
+        Class factoryClass;        
+        if (null != ctx) {                   
+            try {
+                factoryClass = Class.forName(JAXWS_ENDPOINT_FACTORY_BEAN);
+            } catch (ClassNotFoundException ex) {
+                throw new ServletException(ex);
+            }
+            String[] beans = ctx.getBeanNamesForType(factoryClass);
+            if (null != beans) {
+                for (String bean : beans) {
+                    // just remove the & from the bean's name
+                    ctx.getBean(bean.substring(1));
+                }
+            }
+        }    
+    }
 
     protected void buildEndpoints(ServletConfig servletConfig) throws ServletException {
         String location = servletConfig.getInitParameter("config-location");
@@ -236,7 +260,7 @@
             if (null == publisherName || publisherName.length() == 0) {
                 publisherName = "org.apache.cxf.jaxws.EndpointPublisherImpl";
             }
-            System.out.println("[publisherName] " + publisherName);
+            
             EndpointPublisher publisher = (EndpointPublisher)Class.forName(publisherName).newInstance();
             
             publisher.buildEndpoint(bus, implName, serviceName, url, portName);

Modified: incubator/cxf/trunk/systests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/pom.xml?view=diff&rev=506928&r1=506927&r2=506928
==============================================================================
--- incubator/cxf/trunk/systests/pom.xml (original)
+++ incubator/cxf/trunk/systests/pom.xml Tue Feb 13 01:32:26 2007
@@ -178,11 +178,11 @@
             <artifactId>spring-core</artifactId>
         </dependency>
 
-        <dependency>
+        <!--dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-web</artifactId>
             <scope>test</scope>
-        </dependency>
+        </dependency-->
 
         <dependency>
             <groupId>junit</groupId>

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java?view=diff&rev=506928&r1=506927&r2=506928
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
Tue Feb 13 01:32:26 2007
@@ -38,8 +38,17 @@
             getClass().getResourceAsStream("GreeterMessage.xml"),
             "text/xml; charset=utf-8");
 
+        invokingEndpoint(req);
+        
+        req = new PostMethodWebRequest("http://localhost/services/Greeter1",
+            getClass().getResourceAsStream("GreeterMessage.xml"), "text/xml; charset=utf-8");
+        
+        invokingEndpoint(req);
+    }
+    
+    public void invokingEndpoint(WebRequest req) throws Exception {
+        
         WebResponse response = newClient().getResponse(req);
-
         assertEquals("text/xml", response.getContentType());
         assertEquals("utf-8", response.getCharacterSet());
 
@@ -47,7 +56,6 @@
         assertNotNull(doc);
 
         addNamespace("h", "http://apache.org/hello_world_soap_http/types");
-
         assertValid("/s:Envelope/s:Body", doc);
         assertValid("//h:sayHiResponse", doc);
     }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml?view=diff&rev=506928&r1=506927&r2=506928
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml Tue
Feb 13 01:32:26 2007
@@ -37,5 +37,17 @@
     <property name="address" value="http://localhost/services/Greeter"/>
     <property name="bus" ref="cxf"/>
   </bean>
-
+  
+   <jaxws:endpoint id="endpoint1" 
+              implementor="org.apache.hello_world_soap_http.GreeterImpl"
+              address="http://localhost/services/Greeter1"
+              wsdlLocation="/wsdl/hello_world.wsdl"
+              />
+   
+    <jaxws:endpoint id="endpoint2" 
+              implementor="org.apache.hello_world_soap_http.GreeterImpl"
+              address="http://localhost/services/Greeter2"
+              wsdlLocation="/wsdl/world1.wsdl"
+              />     
+  
 </beans>



Mime
View raw message