View Javadoc

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