View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.cxf.builder;
8   
9   
10  import javax.xml.namespace.QName;
11  
12  import org.apache.cxf.endpoint.Client;
13  import org.apache.cxf.endpoint.dynamic.DynamicClientFactory;
14  
15  /**
16   * Builds an outbound CXF MessageProcessor based on a WSDL using CXF's
17   * {@link DynamicClientFactory}. The <code>wsdlLocation</code> attribute
18   * is required. The port and service attributes can also be supplied to 
19   * select the correct service and port in the WSDL.
20   */
21  public class WsdlClientMessageProcessorBuilder extends AbstractOutboundMessageProcessorBuilder
22  {
23      private final static Object CLIENT_CREATION_LOCK = new Object();
24      
25      private String service;
26      private String port;
27      
28      public WsdlClientMessageProcessorBuilder()
29      {
30          super();
31      }
32      
33      protected Client createClient() throws Exception
34      {
35          synchronized (CLIENT_CREATION_LOCK)
36          {
37              DynamicClientFactory cf = DynamicClientFactory.newInstance(getBus());
38              return cf.createClient(getWsdlLocation(), 
39                 (service == null ? null : QName.valueOf(service)), 
40                 (getPort() == null ? null : QName.valueOf(getPort())));
41          }
42      }
43  
44      public String getService()
45      {
46          return service;
47      }
48  
49      public void setService(String service)
50      {
51          this.service = service;
52      }
53  
54      public String getPort()
55      {
56          return port;
57      }
58  
59      public void setPort(String port)
60      {
61          this.port = port;
62      }
63  
64  }