cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r467687 - in /incubator/cxf/trunk/rt: bindings/http/src/test/java/org/apache/cxf/binding/http/wrapped/ bindings/soap/src/main/java/org/apache/cxf/binding/soap/ bindings/soap/src/main/resources/META-INF/cxf/ frontend/jaxws/src/main/java/org/...
Date Wed, 25 Oct 2006 15:51:00 GMT
Author: dandiep
Date: Wed Oct 25 08:50:58 2006
New Revision: 467687

URL: http://svn.apache.org/viewvc?view=rev&rev=467687
Log:
o Create a ClientFactoryBean and seperate out common logic from 
  ServerFactoryBean into AbstractEndpointFactory.
o Do a lookup of the DestinationFactoryManager from the Bus in the
  SoapDestinationFactory and actually set the Bus property in the 
  cxf-extension.xml file. This gets around an NPE and circular 
  reference problem.


Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientFactoryBean.java   (with props)
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractEndpointFactory.java   (with props)
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ClientFactoryBean.java   (with props)
    incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/AbstractSimpleFrontendTest.java   (with props)
    incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ClientFactoryBeanTest.java   (with props)
Modified:
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/wrapped/WrappedServiceTest.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapDestinationFactory.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/resources/META-INF/cxf/cxf-extension.xml
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ServerFactoryBean.java
    incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactoryTest.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ServiceModelHttpConfigurationProvider.java

Modified: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/wrapped/WrappedServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/wrapped/WrappedServiceTest.java?view=diff&rev=467687&r1=467686&r2=467687
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/wrapped/WrappedServiceTest.java (original)
+++ incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/wrapped/WrappedServiceTest.java Wed Oct 25 08:50:58 2006
@@ -18,6 +18,9 @@
  */
 package org.apache.cxf.binding.http.wrapped;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.w3c.dom.Document;
 
 import org.apache.cxf.binding.BindingFactoryManager;
@@ -28,7 +31,6 @@
 import org.apache.cxf.endpoint.ServerImpl;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.service.model.BindingOperationInfo;
