cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r539515 - in /incubator/cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/ systests/src/test/java/org/...
Date Fri, 18 May 2007 16:37:52 GMT
Author: jliu
Date: Fri May 18 09:37:42 2007
New Revision: 539515

URL: http://svn.apache.org/viewvc?view=rev&rev=539515
Log:
support configure jax-ws handlers throw configuration file per port.

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/handler/AnnotationHandlerChainBuilder.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/handlers.xml
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/handlers_invocation.xml
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/handler_test.wsdl

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=539515&r1=539514&r2=539515
==============================================================================
--- 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
Fri May 18 09:37:42 2007
@@ -352,7 +352,7 @@
         LOG.fine("loading handler chain for endpoint");
         AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder();
 
-        List<Handler> chain = builder.buildHandlerChainFromClass(implementor.getClass());
+        List<Handler> chain = builder.buildHandlerChainFromClass(implementor.getClass(),
endpointName);
         for (Handler h : chain) {
             injectResources(h);
         }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java?view=diff&rev=539515&r1=539514&r2=539515
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
Fri May 18 09:37:42 2007
@@ -31,6 +31,7 @@
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.Handler;
 
@@ -57,7 +58,8 @@
      * @param existingHandlers
      * @return
      */
-    public List<Handler> buildHandlerChainFromClass(Class<?> clz, List<Handler>
existingHandlers) {
+    public List<Handler> buildHandlerChainFromClass(Class<?> clz, List<Handler>
existingHandlers,
+                                                    QName endpointName) {
         LOG.fine("building handler chain");
         HandlerChainAnnotation hcAnn = findHandlerChainAnnotation(clz, true);
         List<Handler> chain = null;
@@ -83,7 +85,17 @@
                 
                 chain = new ArrayList<Handler>();
                 for (HandlerChainType hc : handlerChainsType.getHandlerChain()) {
-                    chain.addAll(buildHandlerChain(hc, clz.getClassLoader()));
+                    //Only add handlers if <port-name-pattern> is not presented or
is matched.
+                    //TODO: match the namespace, match the wild card etc. JSR-181, Appendix
B. 
+                    if (hc.getPortNamePattern() != null && endpointName != null)
{
+                        String portNamePattern = hc.getPortNamePattern();
+                        String localPart = portNamePattern.substring(portNamePattern.indexOf(':')
+ 1,
+                                                                     portNamePattern.length());
+                        if (!localPart.equals(endpointName.getLocalPart())) {
+                            continue;
+                        }
+                    }
+                    chain.addAll(buildHandlerChain(hc, clz.getClassLoader()));          
         
                 }
 
             } catch (Exception e) {
@@ -101,10 +113,14 @@
         return clazz.getResource(name);
     }
 
-    public List<Handler> buildHandlerChainFromClass(Class<?> clz) {
-        return buildHandlerChainFromClass(clz, null);
+    public List<Handler> buildHandlerChainFromClass(Class<?> clz, QName endpointName)
{
+        return buildHandlerChainFromClass(clz, null, endpointName);
     }
 
+    public List<Handler> buildHandlerChainFromClass(Class<?> clz) {
+        return buildHandlerChainFromClass(clz, null, null);
+    }
+    
     private HandlerChainAnnotation findHandlerChainAnnotation(Class<?> clz, boolean
searchSEI) {        
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Checking for HandlerChain annotation on " + clz.getName());

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java?view=diff&rev=539515&r1=539514&r2=539515
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java
Fri May 18 09:37:42 2007
@@ -24,6 +24,7 @@
 
 import javax.jws.HandlerChain;
 import javax.jws.WebService;
+import javax.xml.namespace.QName;
 import javax.xml.ws.handler.Handler;
 import javax.xml.ws.handler.LogicalHandler;
 import javax.xml.ws.handler.MessageContext;
@@ -40,12 +41,24 @@
         AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder();
         List<Handler> handlers = chainBuilder.buildHandlerChainFromClass(handlerTestImpl.getClass());
         assertNotNull(handlers);
-        assertEquals(3, handlers.size());
+        assertEquals(5, handlers.size());
         assertEquals(TestLogicalHandler.class, handlers.get(0).getClass());
         assertEquals(TestLogicalHandler.class, handlers.get(1).getClass());
-        assertEquals(TestProtocolHandler.class, handlers.get(2).getClass());
+        assertEquals(TestLogicalHandler.class, handlers.get(2).getClass());
+        assertEquals(TestLogicalHandler.class, handlers.get(3).getClass());
+        assertEquals(TestProtocolHandler.class, handlers.get(4).getClass());
+    }    
+    
+    public void testFindHandlerChainAnnotationPerPort() {
+        HandlerTestImpl handlerTestImpl = new HandlerTestImpl();
+        AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder();
+        QName portName = new QName("namespacedoesntsupportyet", "SoapPort1");
+        List<Handler> handlers = chainBuilder
+            .buildHandlerChainFromClass(handlerTestImpl.getClass(), portName);
+        assertNotNull(handlers);
+        assertEquals(5, handlers.size());
     }
-
+    
     public static class TestLogicalHandler implements LogicalHandler {
         Map config;
         boolean initCalled;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/handlers.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/handlers.xml?view=diff&rev=539515&r1=539514&r2=539515
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/handlers.xml
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/handlers.xml
Fri May 18 09:37:42 2007
@@ -50,4 +50,24 @@
 		</init-param>
 	</handler>
     </handler-chain>
+    
+    
+    <handler-chain>
+		<port-name-pattern
+			xmlns:ns1="http://apache.org/handler_test">
+			ns1:SoapPort1
+		</port-name-pattern>
+		<handler>
+			<handler-name>Handler1</handler-name>
+			<handler-class>
+				org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilderTest$TestLogicalHandler
+			</handler-class>
+		</handler>
+		<handler>
+			<handler-name>Handler2</handler-name>
+			<handler-class>
+				org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilderTest$TestLogicalHandler
+			</handler-class>
+		</handler>
+	</handler-chain>
 </handler-chains>

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/handlers_invocation.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/handlers_invocation.xml?view=diff&rev=539515&r1=539514&r2=539515
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/handlers_invocation.xml
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/handlers_invocation.xml
Fri May 18 09:37:42 2007
@@ -1,45 +1,95 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-  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
+	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.
+-->
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
+	xmlns:cfg="http://cxf.apache.org/configuration/cfg"
+	xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee">
+	
+	<!-- ====================== -->
+	<!-- service based handlers -->
+	<!-- ====================== -->
+	<handler-chain>
+		<handler>
+			<handler-name>Handler1</handler-name>
+			<handler-class>
+				org.apache.cxf.systest.handlers.TestHandler
+			</handler-class>
+		</handler>
+		<handler>
+			<handler-name>Handler2</handler-name>
+			<handler-class>
+				org.apache.cxf.systest.handlers.TestHandler
+			</handler-class>
+		</handler>
+	</handler-chain>
 
-  http://www.apache.org/licenses/LICENSE-2.0
+	<!-- ====================== -->
+	<!-- port based handlers    -->
+	<!-- ====================== -->
+	<!-- ++++++++++++++++++++++ -->
+	<!-- first port -->
+	<!-- ++++++++++++++++++++++ -->
+	<handler-chain>
+		<port-name-pattern
+			xmlns:ns1="http://apache.org/handler_test">
+			ns1:SoapPort
+		</port-name-pattern>
+		<handler>
+			<handler-name>ProtocolHandler1</handler-name>
+			<handler-class>
+				org.apache.cxf.systest.handlers.TestSOAPHandler
+			</handler-class>
+		</handler>
+		<handler>
+			<handler-name>ProtocolHandler2</handler-name>
+			<handler-class>
+				org.apache.cxf.systest.handlers.TestSOAPHandler
+			</handler-class>
+		</handler>
+	</handler-chain>
+	
+	<!-- ====================== -->
+	<!-- port based handlers    -->
+	<!-- ====================== -->
+	<!-- ++++++++++++++++++++++ -->
+	<!-- second port -->
+	<!-- ++++++++++++++++++++++ -->
+	<handler-chain>
+		<port-name-pattern
+			xmlns:ns1="http://apache.org/handler_test">
+			ns1:SoapPort1
+		</port-name-pattern>
+		<handler>
+			<handler-name>Handler1</handler-name>
+			<handler-class>
+				org.apache.cxf.systest.handlers.TestHandler
+			</handler-class>
+		</handler>
+		<handler>
+			<handler-name>ProtocolHandler2</handler-name>
+			<handler-class>
+				org.apache.cxf.systest.handlers.TestSOAPHandler
+			</handler-class>
+		</handler>
+	</handler-chain>
+</handler-chains>
 
-  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.
--->
-<handler-chains xmlns="http://java.sun.com/xml/ns/javaee" 
-xmlns:cfg="http://cxf.apache.org/configuration/cfg" 
-xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
-xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
-xsi:schemaLocation="http://java.sun.com/xml/ns/javaee">
-    <handler-chain>
-        <handler>
-		<handler-name>Handler1</handler-name>
-		<handler-class>org.apache.cxf.systest.handlers.TestHandler</handler-class>
-	</handler>
-        <handler>
-		<handler-name>Handler2</handler-name>
-		<handler-class>org.apache.cxf.systest.handlers.TestHandler</handler-class>
-	</handler>
-        <handler>
-		<handler-name>ProtocolHandler1</handler-name>
-		<handler-class>org.apache.cxf.systest.handlers.TestSOAPHandler</handler-class>
-	</handler>
-        <handler>
-		<handler-name>ProtocolHandler2</handler-name>
-		<handler-class>org.apache.cxf.systest.handlers.TestSOAPHandler</handler-class>
-	</handler>
-    </handler-chain>
-</handler-chains>    
-    
 

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/handler_test.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/handler_test.wsdl?view=diff&rev=539515&r1=539514&r2=539515
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/handler_test.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/handler_test.wsdl Fri May 18 09:37:42
2007
@@ -88,6 +88,11 @@
             <wsdl:fault  message="tns:PingException" name="PingException"/>
         </wsdl:operation>
     </wsdl:portType>
+    <wsdl:portType name="HandlerTest1">
+        <wsdl:operation name="pingOneWay1">
+            <wsdl:input message="tns:pingOneWayRequest" name="pingOneWayRequest1"/>
+        </wsdl:operation>
+    </wsdl:portType>
     <wsdl:binding name="HandlerTest_SOAPBinding" type="tns:HandlerTest">
         <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
         <wsdl:operation name="ping">
@@ -118,9 +123,21 @@
             </wsdl:fault>
         </wsdl:operation>
     </wsdl:binding>
+     <wsdl:binding name="HandlerTest_SOAPBinding1" type="tns:HandlerTest1">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="pingOneWay1">
+            <soap:operation soapAction="" style="document"/>
+            <wsdl:input name="pingOneWayRequest1">
+                <soap:body use="literal"/>
+            </wsdl:input>
+        </wsdl:operation>
+    </wsdl:binding>   
     <wsdl:service name="HandlerTestService">
         <wsdl:port binding="tns:HandlerTest_SOAPBinding" name="SoapPort">
             <soap:address location="http://localhost:9005/HandlerTest/SoapPort"/>
+        </wsdl:port>
+       <wsdl:port binding="tns:HandlerTest_SOAPBinding1" name="SoapPort1">
+            <soap:address location="http://localhost:9005/HandlerTest/SoapPort1"/>
         </wsdl:port>
     </wsdl:service>
 </wsdl:definitions>



Mime
View raw message