cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r588283 [10/18] - in /incubator/cxf/branches/jliu: ./ api/ api/src/main/java/org/apache/cxf/databinding/ api/src/main/java/org/apache/cxf/io/ api/src/main/java/org/apache/cxf/message/ api/src/main/java/org/apache/cxf/phase/ api/src/main/jav...
Date Thu, 25 Oct 2007 17:10:56 GMT
Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java Thu Oct 25 10:09:20 2007
@@ -54,7 +54,7 @@
 
     public JaxWsImplementorInfo(Class<?> ic) {
         implementorClass = ic;
-        initialise();
+        initialize();
     }
 
     public Class<?> getSEIClass() {
@@ -253,7 +253,7 @@
         }
         return null;
     }
-    private void initialise() {
+    private void initialize() {
         Class<?> cls = implementorClass;
         while (cls != null) {
             WebService annotation = cls.getAnnotation(WebService.class);

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java Thu Oct 25 10:09:20 2007
@@ -41,6 +41,7 @@
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.service.factory.AbstractServiceConfiguration;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
@@ -243,7 +244,11 @@
         String tns = null;
         String local = null;
         if (param != null) {
-            tns = param.targetNamespace();
+            //if it's a "wrapped" thing, the WebParam namespace is irrelevant
+            //as the generated element has to be in the namespace of the wrapper type
+            if (param.header() || !op.isUnwrapped()) {
+                tns = param.targetNamespace();
+            }
             local = param.name();
         }
         
@@ -308,6 +313,27 @@
     }
 
     @Override
+    public String getResponseWrapperPartName(OperationInfo op, Method method) {
+        method = getDeclaredMethod(method);
+        WebResult webResult = getWebResult(method);
+        if (webResult != null
+            && webResult.header()) {
+            for (int x = 0; x < method.getParameterTypes().length; x++) {
+                WebParam parm = getWebParam(method, x);
+                if (parm != null
+                    && !parm.header()
+                    && parm.mode() != WebParam.Mode.IN) {
+                    return null;
+                }
+            }
+            //all outs are headers, thus it's an empty body part
+            //thus return the default for an empty part of "result"
+            return "result";
+        }
+        return null;
+    }  
+
+    @Override
     public QName getOutParameterName(OperationInfo op, Method method, int paramNumber) {       
         method = getDeclaredMethod(method);
         
@@ -319,7 +345,11 @@
             String tns = null;
             String local = null;
             if (webResult != null) {
-                tns = webResult.targetNamespace();
+                //if it's a "wrapped" thing, the WebResult namespace is irrelevant
+                //as the generated element has to be in the namespace of the wrapper type
+                if (webResult.header() || !op.isUnwrapped()) {
+                    tns = webResult.targetNamespace();
+                }
                 local = webResult.name();
             }
             if (tns == null || tns.length() == 0) {
@@ -414,12 +444,20 @@
     public QName getRequestWrapperName(OperationInfo op, Method method) {
         Method m = getDeclaredMethod(method);
         RequestWrapper rw = m.getAnnotation(RequestWrapper.class);
-        if (rw == null) {
-            return null;
+        String nm = null;
+        String lp = null;
+        if (rw != null) {
+            nm = rw.targetNamespace();
+            lp = rw.localName();
+        }
+        WebMethod meth = m.getAnnotation(WebMethod.class);
+        if (meth != null && StringUtils.isEmpty(lp)) {
+            lp = meth.operationName();
+        }
+        if (StringUtils.isEmpty(nm)) {
+            nm = op.getName().getNamespaceURI();
         }
-        String nm = rw.targetNamespace();
-        String lp = rw.localName();
-        if (nm.length() > 0 && lp.length() > 0) {            
+        if (!StringUtils.isEmpty(nm) && !StringUtils.isEmpty(lp)) {            
             return new QName(nm, lp); 
         } 
         return null;        
@@ -429,15 +467,26 @@
     public QName getResponseWrapperName(OperationInfo op, Method method) {
         Method m = getDeclaredMethod(method);
         ResponseWrapper rw = m.getAnnotation(ResponseWrapper.class);
-        if (rw == null) {
-            return null;
+        String nm = null;
+        String lp = null;
+        if (rw != null) {
+            nm = rw.targetNamespace();
+            lp = rw.localName();
+        }
+        WebMethod meth = m.getAnnotation(WebMethod.class);
+        if (meth != null && StringUtils.isEmpty(lp)) {
+            lp = meth.operationName();
+            if (!StringUtils.isEmpty(lp)) {
+                lp += "Response";
+            }
         }
-        String nm = rw.targetNamespace();
-        String lp = rw.localName();
-        if (nm.length() > 0 && lp.length() > 0) {            
+        if (StringUtils.isEmpty(nm)) {
+            nm = op.getName().getNamespaceURI();
+        }
+        if (!StringUtils.isEmpty(nm) && !StringUtils.isEmpty(lp)) {            
             return new QName(nm, lp); 
         } 
-        return null;      
+        return null;        
     }
     
     

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java Thu Oct 25 10:09:20 2007
@@ -26,12 +26,12 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.logging.Logger;
-
 import javax.wsdl.Operation;
 import javax.xml.namespace.QName;
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Service;
 import javax.xml.ws.Service.Mode;
+import javax.xml.ws.WebServiceFeature;
 
 import org.apache.cxf.binding.AbstractBindingFactory;
 import org.apache.cxf.common.i18n.Message;
@@ -72,6 +72,8 @@
     private JaxWsImplementorInfo implInfo;
 
     private JAXWSMethodDispatcher methodDispatcher;
+    
+    private List<WebServiceFeature> wsFeatures;
 
     public JaxWsServiceFactoryBean() {
         getIgnoredClasses().add(Service.class.getName());
@@ -135,7 +137,7 @@
 
     @Override
     public Endpoint createEndpoint(EndpointInfo ei) throws EndpointException {
-        return new JaxWsEndpointImpl(getBus(), getService(), ei, implInfo);
+        return new JaxWsEndpointImpl(getBus(), getService(), ei, implInfo, wsFeatures);
     }
 
     @Override
@@ -442,5 +444,13 @@
             getServiceConfigurations().add(0, jaxWsConfiguration);
         }
         methodDispatcher = new JAXWSMethodDispatcher(implInfo);
+    }
+
+    public List<WebServiceFeature> getWsFeatures() {
+        return wsFeatures;
+    }
+
+    public void setWsFeatures(List<WebServiceFeature> wsFeatures) {
+        this.wsFeatures = wsFeatures;
     }
 }

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java Thu Oct 25 10:09:20 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.jaxws;
 
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.binding.BindingFactoryManager;
 import org.apache.cxf.binding.soap.SoapBindingFactory;
 import org.apache.cxf.binding.soap.SoapTransportFactory;
@@ -28,6 +29,7 @@
 import org.apache.cxf.wsdl.WSDLManager;
 import org.apache.cxf.wsdl11.WSDLManagerImpl;
 import org.junit.Before;
+import org.junit.BeforeClass;
 
 /**
  * Abstract test which sets up the local transport and soap binding.
@@ -36,6 +38,12 @@
 
     protected LocalTransportFactory localTransport;
 
+    @BeforeClass
+    public static void checkBus() throws Exception {
+        if (BusFactory.getDefaultBus(false) != null) {
+            throw new Exception("Bus was not null!!!  Check cleanup of previously run tests!!!");
+        }
+    }
 
     @Before
     public void setUpBus() throws Exception {

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java Thu Oct 25 10:09:20 2007
@@ -75,11 +75,11 @@
                     + "/xsd:element[@type='ns0:stringArray']", wsdl);
         
         assertValid("/wsdl:definitions/wsdl:message[@name='sayHi']"
-                    + "/wsdl:part[@element='ns1:sayHi'][@name='sayHi']",
+                    + "/wsdl:part[@element='tns:sayHi'][@name='sayHi']",
                     wsdl);
 
         assertValid("/wsdl:definitions/wsdl:message[@name='getGreetingsResponse']"
-                    + "/wsdl:part[@element='ns1:getGreetingsResponse'][@name='getGreetingsResponse']",
+                    + "/wsdl:part[@element='tns:getGreetingsResponse'][@name='getGreetingsResponse']",
                     wsdl);    
 
         assertValid("/wsdl:definitions/wsdl:binding/wsdl:operation[@name='getGreetings']"
@@ -101,10 +101,10 @@
         assertValid("//wsdl:port/wsdlsoap:address[@location='" + address + "']", wsdl);
         assertValid("//wsdl:portType[@name='Hello']", wsdl);
         assertValid("/wsdl:definitions/wsdl:message[@name='sayHi']"
-                    + "/wsdl:part[@element='ns1:sayHi'][@name='parameters']",
+                    + "/wsdl:part[@element='tns:sayHi'][@name='parameters']",
                     wsdl);
         assertValid("/wsdl:definitions/wsdl:message[@name='sayHiResponse']"
-                    + "/wsdl:part[@element='ns1:sayHiResponse'][@name='result']",
+                    + "/wsdl:part[@element='tns:sayHiResponse'][@name='parameters']",
                     wsdl);
         assertValid("//xsd:complexType[@name='sayHi']"
                     + "/xsd:sequence/xsd:element[@name='arg0']",

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java Thu Oct 25 10:09:20 2007
@@ -55,6 +55,7 @@
         ServerFactoryBean svrFactory = new ServerFactoryBean();
         svrFactory.setBus(bus);
         svrFactory.setServiceFactory(bean);
+        svrFactory.setServiceBean(clazz.newInstance());
         svrFactory.setAddress(address);
         svrFactory.create();
         

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java Thu Oct 25 10:09:20 2007
@@ -68,6 +68,31 @@
         
     }
     
+    @Test
+    public void testEndpointStop() throws Exception {   
+        GreeterImpl greeter = new GreeterImpl();
+        EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null);
+ 
+        WebServiceContext ctx = greeter.getContext();
+        assertNull(ctx);
+        try {
+            String address = "http://localhost:8080/test";
+            endpoint.publish(address);
+        } catch (IllegalArgumentException ex) {
+            assertTrue(ex.getCause() instanceof BusException);
+            assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+        }
+        ctx = greeter.getContext();
+        
+        assertNotNull(ctx);
+        
+        // Test that calling stop on the Endpoint works
+        assertTrue(endpoint.isPublished());
+        endpoint.stop();
+        assertFalse(endpoint.isPublished());
+        
+    }
+    
 
     @Test
     public void testEndpointServiceConstructor() throws Exception {   

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/GreeterTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/GreeterTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/GreeterTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/GreeterTest.java Thu Oct 25 10:09:20 2007
@@ -45,7 +45,7 @@
         bean.setServiceClass(GreeterImpl.class);
         GreeterImpl greeter = new GreeterImpl();
         BeanInvoker invoker = new BeanInvoker(greeter);
-        bean.setInvoker(invoker);
+        
         
         Service service = bean.create();
 
@@ -55,6 +55,7 @@
         ServerFactoryBean svr = new ServerFactoryBean();
         svr.setBus(bus);
         svr.setServiceFactory(bean);
+        svr.setInvoker(invoker);
         
         svr.create();
 

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsServerFactoryBeanTest.java Thu Oct 25 10:09:20 2007
@@ -27,6 +27,7 @@
 import org.w3c.dom.Document;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.calculator.CalculatorImpl;
 import org.apache.cxf.calculator.CalculatorPortType;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.Server;
@@ -129,6 +130,7 @@
     public void testJaxwsServiceClass() throws Exception {
         JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
         factory.setServiceClass(CalculatorPortType.class);
+        factory.setServiceBean(new CalculatorImpl());
         String address = "http://localhost:9001/jaxwstest";
         factory.setAddress(address);
         Server server = factory.create();

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/MessageReplayObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/MessageReplayObserver.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/MessageReplayObserver.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/MessageReplayObserver.java Thu Oct 25 10:09:20 2007
@@ -42,6 +42,7 @@
             while (in.read() != -1) {
                 // do nothing
             }
+            in.close();
             
             Conduit backChannel = message.getDestination().getBackChannel(message, null, null);
 
@@ -53,7 +54,6 @@
             IOUtils.copy(res, out, 2045);
 
             res.close();
-            in.close();
             out.close();
             backChannel.close(message);
         } catch (Exception e) {

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java Thu Oct 25 10:09:20 2007
@@ -100,7 +100,7 @@
                 Boolean outboundProperty = (Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
                 if (outboundProperty.booleanValue()) {
                     try {
-                        smc.setMessage(preparemSOAPMessage("resources/greetMeRpcLitRespChanged.xml"));
+                        smc.setMessage(prepareSOAPMessage("resources/greetMeRpcLitRespChanged.xml"));
                     } catch (Exception e) {
                         throw new Fault(e);
                     }
@@ -232,7 +232,7 @@
         message.setExchange(exchange);
         XMLStreamReader reader = preparemXMLStreamReader("resources/greetMeRpcLitReq.xml");
         message.setContent(XMLStreamReader.class, reader);
-        Object[] headerInfo = preparemSOAPHeader();
+        Object[] headerInfo = prepareSOAPHeader();
         
         message.setContent(Node.class, headerInfo[0]);
         
@@ -343,7 +343,7 @@
                                           soapVersion.getNamespace());
                     writer.writeNamespace(soapVersion.getPrefix(), soapVersion.getNamespace());
                     
-                    Object[] headerInfo = preparemSOAPHeader();
+                    Object[] headerInfo = prepareSOAPHeader();
                     StaxUtils.writeElement((Element) headerInfo[1], writer, true, false);
                     
                     writer.writeEndElement();
@@ -372,6 +372,7 @@
         SOAPHeaderElement headerElementNew = (SOAPHeaderElement)itNew.next();
         SoapVersion soapVersion = Soap11.getInstance();
         assertEquals("false", headerElementNew.getAttributeNS(soapVersion.getNamespace(), "mustUnderstand"));
+        originalEmptyOs.close();
     }
 
     @Test
@@ -512,7 +513,7 @@
         return xmlReader;
     }
 
-    private Object[] preparemSOAPHeader() throws Exception {
+    private Object[] prepareSOAPHeader() throws Exception {
         Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
         SoapVersion soapVersion = Soap11.getInstance();
         Element envElement = doc.createElementNS(soapVersion.getEnvelope().getNamespaceURI(),
@@ -536,7 +537,7 @@
         return new Object[] {doc, headerElement};
     }
 
-    private SOAPMessage preparemSOAPMessage(String resouceName) throws Exception {
+    private SOAPMessage prepareSOAPMessage(String resouceName) throws Exception {
         InputStream is = this.getClass().getResourceAsStream(resouceName);
         SOAPMessage soapMessage = null;
         MessageFactory factory = MessageFactory.newInstance();
@@ -546,7 +547,7 @@
     }
 
     private CachedStream prepareOutputStreamFromResource(String resouceName) throws Exception {
-        SOAPMessage soapMessage = preparemSOAPMessage(resouceName);
+        SOAPMessage soapMessage = prepareSOAPMessage(resouceName);
         CachedStream os = new CachedStream();
         soapMessage.writeTo(os);
         return os;

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/jaxb.index
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/jaxb.index?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/jaxb.index (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/jaxb.index Thu Oct 25 10:09:20 2007
@@ -1 +1,17 @@
+# 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.
 Foo

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java Thu Oct 25 10:09:20 2007
@@ -24,6 +24,7 @@
 
 import junit.framework.Assert;
 
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.binding.BindingConfiguration;
 import org.apache.cxf.binding.soap.Soap12;
 import org.apache.cxf.binding.soap.SoapBindingConfiguration;
@@ -41,10 +42,20 @@
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.jaxws.service.Hello;
 import org.apache.hello_world_soap_http.Greeter;
+import org.junit.After;
 import org.junit.Test;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class SpringBeansTest extends Assert {
+    
+    @After
+    public void tearDown() throws Exception {
+        if (BusFactory.getDefaultBus(false) != null) {
+            BusFactory.getDefaultBus(false).shutdown(true);
+        }
+    }
+
+    
     @Test
     public void testEndpoints() throws Exception {
         ClassPathXmlApplicationContext ctx = 
@@ -143,6 +154,7 @@
         assertTrue("Could not find server factory with autogenerated id", found);
         
         testInterceptors(ctx);
+        
     }
 
     private void testInterceptors(ClassPathXmlApplicationContext ctx) {

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml Thu Oct 25 10:09:20 2007
@@ -39,7 +39,7 @@
       </property>
   </bean>
   
-  <jaxws:server id="simple" serviceBean="#greeter"/>
+  <jaxws:server id="simple" serviceBean="#greeter" xmlns:test="urn:foo" xmlns="urn:foo"/>
 
   <bean id="greeter" class="org.apache.hello_world_soap_http.GreeterImpl"/>
 
@@ -56,10 +56,10 @@
     serviceClass="org.apache.hello_world_soap_http.GreeterImpl"
     address="http://localhost:8080/simpleWithAddress" 
     bus="cxf" 
-    endpointName="e:HelloEndpointCustomized"
-    serviceName="s:HelloServiceCustomized"    
-    xmlns:e="http://service.jaxws.cxf.apache.org/endpoint"
-    xmlns:s="http://service.jaxws.cxf.apache.org/service">
+    endpointName="e:SoapPort_Test1"
+    serviceName="s:SOAPService_Test1"    
+    xmlns:e="http://apache.org/hello_world_soap_http"
+    xmlns:s="http://apache.org/hello_world_soap_http">
     <jaxws:invoker>
       <bean class="org.apache.cxf.service.invoker.BeanInvoker">
         <constructor-arg>

Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java Thu Oct 25 10:09:20 2007
@@ -20,18 +20,23 @@
 package org.apache.cxf.jaxws.support;
 
 import java.net.URL;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
-
 import javax.wsdl.Definition;
 import javax.wsdl.factory.WSDLFactory;
 import javax.xml.namespace.QName;
+import javax.xml.ws.Binding;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.MTOMFeature;
+import javax.xml.ws.soap.SOAPBinding;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxws.AbstractJaxWsTest;
 import org.apache.cxf.mtom_xop.TestMtomImpl;
 import org.apache.cxf.service.Service;
@@ -181,7 +186,7 @@
         assertEquals("greetMeResponse", greetMeOp.getOutput().getName().getLocalPart());
         
         MessagePartInfo outMessagePart = messageParts.get(0);
-        assertEquals("result", outMessagePart.getName().getLocalPart());
+        //assertEquals("result", outMessagePart.getName().getLocalPart());
         assertEquals("http://apache.org/hello_world_doc_lit", outMessagePart.getName().getNamespaceURI());
         assertEquals("http://apache.org/hello_world_doc_lit/types", outMessagePart.getElementQName()
             .getNamespaceURI());
@@ -215,28 +220,38 @@
         
 
         assertValid("/wsdl:definitions/wsdl:message[@name='setMessage']" 
-                    + "/wsdl:part[@name = 'parameters'][@element='ns2:setMessage']" , wsdl);
+                    + "/wsdl:part[@name = 'parameters'][@element='ns1:setMessage']" , wsdl);
 
         assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']" 
-                    + "/wsdl:part[@name = 'y'][@element='ns2:charEl_y']" , wsdl);
+                    + "/wsdl:part[@name = 'y'][@element='ns1:charEl_y']" , wsdl);
         
         assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']" 
-                    + "/wsdl:part[@name = 'return'][@element='ns2:charEl_return']" , wsdl);
+                    + "/wsdl:part[@name = 'return'][@element='ns1:charEl_return']" , wsdl);
 
         assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']" 
-                    + "/wsdl:part[@name = 'z'][@element='ns2:charEl_z']" , wsdl);
+                    + "/wsdl:part[@name = 'z'][@element='ns1:charEl_z']" , wsdl);
         
         assertValid("/wsdl:definitions/wsdl:message[@name='echoChar']" 
-                    + "/wsdl:part[@name = 'x'][@element='ns2:charEl_x']" , wsdl);
+                    + "/wsdl:part[@name = 'x'][@element='ns1:charEl_x']" , wsdl);
         
         assertValid("/wsdl:definitions/wsdl:message[@name='echoChar']" 
-                    + "/wsdl:part[@name = 'y'][@element='ns2:charEl_y']" , wsdl);
+                    + "/wsdl:part[@name = 'y'][@element='ns1:charEl_y']" , wsdl);
 
         
     }
     
-    
-    
-    
-
+    @Test
+    public void testMtomFeature() throws Exception {
+        JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
+        bean.setBus(getBus());
+        bean.setServiceClass(GreeterImpl.class);
+        bean.setWsdlURL(getClass().getResource("/wsdl/hello_world.wsdl"));
+        bean.setWsFeatures(Arrays.asList(new WebServiceFeature[]{new MTOMFeature()}));
+        Service service = bean.create();
+        Endpoint endpoint = service.getEndpoints().values().iterator().next();
+        assertTrue(endpoint instanceof JaxWsEndpointImpl);
+        Binding binding = ((JaxWsEndpointImpl)endpoint).getJaxwsBinding();
+        assertTrue(binding instanceof SOAPBinding);
+        assertTrue(((SOAPBinding)binding).isMTOMEnabled());
+    }   
 }

Modified: incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java Thu Oct 25 10:09:20 2007
@@ -49,6 +49,8 @@
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.ServiceModelUtil;
+import org.apache.cxf.transport.ConduitInitiator;
+import org.apache.cxf.transport.ConduitInitiatorManager;
 import org.apache.cxf.transport.DestinationFactory;
 import org.apache.cxf.transport.DestinationFactoryManager;
 import org.apache.cxf.transport.local.LocalTransportFactory;
@@ -76,6 +78,15 @@
     private ConduitSelector conduitSelector;
     
     protected Endpoint createEndpoint() throws BusException, EndpointException {
+        
+        if (serviceName != null) {
+            serviceFactory.setServiceName(serviceName);
+        }
+        
+        if (endpointName != null) {
+            serviceFactory.setEndpointName(endpointName);    
+        }
+        
         Service service = serviceFactory.getService();
         
         if (service == null) {
@@ -83,9 +94,6 @@
             service = serviceFactory.create();
         }
         
-        if (serviceName != null) {
-            serviceFactory.setServiceName(serviceName);
-        }
         
         if (endpointName == null) {
             endpointName = serviceFactory.getEndpointName();
@@ -167,9 +175,15 @@
                 DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
                 df = dfm.getDestinationFactoryForUri(getAddress());
             }
-            
             if (df != null) {
                 transportId = df.getTransportIds().get(0);
+            } else {
+                //check conduits (the address could be supported on client only)
+                ConduitInitiatorManager cim = getBus().getExtension(ConduitInitiatorManager.class);
+                ConduitInitiator ci = cim.getConduitInitiatorForUri(getAddress());
+                if (ci != null) {
+                    transportId = ci.getTransportIds().get(0);
+                }
             }
         }
         

Modified: incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java Thu Oct 25 10:09:20 2007
@@ -113,7 +113,7 @@
             if (invoker == null) {
                 if (serviceBean != null) {
                     ep.getService().setInvoker(createInvoker());
-                }
+                }    
             } else {
                 ep.getService().setInvoker(invoker);
             }
@@ -129,7 +129,7 @@
             throw new ServiceConstructionException(e);
         }
         
-        if (getServiceBean() != null) {
+        if (serviceBean != null) {
             initializeAnnotationInterceptors(server.getEndpoint(), this.getServiceBean().getClass());
         }
         
@@ -199,7 +199,7 @@
       
     
     protected Invoker createInvoker() {
-        return new BeanInvoker(serviceBean);
+        return new BeanInvoker(getServiceBean());
     }
 
     public Server getServer() {
@@ -222,11 +222,16 @@
         this.start = start;
     }
 
-    public Object getServiceBean() {
-        if (serviceBean == null) {
+    public Object getServiceBean() {        
+        return serviceBean;
+    }
+    
+    public Class<?> getServiceBeanClass() {
+        if (serviceBean != null) {
+            return serviceBean.getClass();
+        } else {
             return getServiceFactory().getServiceClass();
         }
-        return serviceBean;
     }
 
     /**

Modified: incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java Thu Oct 25 10:09:20 2007
@@ -92,7 +92,7 @@
         throws BeanDefinitionStoreException {
         String id = super.resolveId(elem, definition, ctx);
         if (StringUtils.isEmpty(id)) {
-            id = getBeanClass().getName() + "--" + hashCode();
+            id = getBeanClass().getName() + "--" + definition.hashCode();
         }
         
         return id;

Modified: incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java Thu Oct 25 10:09:20 2007
@@ -152,6 +152,9 @@
     public QName getResponseWrapperName(OperationInfo op, Method method) {
         return null;        
     }  
+    public String getResponseWrapperPartName(OperationInfo op, Method method) {
+        return null;        
+    }  
  
     public Class getResponseWrapper(Method selected) {
         return null;

Modified: incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Thu Oct 25 10:09:20 2007
@@ -30,6 +30,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -252,7 +253,6 @@
 
             if (!isWrapped(m) && !isRPC(m) && opInfo.getInput() != null) {
                 createBareMessage(serviceInfo, opInfo, false);
-
             }
 
             if (!isWrapped(m) && !isRPC(m) && opInfo.getOutput() != null) {
@@ -421,21 +421,22 @@
     protected void initializeWrappedSchema(ServiceInfo serviceInfo) {
         for (OperationInfo op : serviceInfo.getInterface().getOperations()) {
             if (op.getUnwrappedOperation() != null) {
-                if (op.hasInput() 
-                    && op.getInput().getMessageParts().get(0).getTypeClass() == null) {
+                if (op.hasInput()) { 
+                    if (op.getInput().getMessageParts().get(0).getTypeClass() == null) {
                     
-                    QName wraperBeanName = op.getInput().getMessageParts().get(0).getElementQName();
-                    XmlSchemaElement e = null;
-                    for (SchemaInfo s : serviceInfo.getSchemas()) {
-                        e = s.getElementByQName(wraperBeanName);
-                        if (e != null) {
-                            op.getInput().getMessageParts().get(0).setXmlSchema(e);
-                            break;
+                        QName wrapperBeanName = op.getInput().getMessageParts().get(0).getElementQName();
+                        XmlSchemaElement e = null;
+                        for (SchemaInfo s : serviceInfo.getSchemas()) {
+                            e = s.getElementByQName(wrapperBeanName);
+                            if (e != null) {
+                                op.getInput().getMessageParts().get(0).setXmlSchema(e);
+                                break;
+                            }
+                        }
+                        if (e == null) {
+                            createWrappedSchema(serviceInfo, op.getInput(),
+                                                op.getUnwrappedOperation().getInput(), wrapperBeanName);
                         }
-                    }
-                    if (e == null) {
-                        createWrappedSchema(serviceInfo, op.getInput(),
-                                            op.getUnwrappedOperation().getInput(), wraperBeanName);
                     }
 
                     for (MessagePartInfo mpi : op.getInput().getMessageParts()) {
@@ -445,35 +446,47 @@
                             mpi.setElementQName(qn);
 
 
-                            checkForHeaderElement(serviceInfo, mpi);
+                            checkForElement(serviceInfo, mpi);
                         }
                     }
 
 
                 }
-                if (op.hasOutput()
-                    && op.getOutput().getMessageParts().get(0).getTypeClass() == null) {
+                if (op.hasOutput()) {
+                    if (op.getOutput().getMessageParts().get(0).getTypeClass() == null) {
                     
-                    QName wraperBeanName = op.getOutput().getMessageParts().get(0).getElementQName();
-                    XmlSchemaElement e = null;
-                    for (SchemaInfo s : serviceInfo.getSchemas()) {
-                        e = s.getElementByQName(wraperBeanName);
-                        if (e != null) {
-                            break;
+                        QName wrapperBeanName = op.getOutput().getMessageParts().get(0).getElementQName();
+                        XmlSchemaElement e = null;
+                        for (SchemaInfo s : serviceInfo.getSchemas()) {
+                            e = s.getElementByQName(wrapperBeanName);
+                            if (e != null) {
+                                break;
+                            }
+                        }
+                        if (e == null) {
+                            createWrappedSchema(serviceInfo, op.getOutput(), op.getUnwrappedOperation()
+                                .getOutput(), wrapperBeanName);
                         }
                     }
-                    if (e == null) {
-                        createWrappedSchema(serviceInfo, op.getOutput(), op.getUnwrappedOperation()
-                            .getOutput(), wraperBeanName);
-                    }
-
                     for (MessagePartInfo mpi : op.getOutput().getMessageParts()) {
                         if (Boolean.TRUE.equals(mpi.getProperty(HEADER))) {
                             QName qn = (QName)mpi.getProperty(ELEMENT_NAME);
                             mpi.setElement(true);
                             mpi.setElementQName(qn);
 
-                            checkForHeaderElement(serviceInfo, mpi);
+                            checkForElement(serviceInfo, mpi);
+                        }
+                    }
+                }
+                if (op.hasFaults()) {
+                    //check to make sure the faults are elements
+                    for (FaultInfo fault : op.getFaults()) {
+                        QName qn = (QName)fault.getProperty("elementName");
+                        MessagePartInfo part = fault.getMessagePart(0);
+                        if (!part.isElement()) {
+                            part.setElement(true);
+                            part.setElementQName(qn);
+                            checkForElement(serviceInfo, part);
                         }
                     }
                 }
@@ -482,7 +495,7 @@
 
     }
 
-    protected void checkForHeaderElement(ServiceInfo serviceInfo, MessagePartInfo mpi) {
+    protected void checkForElement(ServiceInfo serviceInfo, MessagePartInfo mpi) {
         for (SchemaInfo s : serviceInfo.getSchemas()) {
             XmlSchemaElement e = s.getElementByQName(mpi.getElementQName());
             if (e != null) {
@@ -514,13 +527,13 @@
     }
 
     protected void createWrappedSchema(ServiceInfo serviceInfo, AbstractMessageContainer wrappedMessage,
-                                       AbstractMessageContainer unwrappedMessage, QName wraperBeanName) {
+                                       AbstractMessageContainer unwrappedMessage, QName wrapperBeanName) {
         SchemaInfo schemaInfo = getOrCreateSchema(serviceInfo,
-                                                  wraperBeanName.getNamespaceURI(),
+                                                  wrapperBeanName.getNamespaceURI(),
                                                   qualifyWrapperSchema());
 
         createWrappedMessageSchema(serviceInfo, wrappedMessage, unwrappedMessage,
-                                   schemaInfo.getSchema(), wraperBeanName);
+                                   schemaInfo.getSchema(), wrapperBeanName);
     }
 
     protected void createBareMessage(ServiceInfo serviceInfo,
@@ -696,8 +709,20 @@
                 }
                 if (mpi.getTypeClass() != null && mpi.getTypeClass().isArray()
                     && !Byte.TYPE.equals(mpi.getTypeClass().getComponentType())) {
-                    el.setMinOccurs(0);
-                    el.setMaxOccurs(Long.MAX_VALUE);
+                    String min = (String)mpi.getProperty("minOccurs");
+                    String max = (String)mpi.getProperty("maxOccurs");
+                    if (min == null) {
+                        min = "0";
+                    }
+                    if (max == null) {
+                        max = "unbounded";
+                    }
+                    el.setMinOccurs(Long.parseLong(min));
+                    el.setMaxOccurs("unbounded".equals(max) ? Long.MAX_VALUE : Long.parseLong(max));
+                    Boolean b = (Boolean)mpi.getProperty("nillable");
+                    if (b != null && b.booleanValue()) {
+                        el.setNillable(b.booleanValue());
+                    }
                 } else if (Collection.class.isAssignableFrom(mpi.getTypeClass())
                            && mpi.getTypeClass().isInterface()) {
                     Type type = (Type)mpi.getProperty(GENERIC_TYPE);
@@ -717,7 +742,6 @@
                 seq.getItems().add(el);
             }
             if (Boolean.TRUE.equals(mpi.getProperty(HEADER))) {
-
                 QName qn = (QName)mpi.getProperty(ELEMENT_NAME);
 
                 el.setName(qn.getLocalPart());
@@ -752,8 +776,21 @@
         serviceInfo.setXmlSchemaCollection(col);
         schemaInfo.setSchema(schema);
 
+        Map<String, String> explicitNamespaceMappings = this.getDataBinding().getDeclaredNamespaceMappings();
+        if (explicitNamespaceMappings == null) {
+            explicitNamespaceMappings = Collections.emptyMap();
+        }
         NamespaceMap nsMap = new NamespaceMap();
-        nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NU_SCHEMA_XSD);
+        for (Map.Entry<String, String> mapping : explicitNamespaceMappings.entrySet()) {
+            nsMap.add(mapping.getValue(), mapping.getKey());
+        }
+        
+        if (!explicitNamespaceMappings.containsKey(WSDLConstants.NU_SCHEMA_XSD)) {
+            nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NU_SCHEMA_XSD);
+        }
+        if (!explicitNamespaceMappings.containsKey(serviceInfo.getTargetNamespace())) {
+            nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, serviceInfo.getTargetNamespace());
+        }
         schema.setNamespaceContext(nsMap);
         serviceInfo.addSchema(schemaInfo);
         return schemaInfo;
@@ -889,7 +926,19 @@
     }
 
     protected void createOutputWrappedMessageParts(OperationInfo op, Method method, MessageInfo outMsg) {
-        MessagePartInfo part = outMsg.addMessagePart("result");
+        String partName = null;
+        for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
+            AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
+            partName = c.getResponseWrapperPartName(op, method);
+            if (partName != null) {
+                break;
+            }
+        }
+        if (partName == null) {
+            partName = "parameters";
+        }
+        
+        MessagePartInfo part = outMsg.addMessagePart(partName);
         part.setElement(true);
         part.setIndex(0);
         for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
@@ -897,6 +946,7 @@
             QName q = c.getResponseWrapperName(op, method);
             if (q != null) {
                 part.setElementQName(q);
+                break;
             }
         }
 
@@ -1144,7 +1194,8 @@
                                    new QName(op.getName().getNamespaceURI(), exClass.getSimpleName()));
         fi.setProperty(Class.class.getName(), exClass);
         fi.setProperty("elementName", faultName);
-        MessagePartInfo mpi = fi.addMessagePart(new QName(faultName.getNamespaceURI(), "fault"));
+        MessagePartInfo mpi = fi.addMessagePart(new QName(faultName.getNamespaceURI(),
+                                                          exClass.getSimpleName()));
         mpi.setElementQName(faultName);
         mpi.setTypeClass(beanClass);
         return fi;
@@ -1456,7 +1507,7 @@
                 return b.booleanValue();
             }
         }
-        return true;
+        return "rpc".equals(getStyle());
     }
 
     public void setWrapped(boolean style) {

Modified: incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/ClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/ClientServerTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/ClientServerTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/ClientServerTest.java Thu Oct 25 10:09:20 2007
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.frontend.spring;
 import junit.framework.Assert;
+
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.service.factory.HelloService;
 import org.junit.Test;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -28,6 +30,7 @@
 public class ClientServerTest extends Assert {
     @Test
     public void testClientServer() {
+        BusFactory.setDefaultBus(null);
         ClassPathXmlApplicationContext ctx = 
             new ClassPathXmlApplicationContext(new String[] {"/org/apache/cxf/frontend/spring/rountrip.xml"});
         

Modified: incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/servers.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/servers.xml?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/servers.xml (original)
+++ incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/servers.xml Thu Oct 25 10:09:20 2007
@@ -73,6 +73,7 @@
   
   <simple:server id="inlineSoapBinding" 
     serviceClass="org.apache.cxf.service.factory.HelloService"
+    serviceBean="#greeter"
     address="http://localhost:8080/test"   
     serviceName="t:HelloService"
     xmlns:t="http://apache.org/hello_world_soap_http"

Modified: incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactoryTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactoryTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactoryTest.java Thu Oct 25 10:09:20 2007
@@ -138,6 +138,7 @@
         ServerFactoryBean svrBean = new ServerFactoryBean();
         svrBean.setAddress("http://localhost/Hello");
         svrBean.setServiceFactory(serviceFactory);
+        svrBean.setServiceBean(new HelloServiceImpl());
         svrBean.setBus(getBus());
         
         Map<String, Object> props = new HashMap<String, Object>();

Modified: incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ServerFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ServerFactoryTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ServerFactoryTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ServerFactoryTest.java Thu Oct 25 10:09:20 2007
@@ -46,6 +46,7 @@
         ServerFactoryBean svrBean = new ServerFactoryBean();
         svrBean.setAddress("http://localhost/Hello");
         svrBean.setServiceClass(HelloService.class);
+        svrBean.setServiceBean(new HelloServiceImpl());
         svrBean.setBus(getBus());
         svrBean.setDestinationFactory(new CustomDestinationFactory());
 
@@ -53,12 +54,13 @@
         assertTrue(server.getDestination() instanceof CustomDestination);
     }
     
+        
     @SuppressWarnings("unchecked")
     @Test
     public void testJaxbExtraClass() throws Exception {
         ServerFactoryBean svrBean = new ServerFactoryBean();
         svrBean.setAddress("http://localhost/Hello");
-        svrBean.setServiceClass(HelloService.class);
+        svrBean.setServiceClass(HelloServiceImpl.class);
         svrBean.setBus(getBus());
 
         Map props = svrBean.getProperties();

Modified: incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/StaxDatabindingTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/StaxDatabindingTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/StaxDatabindingTest.java (original)
+++ incubator/cxf/branches/jliu/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/StaxDatabindingTest.java Thu Oct 25 10:09:20 2007
@@ -45,7 +45,7 @@
         sf.setAddress(address);
         sf.setDataBinding(new StaxDataBinding());
         sf.getFeatures().add(new StaxDataBindingFeature());
-
+        sf.setBus(getBus());
         sf.create();
         
         Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "req.xml");

Modified: incubator/cxf/branches/jliu/rt/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/pom.xml?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/pom.xml (original)
+++ incubator/cxf/branches/jliu/rt/pom.xml Thu Oct 25 10:09:20 2007
@@ -34,6 +34,7 @@
     <modules>
         <module>core</module>
         <module>transports/local</module>
+        <module>testsupport</module>
         <module>databinding/jaxb</module>
         <module>databinding/aegis</module>
         <module>bindings</module>

Propchange: incubator/cxf/branches/jliu/rt/testsupport/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct 25 10:09:20 2007
@@ -0,0 +1,10 @@
+.pmd
+.checkstyle
+.ruleset
+target
+.settings
+.classpath
+.project
+.wtpmodules
+
+

Modified: incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java (original)
+++ incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java Thu Oct 25 10:09:20 2007
@@ -33,6 +33,7 @@
 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;
@@ -172,13 +173,22 @@
         }
     }
 
-    private synchronized void updateEndpointAddress(String addr) {
+    private String removeTrailingSeparator(String addr) {
+        if (addr != null && addr.lastIndexOf('/') == addr.length() - 1) {
+            return addr.substring(0, addr.length() - 1);
+        } else {
+            return addr;
+        }
+    }
+    
+    private synchronized String updateEndpointAddress(String addr) {
         // only update the EndpointAddress if the base path is equal
         // make sure we don't broke the get operation?parament query 
-        String address = endpointInfo.getAddress();
-        if (getBasePath(address).equals(getStem(getBasePath(addr)))) {
+        String address = removeTrailingSeparator(endpointInfo.getAddress());
+        if (getBasePath(address).equals(removeTrailingSeparator(getStem(getBasePath(addr))))) {
             endpointInfo.setAddress(addr);
         }
+        return address;
     }
    
     protected void doService(HttpServletRequest req, HttpServletResponse resp) throws IOException {
@@ -193,8 +203,9 @@
         }
         QueryHandlerRegistry queryHandlerRegistry = bus.getExtension(QueryHandlerRegistry.class);
         
-        if (null != req.getQueryString() && queryHandlerRegistry != null) {        
-            String requestURL = req.getRequestURL() + "?" + req.getQueryString();
+        if (null != req.getQueryString() && queryHandlerRegistry != null) {   
+            String reqAddr = req.getRequestURL().toString();
+            String requestURL =  reqAddr + "?" + req.getQueryString();
             String pathInfo = req.getPathInfo();                     
             for (QueryHandler qh : queryHandlerRegistry.getHandlers()) {
                 boolean recognized =
@@ -205,17 +216,21 @@
                                                                        contextMatchOnExact())
                     : qh.isRecognizedQuery(requestURL, pathInfo, endpointInfo);
                 if (recognized) {
-                    //replace the endpointInfo address with request url only for get wsdl           
-                    updateEndpointAddress(req.getRequestURL().toString());   
-                    resp.setContentType(qh.getResponseContentType(requestURL, pathInfo));
-                    try {
-                        qh.writeResponse(requestURL, pathInfo, endpointInfo, resp.getOutputStream());
-                    } catch (Exception ex) {
-                        LOG.log(Level.WARNING, "writeResponse failed: ", ex);
+                    //replace the endpointInfo address with request url only for get wsdl   
+                    synchronized (endpointInfo) {
+                        String oldAddress = updateEndpointAddress(reqAddr);   
+                        resp.setContentType(qh.getResponseContentType(requestURL, pathInfo));
+                        try {
+                            qh.writeResponse(requestURL, pathInfo, endpointInfo, resp.getOutputStream());
+                        } catch (Exception ex) {
+                            LOG.log(Level.WARNING, "writeResponse failed: ", ex);
+                        }
+                        endpointInfo.setAddress(oldAddress);
+                        resp.getOutputStream().flush();                     
+                        baseRequest.setHandled(true);
+                        return;    
                     }
-                    resp.getOutputStream().flush();                     
-                    baseRequest.setHandled(true);
-                    return;
+                    
                 }
             }
         }
@@ -239,7 +254,7 @@
             inMessage.put(HTTP_RESPONSE, resp);
             inMessage.put(Message.HTTP_REQUEST_METHOD, req.getMethod());
             inMessage.put(Message.PATH_INFO, req.getContextPath() + req.getPathInfo());
-            inMessage.put(Message.ENCODING, req.getCharacterEncoding());
+            inMessage.put(Message.ENCODING, HttpHeaderHelper.mapCharset(req.getCharacterEncoding()));
             inMessage.put(Message.QUERY_STRING, req.getQueryString());
             inMessage.put(Message.CONTENT_TYPE, req.getContentType());
             if (!StringUtils.isEmpty(endpointInfo.getAddress())) {

Modified: incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java (original)
+++ incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java Thu Oct 25 10:09:20 2007
@@ -40,6 +40,7 @@
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.handler.ContextHandler;
 import org.mortbay.jetty.handler.ContextHandlerCollection;
+import org.mortbay.jetty.handler.DefaultHandler;
 import org.mortbay.jetty.handler.HandlerList;
 import org.mortbay.jetty.nio.SelectChannelConnector;
 import org.mortbay.jetty.security.SslSocketConnector;
@@ -165,7 +166,28 @@
      * remove it from the factory's cache. 
      */
     public void shutdown() {
-        factory.destroyForPort(port);
+        if (shouldDestroyPort()) {
+            if (factory != null && servantCount == 0) {
+                factory.destroyForPort(port);
+            } else {
+                LOG.log(Level.WARNING, "FAILED_TO_SHUTDOWN_ENGINE_MSG", port);
+            }
+        }
+    }
+    
+    private boolean shouldDestroyPort() {
+        //if we shutdown the port, on SOME OS's/JVM's, if a client
+        //in the same jvm had been talking to it at some point and keep alives
+        //are on, then the port is held open for about 60 seconds
+        //afterword and if we restart, connections will then 
+        //get sent into the old stuff where there are 
+        //no longer any servant registered.   They pretty much just hang.
+        
+        //this is most often seen in our unit/system tests that 
+        //test things in the same VM.
+        
+        String s = System.getProperty("org.apache.cxf.transports.http_jetty.DontClosePort");
+        return !Boolean.valueOf(s);
     }
     
     /**
@@ -225,6 +247,7 @@
      */
     public synchronized void addServant(URL url, JettyHTTPHandler handler) {
         if (server == null) {
+            DefaultHandler defaultHandler = null;
             // create a new jetty server instance if there is no server there            
             server = new Server();
             if (connector == null) {
@@ -234,12 +257,21 @@
             if (handlers != null && handlers.size() > 0) {
                 HandlerList handlerList = new HandlerList();
                 for (Handler h : handlers) {
-                    handlerList.addHandler(h);
+                    // filting the jetty default handler 
+                    // which should not be added at this point
+                    if (h instanceof DefaultHandler) {
+                        defaultHandler = (DefaultHandler) h;
+                    } else {
+                        handlerList.addHandler(h);
+                    }
                 }
                 server.addHandler(handlerList);
             }
             contexts = new ContextHandlerCollection();
-            server.addHandler(contexts);            
+            server.addHandler(contexts);
+            if (defaultHandler != null) {
+                server.addHandler(defaultHandler);
+            }
             try {
                 server.start();
                 AbstractConnector aconn = (AbstractConnector) connector;
@@ -471,6 +503,8 @@
         }
     }
     
+
+    
     /**
      * This method is called by the ServerEngine Factory to destroy the 
      * listener.
@@ -478,10 +512,11 @@
      */
     protected void stop() throws Exception {
         if (server != null) {
+            
             connector.close();
             server.stop();
             server.destroy();
-            server   = null;
+            server = null;
         }
     }
     

Modified: incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java (original)
+++ incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java Thu Oct 25 10:09:20 2007
@@ -30,6 +30,8 @@
 import javax.annotation.Resource;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.configuration.jsse.TLSServerParameters;
 
@@ -42,31 +44,19 @@
  * caches the JettyHTTPServerEngines so that they may be 
  * retrieved if already previously configured.
  */
-public class JettyHTTPServerEngineFactory {
+public class JettyHTTPServerEngineFactory implements BusLifeCycleListener {
     private static final Logger LOG =
         LogUtils.getL7dLogger(JettyHTTPServerEngineFactory.class);    
     
     /**
      * This map holds references for allocated ports.
      */
-    // All system tests do not shut down bus correctly,
-    // or the bus does not shutdown all endpoints correctly,
-    // so that these server endings are actuall shared amongst busses
-    // within the same JVM.
-    
-    // We will keep it static until we can resolve the problems 
-    // in the System tests.
-    // TODO: Fix the System Tests so that they shutdown the 
-    // buses that they are using and that the buses actually
-    // shutdown the destinations and their server engines
-    // properly. This will require a bit of lifecyle and reference
-    // counting on Destinations to server engines, if they are 
-    // going to be shared, but they should by no means be 
-    // shared accross buses, right?
+    // Still use the static map to hold the port information
+    // in the same JVM
     private static Map<Integer, JettyHTTPServerEngine> portMap =
         new HashMap<Integer, JettyHTTPServerEngine>();
    
-    
+    private BusLifeCycleManager lifeCycleManager;
     /**
      * This map holds the threading parameters that are to be applied
      * to new Engines when bound to the reference id.
@@ -89,7 +79,8 @@
     
     public JettyHTTPServerEngineFactory() {
         // Empty
-    }
+    }    
+    
     
     /**
      * This call is used to set the bus. It should only be called once.
@@ -104,7 +95,13 @@
     
     @PostConstruct
     public void registerWithBus() {
-        bus.setExtension(this, JettyHTTPServerEngineFactory.class);
+        if (bus != null) {
+            bus.setExtension(this, JettyHTTPServerEngineFactory.class);
+        }
+        lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
+        if (null != lifeCycleManager) {
+            lifeCycleManager.registerLifeCycleListener(this);
+        }        
     }
     
     
@@ -138,7 +135,7 @@
         threadingParametersMap = threadingParamsMap;
     }
     
-    public Map<String, ThreadingParameters> getThreadingParamtersMap() {
+    public Map<String, ThreadingParameters> getThreadingParametersMap() {
         return threadingParametersMap;
     }
             
@@ -147,7 +144,7 @@
      * This call retrieves a previously configured JettyHTTPServerEngine for the
      * given port. If none exists, this call returns null.
      */
-    protected synchronized JettyHTTPServerEngine retrieveJettyHTTPServerEngine(int port) {
+    public synchronized JettyHTTPServerEngine retrieveJettyHTTPServerEngine(int port) {
         return portMap.get(port);
     }
 
@@ -200,6 +197,29 @@
     @PostConstruct
     public void finalizeConfig() {
         registerWithBus();
+    }
+
+    public void initComplete() {
+        // do nothing here
+        
+    }
+
+    public void postShutdown() {
+        //shut down the jetty server in the portMap
+        // To avoid the CurrentModificationException, 
+        // do not use portMap.vaules directly       
+        JettyHTTPServerEngine[] engines = portMap.values().toArray(new JettyHTTPServerEngine[0]);
+        for (JettyHTTPServerEngine engine : engines) {
+            engine.shutdown();
+        }
+        // clean up the collections
+        threadingParametersMap.clear();
+        tlsParametersMap.clear();
+    }
+
+    public void preShutdown() {
+        // do nothing here 
+        // just let server registry to call the server stop first
     }
     
 }

Modified: incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPTransportFactory.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPTransportFactory.java (original)
+++ incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPTransportFactory.java Thu Oct 25 10:09:20 2007
@@ -20,6 +20,7 @@
 
 import java.io.IOException;
 import java.security.GeneralSecurityException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -30,9 +31,12 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.DestinationFactoryManager;
 import org.apache.cxf.transport.http.AbstractHTTPTransportFactory;
 
-public class JettyHTTPTransportFactory extends AbstractHTTPTransportFactory {
+public class JettyHTTPTransportFactory extends AbstractHTTPTransportFactory
+    implements DestinationFactory {
 
     private Map<String, JettyHTTPDestination> destinations = 
         new HashMap<String, JettyHTTPDestination>();
@@ -48,6 +52,23 @@
 
     @PostConstruct
     public void finalizeConfig() {
+        if (null == bus) {
+            return;
+        }
+        
+        if (getTransportIds() == null) {
+            setTransportIds(new ArrayList<String>(activationNamespaces));
+        }
+        if (activationNamespaces == null) {
+            activationNamespaces = getTransportIds();
+        }
+        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
+        if (null != dfm && null != activationNamespaces) {
+            for (String ns : activationNamespaces) {
+                dfm.registerDestinationFactory(ns, this);
+            }
+        }
+
         // This call will register the server engine factory
         // with the Bus.
         getJettyHTTPServerEngineFactory();
@@ -73,7 +94,6 @@
         return serverEngineFactory;
     }
     
-    @Override
     public Destination getDestination(EndpointInfo endpointInfo) 
         throws IOException {
         

Modified: incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties (original)
+++ incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties Thu Oct 25 10:09:20 2007
@@ -22,3 +22,4 @@
 ADD_HANDLER_FAILED_MSG = Could not add cxf jetty handler to Jetty server: {0}
 REMOVE_HANDLER_FAILED_MSG = Could not remove cxf jetty handler from Jetty server: {0}
 CAN_NOT_FIND_HANDLER_MSG = Could not find the handler to remove for context url {0}
+FAILED_TO_SHUTDOWN_ENGINE_MSG = Failed to shutdown Jetty server: {0} because it is still in use
\ No newline at end of file

Modified: incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/resources/META-INF/cxf/cxf-extension-http-jetty.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/resources/META-INF/cxf/cxf-extension-http-jetty.xml?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/resources/META-INF/cxf/cxf-extension-http-jetty.xml (original)
+++ incubator/cxf/branches/jliu/rt/transports/http-jetty/src/main/resources/META-INF/cxf/cxf-extension-http-jetty.xml Thu Oct 25 10:09:20 2007
@@ -23,7 +23,11 @@
        xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
     
-    <bean class="org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory" lazy-init="true">
+	<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
+        
+    <bean class="org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory"
+    	lazy-init="false" 
+    	depends-on="org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory">
         <property name="bus" ref="cxf"/>
         <property name="transportIds">
             <list>
@@ -36,4 +40,5 @@
             </list>
         </property>
     </bean>
+
 </beans>

Modified: incubator/cxf/branches/jliu/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java (original)
+++ incubator/cxf/branches/jliu/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java Thu Oct 25 10:09:20 2007
@@ -68,11 +68,11 @@
     @Test
     public void testEngineRetrieval() throws Exception {
         JettyHTTPServerEngine engine = 
-            factory.createJettyHTTPServerEngine(1234, "http");
+            factory.createJettyHTTPServerEngine(9234, "http");
         
         assertTrue(
             "Engine references for the same port should point to the same instance",
-            engine == factory.retrieveJettyHTTPServerEngine(1234));
+            engine == factory.retrieveJettyHTTPServerEngine(9234));
         
         factory.destroyForPort(1234);
     }
@@ -80,13 +80,13 @@
     @Test
     public void testHttpAndHttps() throws Exception {
         JettyHTTPServerEngine engine = 
-            factory.createJettyHTTPServerEngine(1234, "http");
+            factory.createJettyHTTPServerEngine(9234, "http");
         
         assertTrue("Protocol must be http", 
                 "http".equals(engine.getProtocol()));
         
         engine = new JettyHTTPServerEngine();
-        engine.setPort(1235);
+        engine.setPort(9235);
         engine.setTlsServerParameters(new TLSServerParameters());
         engine.finalizeConfig();
         
@@ -94,14 +94,14 @@
         list.add(engine);
         factory.setEnginesList(list);
         
-        engine = factory.createJettyHTTPServerEngine(1235, "https");
+        engine = factory.createJettyHTTPServerEngine(9235, "https");
         
         assertTrue("Protocol must be https", 
                 "https".equals(engine.getProtocol()));
         
         
-        factory.destroyForPort(1234);
-        factory.destroyForPort(1235);
+        factory.destroyForPort(9234);
+        factory.destroyForPort(9235);
     }
     
     
@@ -139,7 +139,7 @@
         try {
             engine.finalizeConfig();
         } catch (Exception ex) {
-            fail("we should not throw exception here");
+            fail("We should not throw exception here");
         }
     }
     
@@ -147,9 +147,10 @@
     
     @Test 
     public void testaddServants() throws Exception {
-        String urlStr = "http://localhost:1234/hello/test";
+        String urlStr = "http://localhost:9234/hello/test";
+        String urlStr2 = "http://localhost:9234/hello233/test";
         JettyHTTPServerEngine engine = 
-            factory.createJettyHTTPServerEngine(1234, "http");
+            factory.createJettyHTTPServerEngine(9234, "http");
         JettyHTTPTestHandler handler1 = new JettyHTTPTestHandler("string1");
         JettyHTTPTestHandler handler2 = new JettyHTTPTestHandler("string2");        
         engine.addServant(new URL(urlStr), handler1);
@@ -157,32 +158,39 @@
         try {
             response = getResponse(urlStr);
         } catch (Exception ex) {
-            fail("Can't get the reponse from the server " + ex);
+            fail("Can't get the response from the server " + ex);
         }
-        assertEquals("the jetty http handler did not take effect", response, "string1");
+        assertEquals("The jetty http handler did not take effect", response, "string1");
         
         engine.addServant(new URL(urlStr), handler2);
         try {
             response = getResponse(urlStr);
         } catch (Exception ex) {
-            fail("Can't get the reponse from the server " + ex);
+            fail("Can't get the response from the server " + ex);
         }
-        assertEquals("the jetty http handler did not take effect", response, "string1string2");
-        
-        
+        assertEquals("The jetty http handler did not take effect", response, "string1string2");
+        engine.addServant(new URL(urlStr2), handler2);
+        engine.removeServant(new URL(urlStr));
+        engine.shutdown();
+        try {
+            response = getResponse(urlStr2);
+        } catch (Exception ex) {
+            fail("Server should still work, even if we call the shutdown" + ex);
+        }
+        assertEquals("The jetty http handler did not take effect", response, "string2");
         // set the get request
-        factory.destroyForPort(1234);       
+        factory.destroyForPort(9234);       
         
     }
     
     @Test 
     public void testSetHandlers() throws Exception {
-        URL url = new URL("http://localhost:1245/hello/test");
+        URL url = new URL("http://localhost:9235/hello/test");
         JettyHTTPTestHandler handler1 = new JettyHTTPTestHandler("string1");
         JettyHTTPTestHandler handler2 = new JettyHTTPTestHandler("string2");
         
         JettyHTTPServerEngine engine = new JettyHTTPServerEngine();
-        engine.setPort(1245);
+        engine.setPort(9235);
         
         List<Handler> handlers = new ArrayList<Handler>();
         handlers.add(handler1);
@@ -202,9 +210,9 @@
     
     @Test 
     public void testGetContextHandler() throws Exception {
-        String urlStr = "http://localhost:1234/hello/test";
+        String urlStr = "http://localhost:9234/hello/test";
         JettyHTTPServerEngine engine = 
-            factory.createJettyHTTPServerEngine(1234, "http");
+            factory.createJettyHTTPServerEngine(9234, "http");
         ContextHandler contextHandler = engine.getContextHandler(new URL(urlStr));
         // can't find the context handler here
         assertNull(contextHandler);
@@ -223,7 +231,7 @@
             fail("Can't get the reponse from the server " + ex);
         }
         assertEquals("the jetty http handler did not take effect", response, "string2");
-        factory.destroyForPort(1234);
+        factory.destroyForPort(9234);
     }
     
     private String getResponse(String target) throws Exception {

Modified: incubator/cxf/branches/jliu/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSParameterJaxBUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSParameterJaxBUtils.java?rev=588283&r1=588282&r2=588283&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSParameterJaxBUtils.java (original)
+++ incubator/cxf/branches/jliu/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSParameterJaxBUtils.java Thu Oct 25 10:09:20 2007
@@ -23,13 +23,21 @@
 import java.net.URL;
 import java.security.GeneralSecurityException;
 import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.Collection;
 
 import javax.net.ssl.KeyManager;
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 
+import org.apache.cxf.configuration.security.CertStoreType;
 import org.apache.cxf.configuration.security.KeyManagersType;
 import org.apache.cxf.configuration.security.KeyStoreType;
 import org.apache.cxf.configuration.security.SecureRandomParameters;
@@ -108,6 +116,65 @@
         }
         return keyStore;
     }
+    
+    /**
+     * This method converts a JAXB generated CertStoreType into a KeyStore.
+     */
+    public static KeyStore getKeyStore(final CertStoreType pst)
+        throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
+        
+        if (pst == null) {
+            return null;
+        }
+
+        if (pst.isSetFile()) {
+            return createTrustStore(new FileInputStream(pst.getFile()));
+        }
+        if (pst.isSetResource()) {
+            return createTrustStore(
+                pst.getClass().getClassLoader().getResourceAsStream(
+                    pst.getResource()
+                )
+            );
+        }
+        if (pst.isSetUrl()) {
+            return createTrustStore(new URL(pst.getUrl()).openStream());
+        }
+        // TODO error?
+        return null;
+    }
+    
+    /**
+     * Create a KeyStore containing the trusted CA certificates contained
+     * in the supplied input stream.
+     */
+    private static KeyStore createTrustStore(final java.io.InputStream is)
+        throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
+        
+        final Collection<? extends Certificate> certs = loadCertificates(is);
+        final KeyStore keyStore = 
+            KeyStore.getInstance(KeyStore.getDefaultType());
+        keyStore.load(null, null);
+        for (Certificate cert : certs) {
+            final X509Certificate xcert = (X509Certificate) cert;
+            keyStore.setCertificateEntry(
+                xcert.getSubjectX500Principal().getName(), 
+                cert
+            );
+        }
+        return keyStore;
+    }
+    
+    /**
+     * load the certificates as X.509 certificates
+     */
+    private static Collection<? extends Certificate> 
+    loadCertificates(final java.io.InputStream is)
+        throws IOException, CertificateException {
+        
+        final CertificateFactory factory = CertificateFactory.getInstance("X.509");
+        return factory.generateCertificates(is);
+    }
 
     /**
      * This method converts the JAXB KeyManagersType into a list of 
@@ -145,23 +212,27 @@
      * This method converts the JAXB KeyManagersType into a list of 
      * JSSE TrustManagers.
      */
-    public static TrustManager[] getTrustManagers(TrustManagersType kmc) 
+    public static TrustManager[] getTrustManagers(TrustManagersType tmc) 
         throws GeneralSecurityException,
                IOException {
         
-        KeyStore keyStore = getKeyStore(kmc.getKeyStore());
-        
+        final KeyStore keyStore = 
+            tmc.isSetKeyStore()
+                ? getKeyStore(tmc.getKeyStore())
+                : (tmc.isSetCertStore()
+                    ? getKeyStore(tmc.getCertStore())
+                    : (KeyStore) null);
         if (keyStore == null) {
             return null;
         }
         
-        String alg = kmc.isSetFactoryAlgorithm()
-                     ? kmc.getFactoryAlgorithm()
+        String alg = tmc.isSetFactoryAlgorithm()
+                     ? tmc.getFactoryAlgorithm()
                      : KeyManagerFactory.getDefaultAlgorithm();
         
         TrustManagerFactory fac = 
-                     kmc.isSetProvider()
-                     ? TrustManagerFactory.getInstance(alg, kmc.getProvider())
+                     tmc.isSetProvider()
+                     ? TrustManagerFactory.getInstance(alg, tmc.getProvider())
                      : TrustManagerFactory.getInstance(alg);
                      
         fac.init(keyStore);



Mime
View raw message