-import org.apache.cxf.transport.http.JettyHTTPDestination;
 
 public class WrappedServiceTest extends AbstractRestTest {
     public void testCreation() throws Exception {
@@ -41,11 +43,12 @@
         sf.getServiceFactory().setWrapped(true);
         sf.setBindingFactory(new HttpBindingInfoFactoryBean());
         sf.setAddress("http://localhost:9001/");
-        sf.setStart(false);
+
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put("contextMatchStrategy", "stem");
+        sf.setProperties(props);
         
         ServerImpl svr = (ServerImpl) sf.create();
-        ((JettyHTTPDestination) svr.getDestination()).setContextMatchStrategy("stem");
-        svr.start();
                 
         URIMapper mapper = (URIMapper) svr.getEndpoint().getService().get(URIMapper.class.getName());
         assertNotNull(mapper);

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapDestinationFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapDestinationFactory.java?view=diff&rev=467687&r1=467686&r2=467687
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapDestinationFactory.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapDestinationFactory.java Wed Oct 25 08:50:58 2006
@@ -31,6 +31,7 @@
 import com.ibm.wsdl.extensions.soap.SOAPBindingImpl;
 import com.ibm.wsdl.extensions.soap.SOAPOperationImpl;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.soap.model.SoapBindingInfo;
 import org.apache.cxf.binding.soap.model.SoapOperationInfo;
@@ -47,25 +48,21 @@
 import org.apache.cxf.transport.DestinationFactoryManager;
 import org.apache.cxf.wsdl11.WSDLEndpointFactory;
 
-public class SoapDestinationFactory extends AbstractTransportFactory
-    implements DestinationFactory, WSDLEndpointFactory {
+public class SoapDestinationFactory extends AbstractTransportFactory implements DestinationFactory,
+    WSDLEndpointFactory {
     public static final String TRANSPORT_ID = "http://schemas.xmlsoap.org/soap/";
-    private DestinationFactoryManager destinationFactoryManager;
+    private Bus bus;
 
     public SoapDestinationFactory() {
         super();
     }
-    
-    public SoapDestinationFactory(DestinationFactoryManager destinationFactoyrManager) {
-        super();
-        this.destinationFactoryManager = destinationFactoyrManager;
-    }
-    
+
     public Destination getDestination(EndpointInfo ei) throws IOException {
         SoapBindingInfo binding = (SoapBindingInfo)ei.getBinding();
         DestinationFactory destinationFactory;
         try {
-            destinationFactory = destinationFactoryManager.getDestinationFactory(binding.getTransportURI());
+            destinationFactory = bus.getExtension(DestinationFactoryManager.class)
+                .getDestinationFactory(binding.getTransportURI());
 
             return destinationFactory.getDestination(ei);
         } catch (BusException e) {
@@ -75,7 +72,7 @@
     }
 
     public void createPortExtensors(EndpointInfo ei, Service service) {
-        SoapBindingInfo bi = (SoapBindingInfo) ei.getBinding();
+        SoapBindingInfo bi = (SoapBindingInfo)ei.getBinding();
         if (bi.getSoapVersion() instanceof Soap11) {
             createSoap11Extensors(ei, bi);
         }
@@ -84,22 +81,21 @@
     private void createSoap11Extensors(EndpointInfo ei, SoapBindingInfo bi) {
         SOAPAddress address = new SOAPAddressImpl();
         address.setLocationURI(ei.getAddress());
-        
+
         ei.addExtensor(address);
-        
-        
+
         SOAPBindingImpl sbind = new SOAPBindingImpl();
         sbind.setStyle(bi.getStyle());
         sbind.setTransportURI(bi.getTransportURI());
         bi.addExtensor(sbind);
-        
+
         for (BindingOperationInfo b : bi.getOperations()) {
             SoapOperationInfo soi = b.getExtensor(SoapOperationInfo.class);
-            
+
             SOAPOperationImpl op = new SOAPOperationImpl();
             op.setSoapActionURI(soi.getAction());
             op.setStyle(soi.getStyle());
-            
+
             b.addExtensor(op);
         }
     }
@@ -112,7 +108,7 @@
             if (SOAPBindingUtil.isSOAPAddress(extensor)) {
                 SoapAddress sa = SOAPBindingUtil.getSoapAddress(extensor);
 
-                SoapBindingInfo sbi = (SoapBindingInfo) b;
+                SoapBindingInfo sbi = (SoapBindingInfo)b;
                 EndpointInfo info = new EndpointInfo(serviceInfo, sbi.getTransportURI());
                 info.setAddress(sa.getLocationURI());
                 return info;
@@ -122,12 +118,13 @@
         return null;
     }
 
-    public DestinationFactoryManager getDestinationFactoryManager() {
-        return destinationFactoryManager;
+    public Bus getBus() {
+        return bus;
     }
 
     @Resource
-    public void setDestinationFactoryManager(DestinationFactoryManager destinationFactoryManager) {
-        this.destinationFactoryManager = destinationFactoryManager;
+    public void setBus(Bus bus) {
+        this.bus = bus;
     }
+
 }

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/resources/META-INF/cxf/cxf-extension.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/resources/META-INF/cxf/cxf-extension.xml?view=diff&rev=467687&r1=467686&r2=467687
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/resources/META-INF/cxf/cxf-extension.xml (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/resources/META-INF/cxf/cxf-extension.xml Wed Oct 25 08:50:58 2006
@@ -49,5 +49,6 @@
 				<value>http://schemas.xmlsoap.org/wsdl/soap12/</value>
             </list>
         </property>
+        <property name="bus" ref="cxf"/>
     </bean>
 </beans>

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java?view=auto&rev=467687
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java Wed Oct 25 08:50:58 2006
@@ -0,0 +1,216 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.jaxws;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.FutureTask;
+import java.util.logging.Logger;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Binding;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Holder;
+import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceException;
+
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.jaxws.support.ContextPropertiesMapping;
+import org.apache.cxf.service.factory.MethodDispatcher;
+import org.apache.cxf.service.model.BindingOperationInfo;
+
+public final class EndpointInvocationHandler extends BindingProviderImpl implements InvocationHandler {
+
+    private static final Logger LOG = LogUtils.getL7dLogger(EndpointInvocationHandler.class);
+
+    private Endpoint endpoint;
+
+    private Client client;
+
+    public EndpointInvocationHandler(Client c, Binding b) {
+        super(b);
+        endpoint = c.getEndpoint();
+        client = c;
+    }
+
+    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+       
+        MethodDispatcher dispatcher = 
+            (MethodDispatcher)endpoint.getService().get(MethodDispatcher.class.getName());
+        BindingOperationInfo oi = dispatcher.getBindingOperation(method, endpoint);
+        if (oi == null) {
+            // check for method on BindingProvider and Object
+            if (method.getDeclaringClass().equals(BindingProvider.class)
+                || method.getDeclaringClass().equals(BindingProviderImpl.class)
+                || method.getDeclaringClass().equals(Object.class)) {
+                return method.invoke(this);
+            }
+
+            Message msg = new Message("NO_OPERATION_INFO", LOG, method.getName());
+            throw new WebServiceException(msg.toString());
+        }
+       
+        Object[] params = args;
+        if (null == params) {
+            params = new Object[0];
+        }
+
+        Object[] paramsWithOutHolder = handleHolder(params);
+        Map<String, Object> requestContext = this.getRequestContext();
+        Map<String, Object> responseContext = this.getResponseContext();
+        Map<String, Object> context = new HashMap<String, Object>();
+        
+        //need to do context mapping from jax-ws to cxf message
+        ContextPropertiesMapping.mapJaxws2Cxf(requestContext);
+        
+        context.put(Client.REQUEST_CONTEXT, requestContext);
+        context.put(Client.RESPONSE_CONTEXT, responseContext);
+
+        requestContext.put(Method.class.getName(), method);
+
+        boolean isAsync = method.getName().endsWith("Async");
+        
+        Object result = null;
+        if (isAsync) {
+            result = invokeAsync(method, oi, params, paramsWithOutHolder, context);
+        } else {
+            result = invokeSync(method, oi, params, paramsWithOutHolder, context);
+        }
+        // need to do context mapping from cxf message to jax-ws 
+        ContextPropertiesMapping.mapJaxws2Cxf(responseContext);
+        return result;
+        
+    }
+
+
+    Object invokeSync(Method method, 
+                          BindingOperationInfo oi, 
+                          Object[] params, 
+                          Object[] paramsWithOutHolder, 
+                          Map<String, Object> context) throws Exception {
+        Object rawRet[] = client.invoke(oi, paramsWithOutHolder, context);
+
+        if (rawRet != null && rawRet.length != 0) {
+            List<Object> retList = new ArrayList<Object>();
+            handleHolderReturn(params, method, rawRet, retList);
+            Object[] obj = retList.toArray();
+            return obj == null || obj.length == 0 ? null : obj[0];
+        } else {
+            return null;
+        }
+    }
+    
+    Client getClient() {
+        return client;
+    }
+
+    private Object invokeAsync(Method method, 
+                               BindingOperationInfo oi, 
+                               Object[] params, 
+                               Object[] paramsWithOutHolder, 
+                               Map<String, Object> context) {
+        
+        FutureTask<Object> f = new FutureTask<Object>(new JAXWSAsyncCallable(this, 
+                                                                             method,
+                                                                             oi,
+                                                                             params,
+                                                                             paramsWithOutHolder,
+                                                                             context
+                                                                             ));
+
+        endpoint.getService().getExecutor().execute(f);
+
+        Response<?> r = new AsyncResponse<Object>(f, Object.class);
+        if (params.length > 0 && params[params.length - 1] instanceof AsyncHandler) {
+            // callback style
+            AsyncCallbackFuture callback = 
+                new AsyncCallbackFuture(r, (AsyncHandler)params[params.length - 1]);
+            endpoint.getService().getExecutor().execute(callback);
+            return callback;
+        } else {
+            return r;
+        }
+    }
+
+    private Object[] handleHolder(Object[] params) {
+        // get value out of Holder
+        Object[] ret = new Object[params.length];
+        for (int i = 0; i < params.length; i++) {
+            if (params[i] instanceof Holder) {
+                ret[i] = ((Holder)params[i]).value;
+            } else {
+                ret[i] = params[i];
+            }
+        }
+        return ret;
+    }
+
+    private void handleHolderReturn(Object[] params, Method method, Object[] rawRet, List<Object> retList) {
+
+        int idx = 0;
+
+        if (method == null) {
+            return;
+        }
+        if (!((Class)method.getReturnType()).getName().equals("void")) {
+            retList.add(rawRet[0]);
+            idx++;
+        }
+        int holderStartIndex = 0;
+        Type[] para = method.getGenericParameterTypes();
+        for (int i = 0; i < para.length; i++) {
+            if (para[i] instanceof ParameterizedType) {
+                ParameterizedType paramType = (ParameterizedType)para[i];
+                if (((Class)paramType.getRawType()).getName().equals("javax.xml.ws.Holder")) {
+                    break;
+                } else {
+                    holderStartIndex++;
+                }
+            } else {
+                holderStartIndex++;
+            }
+        }
+
+        for (int i = idx; i < rawRet.length; i++, holderStartIndex++) {
+            try {
+                ((Holder)params[holderStartIndex]).getClass().getField("value").set(params[holderStartIndex],
+                                                                                    rawRet[i]);
+            } catch (IllegalArgumentException e) {
+                e.printStackTrace();
+            } catch (SecurityException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            } catch (NoSuchFieldException e) {
+                e.printStackTrace();
+            }
+
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientFactoryBean.java?view=auto&rev=467687
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientFactoryBean.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientFactoryBean.java Wed Oct 25 08:50:58 2006
@@ -0,0 +1,31 @@
+/**
+ * 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.
+ */
+package org.apache.cxf.jaxws;
+
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.service.factory.ClientFactoryBean;
+
+/**
+ * Bean to help easily create Client endpoints for JAX-WS.
+ */
+public class JaxWsClientFactoryBean extends ClientFactoryBean {
+    public JaxWsClientFactoryBean() {
+        setServiceFactory(new JaxWsServiceFactoryBean());
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientFactoryBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientFactoryBean.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientFactoryBean.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java?view=diff&rev=467687&r1=467686&r2=467687
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java Wed Oct 25 08:50:58 2006
@@ -50,10 +50,12 @@
             .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
 
         DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-        SoapDestinationFactory soapDF = new SoapDestinationFactory(dfm);
+
+        SoapDestinationFactory soapDF = new SoapDestinationFactory();
+        soapDF.setBus(bus);
         dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
         dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF);
-
+        
         localTransport = new LocalTransportFactory();
         dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
         dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java?view=diff&rev=467687&r1=467686&r2=467687
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java Wed Oct 25 08:50:58 2006
@@ -320,7 +320,8 @@
             .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
 
         DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-        SoapDestinationFactory soapDF = new SoapDestinationFactory(dfm);
+        SoapDestinationFactory soapDF = new SoapDestinationFactory();
+        soapDF.setBus(bus);
         dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
         dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF);
 

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java?view=diff&rev=467687&r1=467686&r2=467687
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java Wed Oct 25 08:50:58 2006
@@ -25,6 +25,9 @@
 
 import javax.xml.ws.WebServiceContext;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusException;
+import org.apache.cxf.BusFactoryHelper;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.service.invoker.BeanInvoker;
@@ -33,6 +36,13 @@
 import org.apache.hello_world_soap_http.GreeterImpl;
 
 public class EndpointImplTest extends AbstractJaxWsTest {
+
+    
+    @Override
+    protected Bus createBus() throws BusException {
+        return BusFactoryHelper.newInstance().getDefaultBus();
+    }
+
 
     public void testEndpoint() throws Exception {   
         GreeterImpl greeter = new GreeterImpl();

Added: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractEndpointFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractEndpointFactory.java?view=auto&rev=467687
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractEndpointFactory.java (added)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractEndpointFactory.java Wed Oct 25 08:50:58 2006
@@ -0,0 +1,223 @@
+/**
+ * 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.
+ */
+package org.apache.cxf.service.factory;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusException;
+import org.apache.cxf.BusFactoryHelper;
+import org.apache.cxf.binding.soap.SoapBindingInfoFactoryBean;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointException;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.wsdl11.WSDLEndpointFactory;
+
+public abstract class AbstractEndpointFactory {
+
+    private Bus bus;
+    private String address;
+    private String transportId;
+    private AbstractBindingInfoFactoryBean bindingFactory;
+    private Class serviceClass;
+    private DestinationFactory destinationFactory;
+    private ReflectionServiceFactoryBean serviceFactory;
+    private QName endpointName;
+    private Map<String, Object> properties;
+    
+    protected Endpoint createEndpoint() throws BusException, EndpointException {
+        Service service = serviceFactory.getService();
+        
+        if (service == null) {
+            serviceFactory.setServiceClass(getServiceClass());
+            serviceFactory.setBus(getBus());
+            service = serviceFactory.create();
+        }
+        
+        if (endpointName == null) {
+            endpointName = serviceFactory.getEndpointName();
+        }
+
+        EndpointInfo ei = service.getServiceInfo().getEndpoint(endpointName);
+        Endpoint ep = null;
+        if (ei == null) {
+            ei = createEndpointInfo();
+        } else if (getAddress() != null) {
+            ei.setAddress(getAddress()); 
+        }                        
+        
+        setProperties(ei);
+        
+        ep = service.getEndpoints().get(ei.getName());
+        if (ep == null) {
+            ep = serviceFactory.createEndpoint(ei);
+        }
+        service.getEndpoints().put(ep.getEndpointInfo().getName(), ep);
+        return ep;
+    }
+
+    private void setProperties(EndpointInfo ei) {
+        if (properties == null) {
+            return;
+        }
+        
+        for (Map.Entry<String, Object> e : properties.entrySet()) {
+            ei.setProperty(e.getKey(), e.getValue());
+        }
+    }
+
+    protected EndpointInfo createEndpointInfo() throws BusException {
+        if (transportId == null) {
+            if (getAddress() != null) {
+                DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
+                DestinationFactory df = dfm.getDestinationFactoryForUri(getAddress());
+                if (df != null) {
+                    transportId = df.getTransportIds().get(0);
+                }
+            }
+            
+            if (transportId == null) {
+                // TODO: we shouldn't have to do this, but the DF is null because the
+                // LocalTransport doesn't return for the http:// uris
+                // People also seem to be supplying a null JMS getAddress(), which is worrying
+                transportId = "http://schemas.xmlsoap.org/wsdl/soap/http";
+            }
+        }
+        
+        // SOAP nonsense
+        if (getBindingFactory() instanceof SoapBindingInfoFactoryBean) {
+            ((SoapBindingInfoFactoryBean) getBindingFactory()).setTransportURI(transportId);
+            transportId = "http://schemas.xmlsoap.org/wsdl/soap/";
+        }
+        
+        setTransportId(transportId);
+        
+        DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
+        destinationFactory = dfm.getDestinationFactory(transportId);
+        
+        // Get the Service from the ServiceFactory if specified
+        Service service = serviceFactory.getService();
+        getBindingFactory().setServiceFactory(serviceFactory);
+        BindingInfo bindingInfo = getBindingFactory().create();
+        service.getServiceInfo().addBinding(bindingInfo);
+        
+        EndpointInfo ei = new EndpointInfo(service.getServiceInfo(), transportId);
+        ei.setName(endpointName);
+        ei.setAddress(getAddress());
+        ei.setBinding(bindingInfo);
+        
+        if (destinationFactory instanceof WSDLEndpointFactory) {
+            WSDLEndpointFactory we = (WSDLEndpointFactory) destinationFactory;
+            
+            we.createPortExtensors(ei, service);
+        } else {
+            // ?
+        }
+        service.getServiceInfo().addEndpoint(ei);
+        return ei;
+    }
+
+    
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public Bus getBus() {
+        if (bus == null) {
+            bus = BusFactoryHelper.newInstance().getDefaultBus();
+        }
+        return bus;
+    }
+
+    public void setBus(Bus bus) {
+        this.bus = bus;
+    }
+
+    public String getTransportId() {
+        return transportId;
+    }
+
+    public void setTransportId(String transportId) {
+        this.transportId = transportId;
+    }
+
+    public AbstractBindingInfoFactoryBean getBindingFactory() {
+        return bindingFactory;
+    }
+
+    public void setBindingFactory(AbstractBindingInfoFactoryBean bindingFactory) {
+        this.bindingFactory = bindingFactory;
+    }
+
+    public Class getServiceClass() {
+        return serviceClass;
+    }
+
+    public void setServiceClass(Class serviceClass) {
+        this.serviceClass = serviceClass;
+    }
+
+
+    public DestinationFactory getDestinationFactory() {
+        return destinationFactory;
+    }
+
+
+    public void setDestinationFactory(DestinationFactory destinationFactory) {
+        this.destinationFactory = destinationFactory;
+    }
+
+
+    public ReflectionServiceFactoryBean getServiceFactory() {
+        return serviceFactory;
+    }
+
+
+    public void setServiceFactory(ReflectionServiceFactoryBean serviceFactory) {
+        this.serviceFactory = serviceFactory;
+    }
+
+
+    public QName getEndpointName() {
+        return endpointName;
+    }
+
+
+    public void setEndpointName(QName endpointName) {
+        this.endpointName = endpointName;
+    }
+
+    public Map<String, Object> getProperties() {
+        return properties;
+    }
+
+    public void setProperties(Map<String, Object> properties) {
+        this.properties = properties;
+    }
+}
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractEndpointFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractEndpointFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractEndpointFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ClientFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ClientFactoryBean.java?view=auto&rev=467687
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ClientFactoryBean.java (added)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ClientFactoryBean.java Wed Oct 25 08:50:58 2006
@@ -0,0 +1,60 @@
+/**
+ * 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.
+ */
+package org.apache.cxf.service.factory;
+
+import org.apache.cxf.BusException;
+import org.apache.cxf.binding.soap.SoapBindingInfoFactoryBean;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointException;
+
+public class ClientFactoryBean extends AbstractEndpointFactory {
+    private Client client;
+    
+    public ClientFactoryBean() {
+        super();
+        setBindingFactory(new SoapBindingInfoFactoryBean());
+        setServiceFactory(new ReflectionServiceFactoryBean());
+    }
+
+    public Client create() {
+        try {
+            Endpoint ep = createEndpoint();
+            
+            client = new ClientImpl(getBus(), ep);
+        } catch (EndpointException e) {
+            throw new ServiceConstructionException(e);
+        } catch (BusException e) {
+            throw new ServiceConstructionException(e);
+        }
+        
+        return client;
+    }
+
+    public Client getClient() {
+        return client;
+    }
+
+    public void setClient(Client client) {
+        this.client = client;
+    }
+    
+    
+}

Propchange: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ClientFactoryBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ClientFactoryBean.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ClientFactoryBean.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=467687&r1=467686&r2=467687
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Wed Oct 25 08:50:58 2006
@@ -25,6 +25,7 @@
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.concurrent.Executor;
 import java.util.logging.Logger;
@@ -91,6 +92,7 @@
     private List<String> ignoredClasses = new ArrayList<String>();
     private SimpleMethodDispatcher methodDispatcher = new SimpleMethodDispatcher();
     private boolean wrappedStyle = true;
+    private Map<String, Object> properties;
     
     public ReflectionServiceFactoryBean() {
         getServiceConfigurations().add(0, new DefaultServiceConfiguration());
@@ -194,6 +196,10 @@
             
             setService(service);
         }
+        
+        if (properties != null) {
+            getService().putAll(properties);
+        }
     }
 
     protected void initializeWSDLOperations() {
@@ -788,6 +794,14 @@
 
     public void setWrapped(boolean style) {
         this.wrappedStyle = style;
+    }
+
+    public Map<String, Object> getProperties() {
+        return properties;
+    }
+
+    public void setProperties(Map<String, Object> properties) {
+        this.properties = properties;
     }
     
 }

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ServerFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ServerFactoryBean.java?view=diff&rev=467687&r1=467686&r2=467687
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ServerFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ServerFactoryBean.java Wed Oct 25 08:50:58 2006
@@ -20,69 +20,58 @@
 
 import java.io.IOException;
 
-import javax.xml.namespace.QName;
-
-import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.soap.SoapBindingInfoFactoryBean;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.endpoint.ServerImpl;
-import org.apache.cxf.service.Service;
-import org.apache.cxf.service.model.BindingInfo;
-import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.ChainInitiationObserver;
-import org.apache.cxf.transport.DestinationFactory;
-import org.apache.cxf.transport.DestinationFactoryManager;
-import org.apache.cxf.wsdl11.WSDLEndpointFactory;
 
-public class ServerFactoryBean {
-    private ReflectionServiceFactoryBean serviceFactory;
-    private Service service;
-    private DestinationFactory destinationFactory;
+/**
+ * This class helps take a {@link org.apache.cxf.service.Service} and 
+ * expose as a server side endpoint.
+ * If there is no Service, it can create one for you using a 
+ * {@link ReflectionServiceFactoryBean}.
+ * <p>
+ * For most scenarios you'll want to just have the ServerFactoryBean handle everything
+ * for you. In such a case, usage might look like this:
+ * </p>
+ * <pre>
+ * ServerFactoryBean sf = new ServerFactoryBean();
+ * sf.setServiceClass(MyService.class);
+ * sf.setAddress("http://localhost:8080/MyService");
+ * sf.create();
+ * </pre>
+ * <p>
+ * You can also get more advanced and customize the service factory used:
+ * <pre>
+ * ReflectionServiceFactory serviceFactory = new ReflectionServiceFactory();
+ * serviceFactory.setServiceClass(MyService.class);
+ * ..
+ * \/\/ Customize service factory here...
+ * serviceFactory.setWrapped(false);
+ * ...
+ * ServerFactoryBean sf = new ServerFactoryBean();
+ * sf.setServiceFactory(serviceFactory);
+ * sf.setAddress("http://localhost:8080/MyService");
+ * sf.create();
+ * </pre>
+ */
+public class ServerFactoryBean extends AbstractEndpointFactory {
     private Server server;
-    private Bus bus;
-    private String address;
-    private String transportId; // where should this come from???
-    private AbstractBindingInfoFactoryBean bindingFactory;
-    private QName endpointName;
     private boolean start = true;
-    private Class serviceClass;
     
     public ServerFactoryBean() {
         super();
-        bindingFactory = new SoapBindingInfoFactoryBean();
+        setBindingFactory(new SoapBindingInfoFactoryBean());
+        setServiceFactory(new ReflectionServiceFactoryBean());
     }
     
     public Server create() {
         try {
-            service = serviceFactory.getService();
-            
-            if (service == null) {
-                serviceFactory.setServiceClass(serviceClass);
-                serviceFactory.setBus(bus);
-                service = serviceFactory.create();
-            }
-            
-            if (endpointName == null) {
-                endpointName = serviceFactory.getEndpointName();
-            }
-
-            EndpointInfo ei = service.getServiceInfo().getEndpoint(endpointName);
-            Endpoint ep = null;
-            if (ei == null) {
-                ei = createEndpoint();
-            } else if (address != null) {
-                ei.setAddress(address); 
-            }                        
-            
-            ep = service.getEndpoints().get(ei.getName());
-            if (ep == null) {
-                ep = serviceFactory.createEndpoint(ei);
-            }
-            service.getEndpoints().put(ep.getEndpointInfo().getName(), ep);
-            server = new ServerImpl(bus, ep, new ChainInitiationObserver(ep, bus));
+            Endpoint ep = createEndpoint();
+            server = new ServerImpl(getBus(), ep, new ChainInitiationObserver(ep, getBus()));
             
             if (start) {
                 server.start();
@@ -98,78 +87,6 @@
         return server;
     }
 
-    private EndpointInfo createEndpoint() throws BusException {
-        if (transportId == null) {
-            if (address != null) {
-                DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-                DestinationFactory df = dfm.getDestinationFactoryForUri(address);
-                if (df != null) {
-                    transportId = df.getTransportIds().get(0);
-                }
-            }
-            
-            if (transportId == null) {
-                // TODO: we shouldn't have to do this, but the DF is null because the
-                // LocalTransport doesn't return for the http:// uris
-                // People also seem to be supplying a null JMS address, which is worrying
-                transportId = "http://schemas.xmlsoap.org/wsdl/soap/http";
-            }
-        }
-        
-        // SOAP nonsense
-        if (bindingFactory instanceof SoapBindingInfoFactoryBean) {
-            ((SoapBindingInfoFactoryBean) bindingFactory).setTransportURI(transportId);
-            transportId = "http://schemas.xmlsoap.org/wsdl/soap/";
-        }
-        
-        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-        destinationFactory = dfm.getDestinationFactory(transportId);
-        
-        // Get the Service from the ServiceFactory if specified        
-        bindingFactory.setServiceFactory(serviceFactory);
-        BindingInfo bindingInfo = bindingFactory.create();
-        service.getServiceInfo().addBinding(bindingInfo);
-        
-        EndpointInfo ei = new EndpointInfo(service.getServiceInfo(), transportId);
-        ei.setName(endpointName);
-        ei.setAddress(address);
-        ei.setBinding(bindingInfo);
-        
-        if (destinationFactory instanceof WSDLEndpointFactory) {
-            WSDLEndpointFactory we = (WSDLEndpointFactory) destinationFactory;
-            
-            we.createPortExtensors(ei, service);
-        } else {
-            // ?
-        }
-        service.getServiceInfo().addEndpoint(ei);
-        return ei;
-    }
-
-    public String getAddress() {
-        return address;
-    }
-
-    public void setAddress(String address) {
-        this.address = address;
-    }
-
-    public Bus getBus() {
-        return bus;
-    }
-
-    public void setBus(Bus bus) {
-        this.bus = bus;
-    }
-
-    public DestinationFactory getDestinationFactory() {
-        return destinationFactory;
-    }
-
-    public void setDestinationFactory(DestinationFactory destinationFactory) {
-        this.destinationFactory = destinationFactory;
-    }
-
     public Server getServer() {
         return server;
     }
@@ -178,51 +95,11 @@
         this.server = server;
     }
 
-    public ReflectionServiceFactoryBean getServiceFactory() {
-        return serviceFactory;
-    }
-
-    public void setServiceFactory(ReflectionServiceFactoryBean serviceFactory) {
-        this.serviceFactory = serviceFactory;
-    }
-
-    public String getTransportId() {
-        return transportId;
-    }
-
-    public void setTransportId(String transportId) {
-        this.transportId = transportId;
-    }
-
-    public QName getEndpointName() {
-        return endpointName;
-    }
-
-    public void setEndpointName(QName endpointName) {
-        this.endpointName = endpointName;
-    }
-
     public boolean isStart() {
         return start;
     }
 
     public void setStart(boolean start) {
         this.start = start;
-    }
-
-    public AbstractBindingInfoFactoryBean getBindingFactory() {
-        return bindingFactory;
-    }
-
-    public void setBindingFactory(AbstractBindingInfoFactoryBean bindingFactory) {
-        this.bindingFactory = bindingFactory;
-    }
-
-    public Class getServiceClass() {
-        return serviceClass;
-    }
-
-    public void setServiceClass(Class serviceClass) {
-        this.serviceClass = serviceClass;
     }    
-}
+}
\ No newline at end of file

Added: incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/AbstractSimpleFrontendTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/AbstractSimpleFrontendTest.java?view=auto&rev=467687
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/AbstractSimpleFrontendTest.java (added)
+++ incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/AbstractSimpleFrontendTest.java Wed Oct 25 08:50:58 2006
@@ -0,0 +1,58 @@
+/**
+ * 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.
+ */
+package org.apache.cxf.service.factory;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.binding.soap.SoapBindingFactory;
+import org.apache.cxf.binding.soap.SoapDestinationFactory;
+import org.apache.cxf.test.AbstractCXFTest;
+import org.apache.cxf.transport.ConduitInitiatorManager;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.transport.local.LocalTransportFactory;
+
+public abstract class AbstractSimpleFrontendTest extends AbstractCXFTest {
+
+    public void setUp() throws Exception {
+        super.setUp();
+        
+        Bus bus = getBus();
+        
+        SoapBindingFactory bindingFactory = new SoapBindingFactory();
+
+        bus.getExtension(BindingFactoryManager.class)
+            .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
+
+        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
+        SoapDestinationFactory soapDF = new SoapDestinationFactory();
+        soapDF.setBus(bus);
+        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
+        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF);
+
+        LocalTransportFactory localTransport = new LocalTransportFactory();
+        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
+        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
+
+        ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
+        extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
+        extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
+        extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
+    }
+    
+}

Propchange: incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/AbstractSimpleFrontendTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/AbstractSimpleFrontendTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/AbstractSimpleFrontendTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ClientFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ClientFactoryBeanTest.java?view=auto&rev=467687
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ClientFactoryBeanTest.java (added)
+++ incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ClientFactoryBeanTest.java Wed Oct 25 08:50:58 2006
@@ -0,0 +1,76 @@
+/**
+ * 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.
+ */
+package org.apache.cxf.service.factory;
+
+import java.util.Map;
+
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.binding.soap.model.SoapBindingInfo;
+import org.apache.cxf.binding.soap.model.SoapOperationInfo;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.jaxb.JAXBDataBinding;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+
+public class ClientFactoryBeanTest extends AbstractSimpleFrontendTest {
+
+    public void testClientFactoryBean() throws Exception {
+        
+        ClientFactoryBean cfBean = new ClientFactoryBean();
+        cfBean.setAddress("http://localhost/Hello");
+        cfBean.setTransportId("http://schemas.xmlsoap.org/soap/http");
+        cfBean.setBus(getBus());
+        cfBean.setServiceClass(HelloService.class);
+        cfBean.getServiceFactory().setDataBinding(new JAXBDataBinding(HelloService.class));
+        
+        Client client = cfBean.create();
+        assertNotNull(client);
+        
+        Service service = client.getEndpoint().getService();
+        Map<QName, Endpoint> eps = service.getEndpoints();
+        assertEquals(1, eps.size());
+        
+        Endpoint ep = eps.values().iterator().next();
+        EndpointInfo endpointInfo = ep.getEndpointInfo();
+        
+        SOAPAddress soapAddress = endpointInfo.getExtensor(SOAPAddress.class);
+        assertNotNull(soapAddress);
+        
+        BindingInfo b = service.getServiceInfo().getBindings().iterator().next();
+        
+        assertTrue(b instanceof SoapBindingInfo);
+        
+        SoapBindingInfo sb = (SoapBindingInfo) b;
+        assertEquals("HelloServiceSoapBinding", b.getName().getLocalPart());
+        assertEquals("document", sb.getStyle());
+        
+        assertEquals(4, b.getOperations().size());
+        
+        BindingOperationInfo bop = b.getOperations().iterator().next();
+        SoapOperationInfo sop = bop.getExtensor(SoapOperationInfo.class);
+        assertNotNull(sop);
+        assertEquals("", sop.getAction());
+        assertEquals("document", sop.getStyle());
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ClientFactoryBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ClientFactoryBeanTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ClientFactoryBeanTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactoryTest.java?view=diff&rev=467687&r1=467686&r2=467687
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactoryTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactoryTest.java Wed Oct 25 08:50:58 2006
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.service.factory;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -25,10 +26,6 @@
 import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
 
-import org.apache.cxf.Bus;
-import org.apache.cxf.binding.BindingFactoryManager;
-import org.apache.cxf.binding.soap.SoapBindingFactory;
-import org.apache.cxf.binding.soap.SoapDestinationFactory;
 import org.apache.cxf.binding.soap.model.SoapBindingInfo;
 import org.apache.cxf.binding.soap.model.SoapOperationInfo;
 import org.apache.cxf.endpoint.Endpoint;
@@ -42,39 +39,10 @@
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.ServiceInfo;
-import org.apache.cxf.test.AbstractCXFTest;
-import org.apache.cxf.transport.ConduitInitiatorManager;
-import org.apache.cxf.transport.DestinationFactoryManager;
-import org.apache.cxf.transport.local.LocalTransportFactory;
 
-public class ReflectionServiceFactoryTest extends AbstractCXFTest {
+public class ReflectionServiceFactoryTest extends AbstractSimpleFrontendTest {
     private ReflectionServiceFactoryBean serviceFactory;
 
-    public void setUp() throws Exception {
-        super.setUp();
-        
-        Bus bus = getBus();
-        
-        SoapBindingFactory bindingFactory = new SoapBindingFactory();
-
-        bus.getExtension(BindingFactoryManager.class)
-            .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
-
-        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-        SoapDestinationFactory soapDF = new SoapDestinationFactory(dfm);
-        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
-        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF);
-
-        LocalTransportFactory localTransport = new LocalTransportFactory();
-        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
-        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
-
-        ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
-        extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
-        extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
-        extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
-    }
-
     public void testUnwrappedBuild() throws Exception {
         Service service = createService(false);
         
@@ -153,11 +121,16 @@
         serviceFactory.setServiceClass(HelloService.class);
         serviceFactory.setWrapped(wrapped);
         
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put("test", "test");
+        serviceFactory.setProperties(props);
+        
         return serviceFactory.create();        
     }
     
     public void testServerFactoryBean() throws Exception {
         Service service = createService(true);
+        assertEquals("test", service.get("test"));
         
         ServerFactoryBean svrBean = new ServerFactoryBean();
         svrBean.setAddress("http://localhost/Hello");
@@ -165,6 +138,11 @@
         svrBean.setServiceFactory(serviceFactory);
         svrBean.setBus(getBus());
         
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put("test", "test");
+        serviceFactory.setProperties(props);
+        svrBean.setProperties(props);
+        
         Server server = svrBean.create();
         assertNotNull(server);
         Map<QName, Endpoint> eps = service.getEndpoints();
@@ -172,6 +150,8 @@
         
         Endpoint ep = eps.values().iterator().next();
         EndpointInfo endpointInfo = ep.getEndpointInfo();
+        
+        assertEquals("test", endpointInfo.getProperty("test"));
         
         SOAPAddress soapAddress = endpointInfo.getExtensor(SOAPAddress.class);
         assertNotNull(soapAddress);

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ServiceModelHttpConfigurationProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ServiceModelHttpConfigurationProvider.java?view=diff&rev=467687&r1=467686&r2=467687
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ServiceModelHttpConfigurationProvider.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ServiceModelHttpConfigurationProvider.java Wed Oct 25 08:50:58 2006
@@ -47,7 +47,7 @@
             return info.getExtensor(HTTPClientPolicy.class);
         }
 
-        return null;
+        return info.getProperty(name);
     }
 
     /**



Mime
View raw message